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

made it possible to post-process the generated pdf #159

Closed

Conversation

schmitch
Copy link
Contributor

currently we add various xmp metadata / color profile
to the document. so it's really useful to get the pddocument.

currently we add various xmp metadata / color profile
to the document. so it's really useful to get the pddocument.
Copy link
Contributor

@rototor rototor left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This looks fine to me

danfickle added a commit that referenced this pull request Dec 16, 2017
- Remove deprecated methods.
- Make sure the PDDocument is closed in a finally block.
- Make an explicit method createPDFWithoutClosing for those who need to
post-process.
- Implement Closeable interface so that it can be used with try with
resources.
- Mark unused and untested methods as deprecated.

Thanks @rototor @dtrucken @schmitch
@danfickle
Copy link
Owner

Thanks @schmitch

I have implemented an explicit createPDFWithoutClosing method while refactoring PdfBoxRenderer. Usage is something like below:

	public static void main(String... args) throws Exception {
		OutputStream os = new FileOutputStream("/Users/you/Documents/pdftests/mytest-159.pdf");
		PdfRendererBuilder builder = new PdfRendererBuilder();
		builder.withUri("file:///Users/you/Documents/pdftests/issue-159.htm");
		PDDocument doc = null;
		try (PdfBoxRenderer renderer = builder.buildPdfRenderer()) {
			renderer.createPDFWithoutClosing();
			
			doc = renderer.getPdfDocument();
			
			// ... post process doc.
			

		} finally {
			doc.save(os);
			doc.close();
			os.close();
		}
	}

@danfickle danfickle closed this Dec 16, 2017
@schmitch schmitch deleted the post-process-possibility branch December 16, 2017 08:57
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

Successfully merging this pull request may close these issues.

3 participants