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 Nov 29, 2023 8:41 pm

Spire.pdf.dll v6.8.5.2330

Qt5Core.dll v5.9.8.0

The Html to pdf works fine except when we include an image in the html file.

Attached are
c# code
image file
html file
output pdf file.

[email protected]
 
Posts: 110
Joined: Tue May 19, 2015 8:09 pm

Thu Nov 30, 2023 6:48 am

Hi,

Thank you for your inquiry.
I have tested the html file you provided and reproduced your issue. I have recorded this issue in our bug tracking system with the number "SPIREPDF-6425". Our development team will investigate and fix it in the future. If this issue is resolved, we will notify you as soon as possible. We deeply apologize for any inconvenience caused.
In addition, we provide another way that doesn't have this issue to convert html to pdf without QT plugins. I put the complete code below for your reference:
Code: Select all
            // Create a new PdfDocument object
            PdfDocument doc = new PdfDocument();

            // Create a new PdfPageSettings object
            PdfPageSettings setting = new PdfPageSettings();

            // Set the size of the page to 1000x1000
            setting.Size = new SizeF(1000, 1000);

            // Set the margins of the page to 20 units
            setting.Margins = new Spire.Pdf.Graphics.PdfMargins(20);

            // Create a new PdfHtmlLayoutFormat object
            PdfHtmlLayoutFormat htmlLayoutFormat = new PdfHtmlLayoutFormat();

            // Set the IsWaiting property of the layout format to true
            htmlLayoutFormat.IsWaiting = true;

            // Read the HTML content from a file and store it in a string variable
            string htmlString = File.ReadAllText(@"..\TBR.HTML");

            // Create a new thread and start it
            Thread thread = new Thread(() =>
            {
                // Load the HTML content into the PdfDocument object
                doc.LoadFromHTML(htmlString, true, setting, htmlLayoutFormat);
            });
            thread.SetApartmentState(ApartmentState.STA);
            thread.Start();
            thread.Join();

            // Save the PdfDocument object to a file
            doc.SaveToFile(@"..\result2.pdf");

If you have any issue, just feel free to contact us.

Sincerely,
Ula
E-iceblue support team
User avatar

Ula.wang
 
Posts: 282
Joined: Mon Aug 07, 2023 1:38 am

Thu Nov 30, 2023 5:46 pm

Thank you for the code.
We tried that code yesterday but it will not compile.

PdfHtmlLayoutFormat htmlLayoutFormat = new PdfHtmlLayoutFormat();

PdfHtmlLayoutFormat is not seen, even though we have the using statement for it.

https://www.e-iceblue.com/api_documents ... 32a837.htm

This shows PdfHtmlLayoutFormat is in the Spire.Pdf.HtmlConverter namespace.

i have attached the simple console project where I am getting the error.

[email protected]
 
Posts: 110
Joined: Tue May 19, 2015 8:09 pm

Fri Dec 01, 2023 2:46 am

Hi,

Thank you for your feedback.
Sorry, due to internal adjustments in our product, the PdfHtmlLayoutFormat and LoadFromHTML methods are available on the .NET Framework platform, while they are not provided on the .NET Core platform. If the issue numbered "SPIREPDF-6425" is resolved, we will notify you as soon as possible. We deeply apologize for any inconvenience caused.

Sincerely,
Ula
E-iceblue support team
User avatar

Ula.wang
 
Posts: 282
Joined: Mon Aug 07, 2023 1:38 am

Wed Dec 13, 2023 9:18 am

Hi,

Thank you for your patience.
Regarding the issue with the number SPIREPDF-6425, please place the signature image and html file in the same directory, and set the image path to a relative path.
Code: Select all
<img src=". \ barbSignature. png"/>

Then I put the complete code below for your reference.
Code: Select all
// Specify the URL address
string url = @"..\ConvertToPDF\TBR.HTML";

// Specify the output file path
string fileName = @"..\Url转Pdf11.pdf";

// Specify the plugin path
string pluginPath = @"..\\plugins-windows-x64\\plugins";

// Set the plugin path
HtmlConverter.PluginPath = pluginPath;

// Convert the URL to PDF
HtmlConverter.Convert(url, fileName, true, 100000, new Size(1080, 1000), new PdfMargins(0));

If you have any issue, just feel free to contact us.

Sincerely,
Ula
E-iceblue support team
User avatar

Ula.wang
 
Posts: 282
Joined: Mon Aug 07, 2023 1:38 am

Return to Spire.PDF