Merge pull request #721 from mr-mister123/feature_fix_incomplete_CIDsets
remove CIDSets from XObjects
This commit is contained in:
@@ -58,6 +58,7 @@ import org.apache.pdfbox.pdmodel.font.PDCIDFontType2;
|
|||||||
import org.apache.pdfbox.pdmodel.font.PDFont;
|
import org.apache.pdfbox.pdmodel.font.PDFont;
|
||||||
import org.apache.pdfbox.pdmodel.font.PDFontDescriptor;
|
import org.apache.pdfbox.pdmodel.font.PDFontDescriptor;
|
||||||
import org.apache.pdfbox.pdmodel.font.PDType0Font;
|
import org.apache.pdfbox.pdmodel.font.PDType0Font;
|
||||||
|
import org.apache.pdfbox.pdmodel.graphics.PDXObject;
|
||||||
import org.apache.pdfbox.pdmodel.graphics.color.PDOutputIntent;
|
import org.apache.pdfbox.pdmodel.graphics.color.PDOutputIntent;
|
||||||
import org.apache.xmpbox.XMPMetadata;
|
import org.apache.xmpbox.XMPMetadata;
|
||||||
import org.apache.xmpbox.schema.AdobePDFSchema;
|
import org.apache.xmpbox.schema.AdobePDFSchema;
|
||||||
@@ -559,6 +560,7 @@ public class ZUGFeRDExporterFromA3 extends XRExporter implements IZUGFeRDExporte
|
|||||||
// https://github.com/ZUGFeRD/mustangproject/issues/249
|
// https://github.com/ZUGFeRD/mustangproject/issues/249
|
||||||
|
|
||||||
COSName cidSet = COSName.getPDFName("CIDSet");
|
COSName cidSet = COSName.getPDFName("CIDSet");
|
||||||
|
COSName resources = COSName.getPDFName("Resources");
|
||||||
|
|
||||||
// iterate over all pdf pages
|
// iterate over all pdf pages
|
||||||
|
|
||||||
@@ -567,6 +569,24 @@ public class ZUGFeRDExporterFromA3 extends XRExporter implements IZUGFeRDExporte
|
|||||||
|
|
||||||
PDPage page = (PDPage) object;
|
PDPage page = (PDPage) object;
|
||||||
PDResources res = page.getResources();
|
PDResources res = page.getResources();
|
||||||
|
|
||||||
|
// Check for fonts in PDXObjects:
|
||||||
|
for (COSName xObjectName : res.getXObjectNames()) {
|
||||||
|
PDXObject xObject = res.getXObject(xObjectName);
|
||||||
|
COSDictionary d = xObject.getCOSObject().getCOSDictionary(resources);
|
||||||
|
if (d != null) {
|
||||||
|
PDResources xr = new PDResources(d);
|
||||||
|
removeCIDSetFromPDResources(cidSet, xr);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Check for fonts in document-resources:
|
||||||
|
removeCIDSetFromPDResources(cidSet, res);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void removeCIDSetFromPDResources(COSName cidSet, PDResources res) throws IOException {
|
||||||
for (COSName fontName : res.getFontNames()) {
|
for (COSName fontName : res.getFontNames()) {
|
||||||
try {
|
try {
|
||||||
PDFont pdFont = res.getFont(fontName);
|
PDFont pdFont = res.getFont(fontName);
|
||||||
@@ -587,8 +607,6 @@ public class ZUGFeRDExporterFromA3 extends XRExporter implements IZUGFeRDExporte
|
|||||||
// do stuff with the font
|
// do stuff with the font
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
protected void prepareDocument() throws IOException {
|
protected void prepareDocument() throws IOException {
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user