Q: I am facing problem while converting report from html to pdf, details are below:
- While I am using your method HTML2PDF.Convert(doc, URL) for
url : https://stagin??? ?user=PMGR%
the Convert method returning false means some warning/error has been encountered, I couldn’t Identify, why it happening while I am trying same conversion with “Winnovative software" 's library, it seems to be working, but its quality is not so much good compare to yours due to that want to purchase your product, Please guide me where I am doing Mistake, code are below
lReportName = ReportName.Substring(0, ReportName.IndexOf(’&’)) + “_Pdftron.pdf”;
outFile = Path.Combine(Application.StartupPath, lReportName);
string pdfError = “”;
try
{
PDFNet.Initialize();
HTML2PDF.SetModulePath(Application.StartupPath);
using (PDFDoc doc = new PDFDoc())
{
// now convert a web page, sending generated PDF pages to doc
//if ( HTML2PDF.Convert(doc, host + page0) )
if (HTML2PDF.Convert(doc, URL))
doc.Save(outFile, SDFDoc.SaveOptions.e_linearized);
}
}
catch (Exception ex)
{
}
Its Working fine while I am setting Url to www.google.com etc , but its not solving my purpose.
A:
The code seems to be correct. However, I’m unable to test this properly as I get a blank page in my browser. Try the following suggestions.
-
Call HTML2PDF.WebPageSettings.SetAllowPlugins(true)
-
Try HTML2PDF.WebPageSettings.SetJavaScriptDelay(ms) // this will give the page time to load
Finally, if the above doesn’t help, try switching to the following code
using (PDFDoc doc = new PDFDoc()) {
// now convert a web page, sending generated PDF pages to doc
//if ( HTML2PDF.Convert(doc, host + page0) )
HTML2PDF converter = new HTML2PDF();
converter.InsertFromURL(URL);
if (converter.convert(doc))
doc.Save(outFile, SDFDoc.SaveOptions.e_linearized);
else
Console.WriteLine(converter.GetLog());
}
And send us the output from GetLog().