Skip to content

Commit

Permalink
Merge pull request #158 from envisia/set-producer
Browse files Browse the repository at this point in the history
make it possible to set a producer
  • Loading branch information
danfickle authored Dec 16, 2017
2 parents 90f9332 + 567f5ed commit 688b846
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,8 @@ public class PdfBoxRenderer implements Closeable {

private PDEncryption _pdfEncryption;

private String _producer;

// Usually 1.7
private float _pdfVersion;

Expand All @@ -106,11 +108,14 @@ public class PdfBoxRenderer implements Closeable {
HttpStreamFactory httpStreamFactory,
OutputStream os, FSUriResolver resolver, FSCache cache, SVGDrawer svgImpl,
PageDimensions pageSize, float pdfVersion, String replacementText, boolean testMode,
FSObjectDrawerFactory objectDrawerFactory, String preferredTransformerFactoryImplementationClass) {
FSObjectDrawerFactory objectDrawerFactory, String preferredTransformerFactoryImplementationClass,
String producer) {

_pdfDoc = new PDDocument();
_pdfDoc.setVersion(pdfVersion);

_producer = producer;

_svgImpl = svgImpl;
_dotsPerPoint = DEFAULT_DOTS_PER_POINT;
_testMode = testMode;
Expand Down Expand Up @@ -517,7 +522,12 @@ private void setDidValues(PDDocument doc) {
PDDocumentInformation info = new PDDocumentInformation();

info.setCreationDate(Calendar.getInstance());
info.setProducer("openhtmltopdf.com");

if (_producer == null) {
info.setProducer("openhtmltopdf.com");
} else {
info.setProducer(_producer);
}

for (Metadata metadata : _outputDevice.getMetadata()) {
String name = metadata.getName();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ public static enum FontStyle { NORMAL, ITALIC, OBLIQUE }
private boolean _isPageSizeInches;
private float _pdfVersion = 1.7f;
private String _replacementText;
private String _producer;
private FSTextBreaker _lineBreaker;
private FSTextBreaker _charBreaker;
private FSTextTransformer _unicodeToUpperTransformer;
Expand Down Expand Up @@ -107,7 +108,8 @@ public PdfBoxRenderer buildPdfRenderer() {
PdfBoxRenderer renderer = new PdfBoxRenderer(
doc, unicode, _httpStreamFactory, _os, _resolver,
_cache, _svgImpl, pageSize, _pdfVersion, _replacementText,
_testMode, _objectDrawerFactory, _preferredTransformerFactoryImplementationClass);
_testMode, _objectDrawerFactory, _preferredTransformerFactoryImplementationClass,
_producer);

/*
* Register all Fonts
Expand Down Expand Up @@ -449,4 +451,16 @@ public PdfRendererBuilder useTransformerFactoryImplementationClass(String transf
this._preferredTransformerFactoryImplementationClass = transformerFactoryClass;
return this;
}

/**
* Set a producer on the output document
*
* @param producer the name of the producer to set defaults to openhtmltopdf.com
* @return this for method chaining
*/
public PdfRendererBuilder withProducer(String producer) {
this._producer = producer;
return this;
}

}

0 comments on commit 688b846

Please sign in to comment.