diff --git a/openhtmltopdf-pdfbox/src/main/java/com/openhtmltopdf/pdfboxout/PdfBoxRenderer.java b/openhtmltopdf-pdfbox/src/main/java/com/openhtmltopdf/pdfboxout/PdfBoxRenderer.java index c09d54933..faf3a90b7 100644 --- a/openhtmltopdf-pdfbox/src/main/java/com/openhtmltopdf/pdfboxout/PdfBoxRenderer.java +++ b/openhtmltopdf-pdfbox/src/main/java/com/openhtmltopdf/pdfboxout/PdfBoxRenderer.java @@ -873,23 +873,25 @@ private XMPSchema createPdfaProperty(String category, String description, String // Sets the document information dictionary values from html metadata private void setDidValues(PDDocument doc) { - PDDocumentInformation info = new PDDocumentInformation(); - - info.setCreationDate(Calendar.getInstance()); + if(doc.getDocumentInformation() == null) { + doc.setDocumentInformation(new PDDocumentInformation()); + } + final PDDocumentInformation info = doc.getDocumentInformation(); - if (_producer == null) { - info.setProducer("openhtmltopdf.com"); - } else { - info.setProducer(_producer); + if(info.getCreationDate() == null) { + info.setCreationDate(Calendar.getInstance()); + } + if(info.getProducer() == null) { + info.setProducer(_producer == null ? "openhtmltopdf.com": _producer); } for (Metadata metadata : _outputDevice.getMetadata()) { - String name = metadata.getName(); - if (name.isEmpty()) - continue; - String content = metadata.getContent(); - if( content == null ) - continue; + String name = metadata.getName(); + if (name.isEmpty()) + continue; + String content = metadata.getContent(); + if( content == null ) + continue; if( name.equals("title")) info.setTitle(content); else if( name.equals("author")) @@ -901,8 +903,6 @@ else if(name.equals("keywords")) else info.setCustomMetadataValue(name,content); } - - doc.setDocumentInformation(info); } private void paintPageFast(RenderingContext c, PageBox page, DisplayListPageContainer pageOperations, int additionalTranslateX) {