Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Generate PDF from multiple HTML #915

Open
varshaldavda opened this issue Mar 3, 2023 · 1 comment
Open

Generate PDF from multiple HTML #915

varshaldavda opened this issue Mar 3, 2023 · 1 comment

Comments

@varshaldavda
Copy link

I am using this library to generate PDF from multiple HTML files. I can do so but it starts new PDF on a new page instead of existing page. Can anyone help me?

Attaching my code here :

PDDocument doc = new PDDocument();
		File file = File.createTempFile("temp_openhtmltopdf_", ".pdf");
		PdfRendererBuilder builder = new PdfRendererBuilder();
		builder.useDefaultPageSize(210, 297, PageSizeUnits.MM);
		builder.useSVGDrawer(new BatikSVGDrawer());
		builder.usePDDocument(doc);
		for (String html : uris) {
			builder.withHtmlContent(html, "UTF-8");
			PdfBoxRenderer renderer = builder.buildPdfRenderer();
			renderer.createPDFWithoutClosing();
		}
		doc.save(file);
		doc.close();

It generates 2 page PDF. I want to start the 2nd page from the ending of the 1st page.

@stechio
Copy link

stechio commented Mar 20, 2023

Concatenating multiple renderings at their respective bottom positions is doable yet not so straightforward; you have to combine the solutions discussed here:

At the moment, concatenating multiple renderings may also produce some undesirable effect, such as font resource duplication (see #683).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants