Hi, try overriding the
VerifyRenderingInServerForm method, like the following:
Code:
public override void VerifyRenderingInServerForm(Control control)
{ }
That worked for me and I hope it will help anyone that encounters this issue. Also I used a different third party component,
this Word DLL written in C#, here is how you can try it out:
Code:
protected void ExportToPDF()
{
System.IO.StringWriter oStringWriter = new System.IO.StringWriter();
System.Web.UI.HtmlTextWriter oHtmlTextWriter = new System.Web.UI.HtmlTextWriter(oStringWriter);
Page.RenderControl(oHtmlTextWriter);
string pageSoure = oStringWriter.ToString();
DocumentModel document;
HtmlLoadOptions option = new HtmlLoadOptions() { BaseAddress = this.Request.PhysicalApplicationPath };
using (Stream htmlStream = new System.IO.MemoryStream(option.Encoding.GetBytes(pageSoure)))
document = DocumentModel.Load(htmlStream, option);
PageSetup page = document.Sections[0].PageSetup;
page.PageWidth = 900;
page.PageMargins.Left = 25;
page.PageMargins.Right = 25;
page.Orientation = Orientation.Landscape;
page.PaperType = PaperType.A4;
document.Save(Request.PhysicalApplicationPath + @"\temp\" + pageID.ToString() + ".pdf");
}
In one of my previous project I used it to
convert HTML files (from various sources) into PDF files through C#. Also before showing them I needed to join these multiple files (this can also be easily done in this DLL with import method) and then
export the generated PDF to an ASP.NET client.