View Single Post
  #3 (permalink)  
Old May 26th, 2014, 04:26 AM
BrendaBessi BrendaBessi is offline
Registered User
Points: 21, Level: 1
Points: 21, Level: 1 Points: 21, Level: 1 Points: 21, Level: 1
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
Join Date: Dec 2013
Posts: 7
Thanks: 0
Thanked 0 Times in 0 Posts
Default RE: using Page.RenderControl()

Hi, try overriding the VerifyRenderingInServerForm method, like the following:
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:
protected void ExportToPDF()
	System.IO.StringWriter oStringWriter = new System.IO.StringWriter();
	System.Web.UI.HtmlTextWriter oHtmlTextWriter = new System.Web.UI.HtmlTextWriter(oStringWriter);
	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.
Reply With Quote