0

I'm building an application in asp.net mcv, using Entity Framework and am running into some problems. My requirements are to take a pdf template and fill the pdf with information form a database. When try to return the data from the databse all I get is the EF genearted sql.

This is what displays in my text box on my pdf form

SELECT
[Extent1].[Applicant_ID] AS [Applicant_ID]
FROM [dbo].[W4] AS [Extent1]

This is the controller with the linq query

 public ActionResult Index()
        {

            string template = @"c:\users\carisch\documents\visual studio 2013\Projects\NewTry\NewTry\fw4.pdf";
            string newFile = @"c:\users\carisch\documents\visual studio 2013\Projects\NewTry\NewTry\Newfw4.pdf";

            PdfReader reader = new PdfReader(template);
            PdfStamper stamper = new PdfStamper(reader, new FileStream(newFile, FileMode.Create));

            AcroFields fields = stamper.AcroFields;

            var context = new NewTryContext();

            var id = context.W4.Where(c => c.ID == 2).FirstOrDefault();
            List<W4> myList = new List<W4>();
            myList.Add(id);

            fields.SetField("f1_15_0_", myList.ToString());

            stamper.FormFlattening = false;
            stamper.Close();

            return File(@"c:\users\carisch\documents\visual studio 2013\Projects\NewTry\NewTry\Newfw4.pdf", "application/pdf");
        }
    }
2
Contributors
1
Reply
18
Views
2 Years
Discussion Span
Last Post by clairestreb
0

I think you want to add a select clause to line 14, use the result in line 18, and remove lines 15 and 16.

Edited by clairestreb

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.