Skip to content

Commit

Permalink
Enhance the PDF options to provide the control option to include the
Browse files Browse the repository at this point in the history
CIDSet of a font (#1817)
  • Loading branch information
speckyspooky committed Jul 31, 2024
1 parent 36452dc commit bfe5901
Show file tree
Hide file tree
Showing 3 changed files with 48 additions and 0 deletions.
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() {
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) {
this.includeFontCidSet = includeFontCidSet;
}

/**
* Get the instruction to include CIDSet stream of fonts
*
* @return the CIDSet shall be included
*/
public boolean getPdfIncludeCidSet() {
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

0 comments on commit bfe5901

Please sign in to comment.