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

Enhance the PDF options to provide the control option to include the CIDSet of a font (#1817) #1823

Merged
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -462,6 +462,8 @@ private void drawText(String text, float textX, float textY, FontInfo fontInfo,
contentByte.setColorStroke(color);
}
BaseFont font = getBaseFont(fontInfo);
font.setIncludeCidSet(this.pageDevice.getPdfIncludeCidSet());

float fontSize = fontInfo.getFontSize();
try {
// PDF/A: if font not embeddable then use the configured PDF/A fallback font
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -166,6 +166,8 @@ public class PDFPageDevice implements IPageDevice {

private final static String PDFA_FALLBACK_FONT = "PdfEmitter.PDFA.FallbackFont";

private final static String PDF_FONT_CID_SET = "PdfEmitter.IncludeCidSet";

protected Map<String, Expression> userProperties;

private char pdfVersion = '0';
Expand All @@ -178,6 +180,8 @@ public class PDFPageDevice implements IPageDevice {

private String defaultFontPdfA = null;

private boolean includeFontCidSet = true;

/**
*
* Constructor to define the PDF
Expand Down Expand Up @@ -207,6 +211,8 @@ public PDFPageDevice(OutputStream output, String title, String author, String su
this.setPdfConformance();
// PDF/A, set the default font of not embeddable fonts
this.setDefaultFontPdfA();
// PDF include font CID set stream
this.setPdfIncludeCidSet();

// PDF/A (A1A, A1B), avoid compression and transparency
if (!this.isPdfAFormat) {
Expand Down Expand Up @@ -867,4 +873,33 @@ public void setDefaultFontPdfA(String defaultFont) {
public String getDefaultFontPdfA() {
return this.defaultFontPdfA;
}

/**
* Set the including of a font CIDSet stream the document. When set to true, a
* CIDSet stream will be included in the document. When set to false, no CIDSet
* stream will be included.
*/
private void setPdfIncludeCidSet() {
speckyspooky marked this conversation as resolved.
Show resolved Hide resolved
if (this.userProperties != null && this.userProperties.containsKey(PDFPageDevice.PDF_FONT_CID_SET))
this.includeFontCidSet = Boolean
.parseBoolean(this.userProperties.get(PDFPageDevice.PDF_FONT_CID_SET).toString());
}

/**
* Set the including of a font CIDSet stream the document
*
* @param includeFontCidSet include CIDSet stream of a font to the document
*/
public void setPdfIncludeCidSet(Boolean includeFontCidSet) {
speckyspooky marked this conversation as resolved.
Show resolved Hide resolved
this.includeFontCidSet = includeFontCidSet;
}

/**
* Get the instruction to include CIDSet stream of fonts
*
* @return the CIDSet shall be included
*/
public boolean getPdfIncludeCidSet() {
speckyspooky marked this conversation as resolved.
Show resolved Hide resolved
return this.includeFontCidSet;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,17 @@ The following list get an overview of all supported user properties, the content
Values file name with full path or list of file names
Default empty (null)


**PdfEmitter.IncludeCidSet**

Content include the CIDSet stream of a font into the document
Location report
Data type boolean
Values true, CIDSet will be included
false, CIDSet won't be included
Default true
Since 4.17

**PdfEmitter.PDFA.FallbackFont**

Content fall back font to create the pdf/a document correctly,
Expand Down
Loading