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!