|
Rank: Newbie Groups: Member
Joined: 3/4/2013 Posts: 2
|
Hello,
I am working on a report with asp.net and c# as language. we have recently bought EO.Pdf 2012 for .NET, I am generating report within same page. It's work really great, If i don't use any other option with ASPXtoPDf, but i need only portion of the page which has report table need to print to pdf, whn i am tring to do. It is not working properly, I tried to do it with two differnt way.
On button click event (Generate Report to PDF)
ASPXToCertPDF.RenderAsPDF(false);
HtmlToPdf.Options.VisibleElementIds = "reports";
HtmlToPdfResult result = (HtmlToPdfResult)ASPXToCertPDF.Result;
string fileName = "newfile.pdf";
result.PdfDocument.Save(fileName);
But Last line giving me error: Value cannot be null. Parameter name: type
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.
Exception Details: System.ArgumentNullException: Value cannot be null. Parameter name: type
because ASPXTOCertPDF.result contain empty
Another way what i tried is On button click event Generate Report to pdf
HtmlToPdf.Options.InvisibleElementIds = "header, leftCol, gvSerialNumber"; HtmlToPdf.Options.visibleElementIds = report
ASPXToCertPDF.RenderAsPDF(false);
but still it contain some of the invisibleElement in PDF file.
What is the solution, Please help me
Thanks,
|
|
Rank: Administration Groups: Administration
Joined: 5/27/2007 Posts: 24,195
|
Hi,
The IDs are separated by ";", not by ",".
Also you need to access the Result property from inside AfterRender event handler.
Thanks!
|
|
Rank: Newbie Groups: Member
Joined: 3/4/2013 Posts: 2
|
I tried with ";" and also created after render event, but 1st after render event is not executing. and if i call from click event, still getting same error.
protected void ASPXToCertPDF_AfterRender(object sender, EventArgs e) { HtmlToPdf.Options.InvisibleElementIds = "header; leftCol; gvSerialNumber;"; HtmlToPdf.Options.VisibleElementIds = "report";
HtmlToPdfResult result = (HtmlToPdfResult)ASPXToCertPDF.Result; string fileName = "file1.pdf"; result.PdfDocument.Save(fileName); }
protected void btnExporttoPDF_Click(object sender, EventArgs e) { ASPXToCertPDF.RenderAsPDF(false); }
|
|
Rank: Administration Groups: Administration
Joined: 5/27/2007 Posts: 24,195
|
Hi,
As to the event not executing problem, you need to check whether your event handler is correctly hooked up. You can take a look of the web sample project in your installation folder to troubleshoot that problem.
As to the InvisibleElementIds. Do two things: 1. You set the Options BEFORE the conversion, check the result AFTER the conversion; 2. Do not include spaces;
Thanks!
|
|