From bfe59013c347813d509c4e172f18171644386111 Mon Sep 17 00:00:00 2001 From: Thomas Gutmann Date: Wed, 31 Jul 2024 22:20:51 +0200 Subject: [PATCH 1/2] Enhance the PDF options to provide the control option to include the CIDSet of a font (#1817) --- .../report/engine/emitter/pdf/PDFPage.java | 2 ++ .../engine/emitter/pdf/PDFPageDevice.java | 35 +++++++++++++++++++ .../birt/report/engine/emitter/pdf/README.md | 11 ++++++ 3 files changed, 48 insertions(+) diff --git a/engine/org.eclipse.birt.report.engine.emitter.pdf/src/org/eclipse/birt/report/engine/emitter/pdf/PDFPage.java b/engine/org.eclipse.birt.report.engine.emitter.pdf/src/org/eclipse/birt/report/engine/emitter/pdf/PDFPage.java index e258dbd9ff..8345f04090 100644 --- a/engine/org.eclipse.birt.report.engine.emitter.pdf/src/org/eclipse/birt/report/engine/emitter/pdf/PDFPage.java +++ b/engine/org.eclipse.birt.report.engine.emitter.pdf/src/org/eclipse/birt/report/engine/emitter/pdf/PDFPage.java @@ -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 diff --git a/engine/org.eclipse.birt.report.engine.emitter.pdf/src/org/eclipse/birt/report/engine/emitter/pdf/PDFPageDevice.java b/engine/org.eclipse.birt.report.engine.emitter.pdf/src/org/eclipse/birt/report/engine/emitter/pdf/PDFPageDevice.java index 2aa012158a..10625b1aa9 100644 --- a/engine/org.eclipse.birt.report.engine.emitter.pdf/src/org/eclipse/birt/report/engine/emitter/pdf/PDFPageDevice.java +++ b/engine/org.eclipse.birt.report.engine.emitter.pdf/src/org/eclipse/birt/report/engine/emitter/pdf/PDFPageDevice.java @@ -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 userProperties; private char pdfVersion = '0'; @@ -178,6 +180,8 @@ public class PDFPageDevice implements IPageDevice { private String defaultFontPdfA = null; + private boolean includeFontCidSet = true; + /** * * Constructor to define the PDF @@ -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) { @@ -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; + } } diff --git a/engine/org.eclipse.birt.report.engine.emitter.pdf/src/org/eclipse/birt/report/engine/emitter/pdf/README.md b/engine/org.eclipse.birt.report.engine.emitter.pdf/src/org/eclipse/birt/report/engine/emitter/pdf/README.md index 49b724b06a..fa95b6e44f 100644 --- a/engine/org.eclipse.birt.report.engine.emitter.pdf/src/org/eclipse/birt/report/engine/emitter/pdf/README.md +++ b/engine/org.eclipse.birt.report.engine.emitter.pdf/src/org/eclipse/birt/report/engine/emitter/pdf/README.md @@ -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, From 369635fe031524ef7d2c2ff6735e0a68bcef7866 Mon Sep 17 00:00:00 2001 From: Thomas Gutmann Date: Thu, 1 Aug 2024 20:10:15 +0200 Subject: [PATCH 2/2] Renaming of method names --- .../eclipse/birt/report/engine/emitter/pdf/PDFPage.java | 2 +- .../birt/report/engine/emitter/pdf/PDFPageDevice.java | 8 ++++---- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/engine/org.eclipse.birt.report.engine.emitter.pdf/src/org/eclipse/birt/report/engine/emitter/pdf/PDFPage.java b/engine/org.eclipse.birt.report.engine.emitter.pdf/src/org/eclipse/birt/report/engine/emitter/pdf/PDFPage.java index 8345f04090..085252eedd 100644 --- a/engine/org.eclipse.birt.report.engine.emitter.pdf/src/org/eclipse/birt/report/engine/emitter/pdf/PDFPage.java +++ b/engine/org.eclipse.birt.report.engine.emitter.pdf/src/org/eclipse/birt/report/engine/emitter/pdf/PDFPage.java @@ -462,7 +462,7 @@ private void drawText(String text, float textX, float textY, FontInfo fontInfo, contentByte.setColorStroke(color); } BaseFont font = getBaseFont(fontInfo); - font.setIncludeCidSet(this.pageDevice.getPdfIncludeCidSet()); + font.setIncludeCidSet(this.pageDevice.isIncludeCidSet()); float fontSize = fontInfo.getFontSize(); try { diff --git a/engine/org.eclipse.birt.report.engine.emitter.pdf/src/org/eclipse/birt/report/engine/emitter/pdf/PDFPageDevice.java b/engine/org.eclipse.birt.report.engine.emitter.pdf/src/org/eclipse/birt/report/engine/emitter/pdf/PDFPageDevice.java index 10625b1aa9..0379e7ae6c 100644 --- a/engine/org.eclipse.birt.report.engine.emitter.pdf/src/org/eclipse/birt/report/engine/emitter/pdf/PDFPageDevice.java +++ b/engine/org.eclipse.birt.report.engine.emitter.pdf/src/org/eclipse/birt/report/engine/emitter/pdf/PDFPageDevice.java @@ -212,7 +212,7 @@ public PDFPageDevice(OutputStream output, String title, String author, String su // PDF/A, set the default font of not embeddable fonts this.setDefaultFontPdfA(); // PDF include font CID set stream - this.setPdfIncludeCidSet(); + this.setIncludeCidSet(); // PDF/A (A1A, A1B), avoid compression and transparency if (!this.isPdfAFormat) { @@ -879,7 +879,7 @@ public String getDefaultFontPdfA() { * CIDSet stream will be included in the document. When set to false, no CIDSet * stream will be included. */ - private void setPdfIncludeCidSet() { + private void setIncludeCidSet() { 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()); @@ -890,7 +890,7 @@ private void setPdfIncludeCidSet() { * * @param includeFontCidSet include CIDSet stream of a font to the document */ - public void setPdfIncludeCidSet(Boolean includeFontCidSet) { + public void setIncludeCidSet(boolean includeFontCidSet) { this.includeFontCidSet = includeFontCidSet; } @@ -899,7 +899,7 @@ public void setPdfIncludeCidSet(Boolean includeFontCidSet) { * * @return the CIDSet shall be included */ - public boolean getPdfIncludeCidSet() { + public boolean isIncludeCidSet() { return this.includeFontCidSet; } }