I get the error "Input string was not in a correct format" every single time I call .DrawToWeb() and I can't figure out why. Here is the code I currently have:
MergeDocument mdPDFDocument = new MergeDocument(MapPath("Agreements/Current/Agreement.pdf"));
mdPDFDocument.Form.Fields["Date"].Value = PageLoadTime.ToString("MMMM d, yyyy");
mdPDFDocument.Form.Fields["Company"].Value = (String)dsData.Tables[0].Rows[0]["FirstName"] + " " + (String)dsData.Tables[0].Rows[0]["LastName"];
mdPDFDocument.Form.Fields["State"].Value = (String)dsData.Tables[0].Rows[0]["StateName"];
if (CommonFunctions.ConvertToString(dsData.Tables[0].Rows[0]["Address2"]) == "")
{
mdPDFDocument.Form.Fields["Address"].Value = (String)dsData.Tables[0].Rows[0]["Address1"];
}
else
{
mdPDFDocument.Form.Fields["Address"].Value = (String)dsData.Tables[0].Rows[0]["Address1"] + " " + (String)dsData.Tables[0].Rows[0]["Address2"];
}
mdPDFDocument.Form.IsReadOnly = true;
mdPDFDocument.DrawToWeb("Test.pdf");
I've also tried using .Draw() like this:
mdPDFDocument.Draw(MapPath("Agreements/Current/AgreementTest.pdf"));
But I get the following error:
Access to the path 'C:\inetpub\wwwroot\TestSite\Agreements\Current\AgreementTest.pdf' is denied.
This is my first time using DynamicPDF in C#, I never encountered any errors when using VB.NET. Any suggestions? This is super frustrating and I can't figure out what I'm doing wrong.