aboutsummaryrefslogtreecommitdiff
path: root/pdf-as-lib/src/main/java/at/gv/egiz/pdfas
diff options
context:
space:
mode:
authorAndreas Fitzek <andreas.fitzek@iaik.tugraz.at>2014-04-03 15:38:01 +0200
committerAndreas Fitzek <andreas.fitzek@iaik.tugraz.at>2014-04-03 15:47:56 +0200
commitf891dca529c9dc199114ae4f0857d28812315b11 (patch)
tree66de8c3db33fd05ff8511c9d8252aaef72a6b516 /pdf-as-lib/src/main/java/at/gv/egiz/pdfas
parent473f376290dbcaa435f234a9ba48d9bc54946923 (diff)
downloadpdf-as-4-f891dca529c9dc199114ae4f0857d28812315b11.tar.gz
pdf-as-4-f891dca529c9dc199114ae4f0857d28812315b11.tar.bz2
pdf-as-4-f891dca529c9dc199114ae4f0857d28812315b11.zip
Fixed Positioning to recognize Annotations
Diffstat (limited to 'pdf-as-lib/src/main/java/at/gv/egiz/pdfas')
-rw-r--r--pdf-as-lib/src/main/java/at/gv/egiz/pdfas/lib/impl/signing/pdfbox/PADESPDFBOXSigner.java19
-rw-r--r--pdf-as-lib/src/main/java/at/gv/egiz/pdfas/lib/impl/stamping/pdfbox/PDFAsVisualSignatureBuilder.java9
-rw-r--r--pdf-as-lib/src/main/java/at/gv/egiz/pdfas/lib/impl/stamping/pdfbox/tagging/PDFBoxTaggingUtils.java35
3 files changed, 57 insertions, 6 deletions
diff --git a/pdf-as-lib/src/main/java/at/gv/egiz/pdfas/lib/impl/signing/pdfbox/PADESPDFBOXSigner.java b/pdf-as-lib/src/main/java/at/gv/egiz/pdfas/lib/impl/signing/pdfbox/PADESPDFBOXSigner.java
index 767887b3..c04dca59 100644
--- a/pdf-as-lib/src/main/java/at/gv/egiz/pdfas/lib/impl/signing/pdfbox/PADESPDFBOXSigner.java
+++ b/pdf-as-lib/src/main/java/at/gv/egiz/pdfas/lib/impl/signing/pdfbox/PADESPDFBOXSigner.java
@@ -42,6 +42,8 @@ import org.apache.pdfbox.pdmodel.PDDocument;
import org.apache.pdfbox.pdmodel.PDDocumentCatalog;
import org.apache.pdfbox.pdmodel.PDPage;
import org.apache.pdfbox.pdmodel.PDPageNode;
+import org.apache.pdfbox.pdmodel.documentinterchange.logicalstructure.PDStructureElement;
+import org.apache.pdfbox.pdmodel.documentinterchange.logicalstructure.PDStructureTreeRoot;
import org.apache.pdfbox.pdmodel.graphics.color.PDOutputIntent;
import org.apache.pdfbox.pdmodel.graphics.xobject.PDJpeg;
import org.apache.pdfbox.pdmodel.interactive.digitalsignature.PDSignature;
@@ -69,6 +71,7 @@ import at.gv.egiz.pdfas.lib.impl.stamping.TableFactory;
import at.gv.egiz.pdfas.lib.impl.stamping.ValueResolver;
import at.gv.egiz.pdfas.lib.impl.stamping.pdfbox.PDFAsVisualSignatureProperties;
import at.gv.egiz.pdfas.lib.impl.stamping.pdfbox.PdfBoxVisualObject;
+import at.gv.egiz.pdfas.lib.impl.stamping.pdfbox.tagging.PDFBoxTaggingUtils;
import at.gv.egiz.pdfas.lib.impl.status.PDFObject;
import at.gv.egiz.pdfas.lib.impl.status.RequestedSignature;
import at.knowcenter.wag.egov.egiz.pdf.PositioningInstruction;
@@ -288,6 +291,22 @@ public class PADESPDFBOXSigner implements IPdfSigner, IConfigurationConstants {
e);
}
}
+
+ /*if(signatureProfileSettings.isPDFA()) {
+ // Check for PDF-UA
+ PDDocumentCatalog root = doc.getDocumentCatalog();
+ PDStructureTreeRoot treeRoot = root.getStructureTreeRoot();
+ if(treeRoot != null) {
+ // Handle as PDF-UA
+ logger.info("Tree Root: {}", treeRoot.toString());
+ PDStructureElement docElement = PDFBoxTaggingUtils.getDocumentElement(treeRoot);
+ PDStructureElement sigBlock = new PDStructureElement("Table", docElement);
+ root.getCOSObject().setNeedToBeUpdate(true);
+ docElement.getCOSObject().setNeedToBeUpdate(true);
+ treeRoot.getCOSObject().setNeedToBeUpdate(true);
+ sigBlock.setTitle("Signature Table");
+ }
+ }*/
options.setPreferedSignatureSize(0x1000);
options.setPage(positioningInstruction.getPage());
diff --git a/pdf-as-lib/src/main/java/at/gv/egiz/pdfas/lib/impl/stamping/pdfbox/PDFAsVisualSignatureBuilder.java b/pdf-as-lib/src/main/java/at/gv/egiz/pdfas/lib/impl/stamping/pdfbox/PDFAsVisualSignatureBuilder.java
index 0b183c08..e24ff939 100644
--- a/pdf-as-lib/src/main/java/at/gv/egiz/pdfas/lib/impl/stamping/pdfbox/PDFAsVisualSignatureBuilder.java
+++ b/pdf-as-lib/src/main/java/at/gv/egiz/pdfas/lib/impl/stamping/pdfbox/PDFAsVisualSignatureBuilder.java
@@ -41,14 +41,13 @@ import org.slf4j.LoggerFactory;
import at.gv.egiz.pdfas.common.exceptions.PdfAsException;
import at.gv.egiz.pdfas.common.settings.ISettings;
-import at.gv.egiz.pdfas.lib.test.mains.TestPDFBoxTable;
import at.knowcenter.wag.egov.egiz.table.Entry;
import at.knowcenter.wag.egov.egiz.table.Style;
public class PDFAsVisualSignatureBuilder extends PDVisibleSigBuilder {
private static final Logger logger = LoggerFactory
- .getLogger(TestPDFBoxTable.class);
+ .getLogger(PDFAsVisualSignatureBuilder.class);
private void drawTable(PDPage page, PDPageContentStream contentStream,
float x, float y, PDFBoxTable abstractTable, PDDocument doc,
@@ -157,9 +156,8 @@ public class PDFAsVisualSignatureBuilder extends PDVisibleSigBuilder {
String text = (String) cell.getValue();
float ttexty = texty - padding - fontSize;
- // COSName name = COSName.getPDFName("ANDI_TAG!");
- // contentStream.beginMarkedContentSequence(COSName.ALT,
- // name);
+ //COSName name = COSName.getPDFName("ANDI_TAG!");
+ //contentStream.beginMarkedContentSequence(COSName.ALT, name);
String fontName = textFont.equals(PDType1Font.COURIER) ? "COURIER" : "HELVETICA";
contentStream.beginText();
@@ -254,7 +252,6 @@ public class PDFAsVisualSignatureBuilder extends PDVisibleSigBuilder {
private PDFAsVisualSignatureProperties properties;
private ISettings settings;
-// private List<PDFont> addedFonts = new ArrayList<PDFont>();
private PDResources innerFormResources;
private Map<String, ImageObject> images = new HashMap<String, ImageObject>();
diff --git a/pdf-as-lib/src/main/java/at/gv/egiz/pdfas/lib/impl/stamping/pdfbox/tagging/PDFBoxTaggingUtils.java b/pdf-as-lib/src/main/java/at/gv/egiz/pdfas/lib/impl/stamping/pdfbox/tagging/PDFBoxTaggingUtils.java
new file mode 100644
index 00000000..3501e354
--- /dev/null
+++ b/pdf-as-lib/src/main/java/at/gv/egiz/pdfas/lib/impl/stamping/pdfbox/tagging/PDFBoxTaggingUtils.java
@@ -0,0 +1,35 @@
+package at.gv.egiz.pdfas.lib.impl.stamping.pdfbox.tagging;
+
+import java.util.Iterator;
+import java.util.List;
+
+import org.apache.pdfbox.pdmodel.documentinterchange.logicalstructure.PDMarkedContentReference;
+import org.apache.pdfbox.pdmodel.documentinterchange.logicalstructure.PDStructureElement;
+import org.apache.pdfbox.pdmodel.documentinterchange.logicalstructure.PDStructureNode;
+import org.apache.pdfbox.pdmodel.documentinterchange.markedcontent.PDMarkedContent;
+
+public class PDFBoxTaggingUtils {
+
+ public static String DOCUMENT = "Document";
+
+ public static void beginMarkedContent(PDMarkedContentReference reference) {
+ PDMarkedContentReference ref;
+ PDMarkedContent mc;
+ }
+
+ public static PDStructureElement getDocumentElement(PDStructureNode structElem) {
+ List<Object> kids = structElem.getKids();
+ Iterator<Object> kidsit = kids.iterator();
+ while (kidsit.hasNext()) {
+ Object kid = kidsit.next();
+ if (kid instanceof PDStructureElement) {
+ PDStructureElement elem = (PDStructureElement) kid;
+ if(elem.getStructureType().equals(DOCUMENT)) {
+ return elem;
+ }
+ }
+ }
+ return null;
+ }
+
+}