Unable to convert (Html File with external css) to pdf

Hi All,


I am unable to convert html file(with external css) to pdf

Below I am attaching sample file which i am trying to convert.

Hi Srini,

Thanks for contacting support. I have tested the scenario using Aspose.Pdf for .NET 9.5.0 where I have used the following code snippet and I am unable to notice any issue. The PDF file is properly converted.

C#

// Load the HTML file
Document doc = new Document(
  @"C:\pdftest\htmlsample(1)\sample\5340117181.html",
  new HtmlLoadOptions()
);
doc.Save(@"C:\pdftest\htmlsample(1)\sample\5340117181.pdf");

Hello,


Thanks for the reply

I have tried with above source code which u mentioned, its converting all the pages of HTML content into single page of PDF file.

Please kindly help me out, is it required to set any property/method of Document before going to save?

Thanks
Hello,
I forgot to attach my HTML file along with reference files.
Please find the attachment which I am trying to convert from HTML to PDF.

Thanks

Hi Srini,

Thanks for your feedback. Please check a sample code snippet to convert HTML to PDF using external source files. As described in HTML to PDF conversion documentation link, you need to define base path to refer your external resources. Then complete path for external source will be comprise basepath+path in html tag. Hopefully it will help you to accomplish the task.

// Specify the The base path/url for
the html file which serves as images/css database

String basePath = `"E:/temp/"`;

HtmlLoadOptions htmloptions = new HtmlLoadOptions(basePath);

// load HTML file
Document doc = new Document("E:/temp/PDFtoHTML.html", htmloptions);
// Save HTML file
doc.Save("E:/temp/HTMLtoPDF.pdf")

Please feel free to contact us for any further assistance.

Best Regards,

Hello,

Thanks for the information.
The above conversion code (HTML to PDF) is not responding with my source file. it has 11 pages of pdf document.

Could you please find the attachment of my source pdf file and try to convert from PDF to HTML(its working fine- we have test on browser) then convert HTML to PDF(this is the problem we are facing currently) ?

Please kindly review my below source code and let me know if i am doing wrong.

1) PDF to HTML
            Document pdfDocument = new Document(Server.MapPath(@"/CCDS.pdf"));
string outHtmlFile = Server.MapPath("/HTML/SourcePdfHtml.html");
        <span style="color:green;">// Create HtmlSaveOption with tested feature</span>
        <span style="color:#2b91af;">HtmlSaveOptions</span> saveOptions = <span style="color:blue;">new</span> <span style="color:#2b91af;">HtmlSaveOptions</span>();
        saveOptions.FixedLayout = <span style="color:blue;">true</span>;
        saveOptions.RasterImagesSavingMode = <span style="color:#2b91af;">HtmlSaveOptions</span>.<span style="color:#2b91af;">RasterImagesSavingModes</span>.AsEmbeddedPartsOfPngPageBackground;

        pdfDocument.Save(outHtmlFile, saveOptions);</pre></div><div><br></div><div>2)HTML to PDF</div><div><br></div><div>                   <span style="font-family: Consolas; font-size: 13px; color: rgb(43, 145, 175);">String</span><span style="font-family: Consolas; font-size: 13px; background-color: white;"> basePath = Server.MapPath(</span><span style="font-family: Consolas; font-size: 13px; color: rgb(163, 21, 21);">"HTML"</span><span style="font-family: Consolas; font-size: 13px; background-color: white;">);</span></div><pre style="font-family: Consolas; font-size: 13px; background: white;">            <span style="color:#2b91af;">HtmlLoadOptions</span> htmloptions = <span style="color:blue;">new</span> <span style="color:#2b91af;">HtmlLoadOptions</span>(basePath);
        <span style="color:green;">// use the new conversion engine</span>
        htmloptions.UseNewConversionEngine = <span style="color:blue;">true</span>;
        <span style="color:green;">// load HTML file</span>
        <span style="color:#2b91af;">Document</span> doc = <span style="color:blue;">new</span> <span style="color:#2b91af;">Document</span>(basePath + <span style="color:#a31515;">@"\SourcePdfHtml.html"</span>, htmloptions);
        <span style="color:green;">// Save HTML file</span>
        doc.Save(basePath + <span style="color:#a31515;">@"\output.pdf"</span>);</pre><div><br></div><div>Thanks,</div><div><br></div><div><br></div><div><br></div><div><br></div><div><br></div>

Its very urgent for me to release.

Any update please??

Hi Srini,


We are sorry for the inconvenience. I have tested the scenario with your source PDF file and noticed that all pages are being overwritten on first page. We have logged a ticket PDFNEWNET-37465 for further investigation and resolution. We will notify you as soon as it is resolved.

Best Regards,

Any update plz?

Hi Srini,


Thanks for your inquiry. Our development team has completed the investigation and now working over the fix. We have requested our development team share an ETA. We will update you as soon as we get a feedback.

Thanks for your patience and cooperation.

Best Regards,

Hello,

Is it fixed? Please share the ETA or else we will go with alternative solution.

Thanks,

Hi Srini,


Thanks for your inquiry. Our development team has planned the fix of above reported issue in Aspose.Pdf for .NET 10.3.0. Hopefully it will be published in April,2015. However, we have recorded your concern and requested the development team to provide solution as earliest as possible. We will keep you updated about the issue resolution progress via this forum thread.

Thanks for your patience and cooperation.

Best Regards,

Hi Srini,


Thanks for your patience.

We are pleased to share that the issue reported earlier is resolved in latest release of Aspose.Pdf for .NET 10.2.0. Please try using the latest release and in case you encounter any issue, please feel free to contact.

The issues you have found earlier (filed as PDFNEWNET-37465) have been fixed in Aspose.Pdf for .NET 10.3.0.


This message was posted using Notification2Forum from Downloads module by Aspose Notifier.