diff options
author | Andreas Fitzek <andreas.fitzek@iaik.tugraz.at> | 2014-02-11 08:19:04 +0100 |
---|---|---|
committer | Andreas Fitzek <andreas.fitzek@iaik.tugraz.at> | 2014-02-11 08:19:04 +0100 |
commit | 6d416edf737b9899aef7194aa66c35103dba07ce (patch) | |
tree | 25507345cd1e66a005c36e4021fba1bb57d56311 /stamper | |
parent | 5ea41481c10aa43ab1df5e0b7ba0c18c3262c9eb (diff) | |
download | pdf-as-4-6d416edf737b9899aef7194aa66c35103dba07ce.tar.gz pdf-as-4-6d416edf737b9899aef7194aa66c35103dba07ce.tar.bz2 pdf-as-4-6d416edf737b9899aef7194aa66c35103dba07ce.zip |
Support rotation of the signature block by r attribute in pos string
Diffstat (limited to 'stamper')
-rw-r--r-- | stamper/stmp-itext/src/main/java/at/gv/egiz/pdfas/stmp/itext/ITextStamper.java | 33 |
1 files changed, 31 insertions, 2 deletions
diff --git a/stamper/stmp-itext/src/main/java/at/gv/egiz/pdfas/stmp/itext/ITextStamper.java b/stamper/stmp-itext/src/main/java/at/gv/egiz/pdfas/stmp/itext/ITextStamper.java index 1b026300..afcac94c 100644 --- a/stamper/stmp-itext/src/main/java/at/gv/egiz/pdfas/stmp/itext/ITextStamper.java +++ b/stamper/stmp-itext/src/main/java/at/gv/egiz/pdfas/stmp/itext/ITextStamper.java @@ -35,6 +35,7 @@ import com.lowagie.text.pdf.PdfPCell; import com.lowagie.text.pdf.PdfPTable; import com.lowagie.text.pdf.PdfReader; import com.lowagie.text.pdf.PdfStamper; +import com.lowagie.text.pdf.PdfTemplate; public class ITextStamper implements IPDFStamper { @@ -501,11 +502,39 @@ public class ITextStamper implements IPDFStamper { PdfPTable table = object.getTable(); + + logger.info("Positioning: X " + positioningInstruction.getX() + " Y " + positioningInstruction.getY()); + logger.info("Positioning: P " + positioningInstruction.getPage()); logger.info("Visual Object: " + visualObject.getWidth() + " x " + visualObject.getHeight()); - //PdfTemplate table_template = content.createTemplate(visualObject.getWidth(), visualObject.getHeight()); - table.writeSelectedRows(0, -1, positioningInstruction.getX(), + PdfTemplate table_template = content.createTemplate(table.getTotalWidth(), table.getTotalHeight()); + + /* table.writeSelectedRows(0, -1, positioningInstruction.getX(), positioningInstruction.getY(), content); + */ + table.writeSelectedRows(0, -1, 0, + table.getTotalHeight(), table_template); + //table_template. + + float rotate = positioningInstruction.getRotation(); + + if(rotate != 0) { + //set up the affine transform + float angle = (float)(-rotate * (Math.PI / 180)); + float fxScale = (float)(Math.cos(angle)); + float fyScale = (float)(Math.cos(angle)); + float fxRote = (float)(-Math.sin(angle)); + float fyRote = (float)(Math.sin(angle)); + + content.addTemplate(table_template, fxScale, fxRote, fyRote, fyScale, + positioningInstruction.getX(), + positioningInstruction.getY() - table.getTotalHeight()); + } else { + content.addTemplate(table_template, positioningInstruction.getX(), + positioningInstruction.getY() - table.getTotalHeight()); + } + + stamper.close(); |