From ee90b4f0118d0ad76edf6995267ac900d4ecf2b6 Mon Sep 17 00:00:00 2001 From: Andreas Fitzek Date: Tue, 8 Jul 2014 18:08:26 +0200 Subject: Keep Font Dictionary in Resources original during positioning --- .../at/knowcenter/wag/egov/egiz/pdf/PDFPage.java | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) (limited to 'pdf-as-lib/src/main/java/at/knowcenter') diff --git a/pdf-as-lib/src/main/java/at/knowcenter/wag/egov/egiz/pdf/PDFPage.java b/pdf-as-lib/src/main/java/at/knowcenter/wag/egov/egiz/pdf/PDFPage.java index 4ce8daa9..6911c698 100644 --- a/pdf-as-lib/src/main/java/at/knowcenter/wag/egov/egiz/pdf/PDFPage.java +++ b/pdf-as-lib/src/main/java/at/knowcenter/wag/egov/egiz/pdf/PDFPage.java @@ -56,12 +56,14 @@ import java.util.Map; import org.apache.commons.lang3.math.NumberUtils; import org.apache.pdfbox.cos.COSBase; +import org.apache.pdfbox.cos.COSDictionary; import org.apache.pdfbox.cos.COSName; import org.apache.pdfbox.cos.COSStream; import org.apache.pdfbox.pdmodel.PDPage; import org.apache.pdfbox.pdmodel.PDResources; import org.apache.pdfbox.pdmodel.common.PDRectangle; import org.apache.pdfbox.pdmodel.common.PDStream; +import org.apache.pdfbox.pdmodel.font.PDFont; import org.apache.pdfbox.pdmodel.graphics.xobject.PDXObject; import org.apache.pdfbox.pdmodel.graphics.xobject.PDXObjectForm; import org.apache.pdfbox.pdmodel.interactive.annotation.PDAnnotation; @@ -359,6 +361,25 @@ public class PDFPage extends PDFTextStripper { maxPathRelatedYPositionFromTop); } + @Override + public Map getFonts() { + + COSBase fontObj = null; + + if(getCurrentPage().getResources() != null && + getCurrentPage().getResources().getCOSDictionary() != null && + getCurrentPage().getResources().getCOSDictionary().getDictionaryObject(COSName.FONT) != null) { + fontObj = getCurrentPage().getResources().getCOSDictionary().getDictionaryObject(COSName.FONT); + } + Map fontMap = getCurrentPage().findResources().getFonts(); + + if(fontObj != null) { + getCurrentPage().getResources().getCOSDictionary().setItem(COSName.FONT, fontObj); + } + + return fontMap; + } + public class MyInvoke extends OperatorProcessor { private PDFPage mypage; -- cgit v1.2.3