Spire.PDF is a professional PDF library applied to creating, writing, editing, handling and reading PDF files without any external dependencies. Get free and professional technical support for Spire.PDF for .NET, Java, Android, C++, Python.

Wed Apr 26, 2023 10:41 pm

I am trying to load few comments and attachments from Jira into an html and then convert the html to PDF using Spire PDF in C# .net. ( Spire PDF Version - 8.6.0 )

I create a html - add comments into it and then embed the attachments ( like png / docx etc ) into the html.
Once I have the html ( which is a string ) I use this code to generate PDF document,

PdfDocument docPdfGen = new PdfDocument();
PdfPageSettings setting = new PdfPageSettings();

setting.Size = new SizeF(1000, 1000);
setting.Margins = new Spire.Pdf.Graphics.PdfMargins(20);

PdfHtmlLayoutFormat htmlLayoutFormat = new PdfHtmlLayoutFormat();
htmlLayoutFormat.IsWaiting = true;

Thread thread = new Thread(() =>
{ docPdfGen.LoadFromHTML(html, true, setting, htmlLayoutFormat); });
thread.SetApartmentState(ApartmentState.STA);
thread.Start();
thread.Join();

docPdfGen.SaveToFile("TestFinal.pdf");
docPdfGen.Close();

If I use this code, my final pdf does not embed attachments ( in this case png and docx files ) , however my html embeds those attachments and I can click those and open those from HTML.

When I use this - to enable hyperlinks - { docPdfGen.LoadFromHTML(html, false,true, true, setting, htmlLayoutFormat); }); It gives me this error - value does not fall within the expected range ( when LoadHTML call is called)

I need my attachments embeded in final PDF documents and need to open those from the pdf document . how do I achieve that?

shrutig3
 
Posts: 1
Joined: Wed Apr 26, 2023 10:29 pm

Thu Apr 27, 2023 6:05 am

Hi,

Thanks for your feedback.
I simulated a HTML file and tested your code, but I did not reproduce your problem. As for your situation, we first recommend that you use the QT method(C#/VB.NET: Convert HTML to PDF) to do the conversion. If the issue still occurs after testing this way. To help us have a further investigation, please provide your input HTML for reference, you can upload it here or provide it to us by email ([email protected]), thank you advance.

Best Regards,
Herman
E-iceblue support team
User avatar

Herman.Yan
 
Posts: 115
Joined: Wed Mar 08, 2023 2:00 am

Return to Spire.PDF

cron