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 Mar 26, 2026 5:52 pm

Hi everyone,

I'm working on a project where I need to generate a PDF starting from different HTML fragments (specifically, tables containing medical data for AIRVO devices).

Currently, I'm trying to use this approach:

Code: Select all
String html = "<div style="width:100%; overflow-x:auto; font-family:Arial, sans-serif;">" +
"<h3>Approximate Oxygen Concentrations for AIRVO 1</h3>" +
"<table style="width:100%; border-collapse:collapse; text-align:center;">" +
// ... table rows and data ...
"</table></div>" +
"<div style="margin-top:30px;">" +
"<h3>Approximate Oxygen Concentrations for MyAIRVO2</h3>" +
"<table>" +
// ... more table rows ...
"</table></div>";

converter.convertToPdf(html, "output.pdf", null);


The Issues:

Errors with Fragments: I'm receiving errors during conversion, likely because the engine expects a full HTML document (with <html> and <body> tags) rather than raw fragments.

Appending Issues: I need to perform some text replacements (placeholders) and then append 2 or 3 different HTML fragments one after another in the same PDF.

QT Limitations: I tried using QT, but it's proving difficult because:

It seems to require the creation of a temporary .pdf file.

The HtmlConverter.convert method requires a specific Size parameter, but I don't know the final height of the content before the conversion.

Fragments are not appending correctly in sequence.

My Goal:
I want to achieve this without using Chrome/Headless browsers. I need a way to:

Perform text replacement on the fly.

Concatenate multiple HTML fragments into a single, continuous PDF.

Avoid manual size calculations (the tool should handle the flow based on a standard page size like A4).


Thanks!

jadinard
 
Posts: 13
Joined: Wed Aug 13, 2025 2:25 pm

Fri Mar 27, 2026 2:55 am

Hello,

Thanks for your inquiry.
Please be advised that the two methods you mentioned rely on third-party plugins, Chrome/QT, which currently only support the conversion of complete HTML files. For your needs, it may be possible to achieve this using our Spire.Doc, which provides the appendHTML method to append HTML fragments to a Word document and can generate PDF format. Please refer to this tutorial(Convert an HTML String to PDF in Java) for testing. If you have any questions, feel free to write back.

Sincerely,
William
E-iceblue support team
User avatar

William.Zhang
 
Posts: 764
Joined: Mon Dec 27, 2021 2:23 am

Mon Mar 30, 2026 7:32 am

Do i need another license to use Spire.doc?
This is kinda a limitation.

jadinard
 
Posts: 13
Joined: Wed Aug 13, 2025 2:25 pm

Mon Mar 30, 2026 7:49 am

Hello,

Thanks for your reply.
Yes, you need to apply for a Spire.Doc license. We can provide you with a one-month free temporary license for better evaluation. If you need it, please reply to let us know.

Sincerely,
William
E-iceblue support team
User avatar

William.Zhang
 
Posts: 764
Joined: Mon Dec 27, 2021 2:23 am

Return to Spire.PDF

cron