|
Rank: Newbie Groups: Member
Joined: 12/19/2014 Posts: 2
|
Here is my error .Please help me.
EO.Pdf.HtmlToPdfException: Convertion failed. Object reference not set to an instance of an object. ---> System.NullReferenceException: Object reference not set to an instance of an object. at EO.Pdf.Internal.ew..ctor(j9 A_0, Boolean A_1, Int32 A_2, jg A_3, Int32 A_4, Single A_5, Rectangle A_6, PdfPage A_7, eo A_8) at EO.Pdf.Internal.j9.a(PdfPage A_0, Boolean A_1, Int32 A_2, Rectangle A_3, jg A_4, f8 A_5) at EO.Pdf.Internal.j9.a(Int32 A_0, HtmlToPdfResult A_1) at EO.Pdf.Internal.j9.h() --- End of inner exception stack trace --- at EO.Pdf.HtmlToPdfException.b(Exception A_0) at EO.Pdf.Internal.j9.h() at EO.Pdf.HtmlToPdf.a(j9 A_0) at EO.Pdf.HtmlToPdf.ConvertUrl(String url, PdfDocument doc, HtmlToPdfOptions options)
|
|
Rank: Administration Groups: Administration
Joined: 5/27/2007 Posts: 24,196
|
Hi, Please check whether the same problem occurs with the latest build. If it still occurs, you can try to isolate the problem into a test HTML file and send the HTML file to us. Once we have that we will be happy to take a look. See here for test project/file guidelines: http://www.essentialobjects.com/forum/test_project.aspxThanks!
|
|
Rank: Newbie Groups: Member
Joined: 12/19/2014 Posts: 2
|
Here is my source code.
//start public class PrintCommonUtil { public PrintCommonUtil() { EO.Pdf.Runtime.AddLicense(.....REMOVED BY ADMIN....) }
protected String Header(String customerLogoUrlPath, string paceLogoUrlPath) {
String header = @"<html><head></head><body><table style='width:680px;' border='0'><tr><td height='50px'></td></tr><tr><td><img src='" + customerLogoUrlPath + "'width='200px' height='50px'></td><td align='right'><img src='" + paceLogoUrlPath + "'width='150px' height='60px'></td>></tr><tr><td height='20px'></td></tr></table></body></html>"; return header; }
protected String Footer() { String footer = @"<html><head></head><body><table style='width:670px;' border='0'><tr><td><div style='vertical-align:bottom;height:3px; background-color:green;' /></td></tr><tr><td align='center' style='font-family:Arial;font-size:11px;'>Copyright © PACE O.D. Consulting Pte Ltd. All rights reserved.</td></tr><tr><td style='height:20px;'></td></tr></table></body></html>"; return footer; }
protected HtmlToPdfOptions printOptions() { HtmlToPdfOptions ops = new HtmlToPdfOptions(); ops.PageSize = new SizeF(8.27f, 11.69f); ops.OutputArea = new RectangleF(0.5f, 0.5f, 7.27f, 11.69f); ops.MaxLoadWaitTime = 1200000; return ops; } public void generateReport(PrintInfo printInfo) {
try { HtmlToPdfOptions ops = printOptions(); ops.HeaderHtmlFormat = Header(printInfo.CustomerLogoPath, printInfo.PaceLogoPath); ops.FooterHtmlFormat = Footer(); EO.Pdf.HtmlToPdf.Options.AutoFitX = HtmlToPdfAutoFitMode.None; EO.Pdf.HtmlToPdf.Options.AutoFitY = HtmlToPdfAutoFitMode.None; EO.Pdf.HtmlToPdf.ConvertUrl(printInfo.PrintUrl, printInfo.PdfDocument, ops); } catch (Exception ex) {
//throw new Exception(ex.Message, ex); } }
public void generatePDF(PdfDocument pdfDocument) {
try {
//Add page number to each page for (int page = 0; page < pdfDocument.Pages.Count; page++) { //Create an AcmText representing the page number AcmText pageNo = new AcmText((page + 1).ToString()); pageNo.Style.FontName = "Arial"; pageNo.Style.FontSize = 10f; pageNo.Style.ForegroundColor = Color.Black; //Ignore page 0 //if (page > 0) //{ EO.Pdf.Acm.AcmRender render = new EO.Pdf.Acm.AcmRender( pdfDocument.Pages[page], 11.2f, new EO.Pdf.Acm.AcmPageLayout( new EO.Pdf.Acm.AcmPadding(7.6f, 0f, 0f, 0f))); render.Render(pageNo); //} }
string path = AppDomain.CurrentDomain.BaseDirectory; pdfDocument.Save(path + "Text.pdf"); }
catch (Exception ex) { throw new Exception(ex.Message, ex); } }
//end
protected void btnReport_Click(object sender, EventArgs e){
PdfDocument pdfDocument = new PdfDocument(); PrintCommonUtil printCommonUtil = new PrintCommonUtil(); PrintInfo printInfo = new PrintInfo(); printInfo.PdfDocument = pdfDocument;
printInfo.PrintUrl = url + "Report/Summary.aspx?"; printInfo.CustomerLogoPath = url + "atlogo.png"; printInfo.PaceLogoPath = url + "logo.jpg"; printCommonUtil.generateReport(printInfo); printCommonUtil.generatePDF(pdfDocument); }
|
|
Rank: Administration Groups: Administration
Joined: 5/27/2007 Posts: 24,196
|
Please read our original reply carefully and follow our instructions. First you post your questions in multiple unrelated threads. Then when we ask you to check the latest build you ignored our instructions. Next we ask you to isolate the problem into a small test project that runs, you ignored it again and post code that does not run. Not only that, you choose to publicly post your license key in the forum so that everyone can copy and use your license key. If you do this again, we will have no option but to permanently disable your license key.
|
|