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.

Thu Jun 22, 2023 7:29 am

Hi all,
I designed a htm page in letter style where I define right margin size and font sizes.
When I print out the generated html site from the browser, the printed letter looks as designed.
When I convert the html page (with new plugin 9.5.4) to pdf and print it afterwards (original size) the margins shrunk and the font size is smaller as well.

How to make a accurate 'copy' of the html page ?

Please advice.
Kind regards
Dan

BEKB
 
Posts: 23
Joined: Wed Dec 16, 2015 2:36 pm

Thu Jun 22, 2023 9:06 am

Hi Dan,

Thanks for your feedback.
Could you please provide us with your html file or the url? So that we can investigate further and work out solution for you. You can share it with us via email ([email protected]) or attach it here. Thanks for your assistance.

Best regards,
Triste
E-iceblue support team
User avatar

Triste.Dai
 
Posts: 1000
Joined: Tue Nov 15, 2022 3:59 am

Tue Jun 27, 2023 11:03 am

Hi Triste,

Thanks for your reply. I added four sample files.
Questions:

1) Why is the text size in Word (Arial 10) not the same as in html or convertet to pdf (with PdfCreator or SpirePdf) ?
2) Why is the left margin size defined in html not the same when I convert the html with spirePdf to a pdf ?

Kind regards
Dan

BEKB
 
Posts: 23
Joined: Wed Dec 16, 2015 2:36 pm

Wed Jun 28, 2023 3:55 am

Hi Dan,

Thank you for bringing the two issues you encountered while using our product to our attention. We appreciate your feedback and would like to address them accordingly.

Regarding the first issue, upon reviewing the document "ConvertedWithSpireConvert.pdf" provided by you, we have confirmed that the font remains unchanged throughout the document, with all text appearing as Arial 10. See the following screenshot for reference.
convertedWithSpire.png

For the second issue, we would like to inquire whether you utilized the Qt plugin for the conversion. If so, please provide us with the version of the Qt plugin you are using, as well as any relevant test code that you employed. This will assist us in replicating the issue on our end and identifying a resolution promptly.

Thank you for your understanding and continued support.

Best regards,
Triste
E-iceblue support team
User avatar

Triste.Dai
 
Posts: 1000
Joined: Tue Nov 15, 2022 3:59 am

Wed Jun 28, 2023 10:11 am

Hi Triste,

Thanks for your reply.
After doing some more investigation we came to the following finding:

We use the following code to generate the pdf (Version of Qt5Core.dll = 5.14.2.0):
LicenseProvider.SetLicenseFileName($"{rootPath}\\path_to_licensefile\\pdf.license.elic.xml");
LicenseProvider.LoadLicense();
HtmlConverter.PluginPath = $"{rootPath}\\path_to_plugins\\";

var pdfMargins = new PdfMargins(0);
var pdfPageSize = PdfPageSize.A4;
var memoryStream = new MemoryStream();

HtmlConverter.Convert(
url,
memoryStream,
//enable javascript
true,
//load timeout
10 * 1000,
//page size
pdfPageSize,
//page margins
pdfMargins,
//load from content type
LoadHtmlType.URL);

We realized that if we convert the html like above the result is a pdf in format 297mm x 420mm, what is NOT A4 (210mm x 297mm) as specified with PdfPageSize.A4 !? (see attached file ConvertedWithSpireConvertWrongPageSize.zip)

That's why we convert the generated pdf afterward into proper format A4 and most likely this causes the characters on the printout to be smaller as in the printout from word.

Is there a bug in spire.pdf with the PdfPageSize.A4 ?



Thanks for your further support in this matter.
Kind regards
Dan

BEKB
 
Posts: 23
Joined: Wed Dec 16, 2015 2:36 pm

Thu Jun 29, 2023 2:12 am

Hi Dan,

Thanks for your feedback.
After testing, I have reproduced this issue, the page size is not correct. I have logged this issue into our issue tracking system with the ticket number SPIREPDF-6107, our developers will investigate and fix it. Sorry for the inconvenience caused. Once there are any updates available, I will inform you asap.

Best regards,
Triste
E-iceblue support team
User avatar

Triste.Dai
 
Posts: 1000
Joined: Tue Nov 15, 2022 3:59 am

Thu Jul 13, 2023 2:20 am

Hi Dan,

Thanks for your patience.
After investigation, our developers have found that this issue is due to the inclusion of a page setting parameter in your HTML document, as shown in the screenshot below.
html.png

This setting has caused the page size we set in the code to not take effect. You can delete or comment out this setting and convert it again. As a result, the page size of the document will be correct.

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

Best regards,
Triste
E-iceblue support team
User avatar

Triste.Dai
 
Posts: 1000
Joined: Tue Nov 15, 2022 3:59 am

Return to Spire.PDF