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");
        }
    }

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

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.