diff options
author | Andreas Fitzek <andreas.fitzek@iaik.tugraz.at> | 2013-07-31 10:58:22 +0200 |
---|---|---|
committer | Andreas Fitzek <andreas.fitzek@iaik.tugraz.at> | 2013-07-31 10:58:22 +0200 |
commit | 59b738ffa58aef22454270d49d081a4506fc43cf (patch) | |
tree | 1aecd5e26400d4ed971d02d8c02ab1cdc957b5bf | |
parent | c33195994e0a5e263ebb87402f9789cdda21a4b2 (diff) | |
download | pdf-as-3-59b738ffa58aef22454270d49d081a4506fc43cf.tar.gz pdf-as-3-59b738ffa58aef22454270d49d081a4506fc43cf.tar.bz2 pdf-as-3-59b738ffa58aef22454270d49d081a4506fc43cf.zip |
Legacy Positionierung 3.2 ist nun Profil anhaengig
3 files changed, 26 insertions, 30 deletions
diff --git a/pdf-as-lib/src/main/java/at/knowcenter/wag/egov/egiz/PdfAS.java b/pdf-as-lib/src/main/java/at/knowcenter/wag/egov/egiz/PdfAS.java index 2681f80..a09a238 100644 --- a/pdf-as-lib/src/main/java/at/knowcenter/wag/egov/egiz/PdfAS.java +++ b/pdf-as-lib/src/main/java/at/knowcenter/wag/egov/egiz/PdfAS.java @@ -1288,8 +1288,19 @@ public abstract class PdfAS // y:auto
pos = new TablePos();
}
+
+ // afitzek
+ // Allow legacy positioning (3.2) for BRZ Templates ...
+ boolean legacy32 = false;
+ String leg = SettingsReader.getInstance().getSetting(SignatureTypes.SIG_OBJ + signature_type + ".legacy.pos", "false");
+ if (leg != null) {
+ if ("true".equals(leg.trim())) {
+ legacy32 = true;
+ }
+ }
+
// System.out.println("Tablepos="+pos);
- return PdfAS.adjustSignatureTableandCalculatePosition(pdfDataSource, pdf_table, pos);
+ return PdfAS.adjustSignatureTableandCalculatePosition(pdfDataSource, pdf_table, pos, legacy32);
}
/**
@@ -1304,7 +1315,7 @@ public abstract class PdfAS * @throws PDFDocumentException
* F.e.
*/
- public static PositioningInstruction adjustSignatureTableandCalculatePosition(final PdfDataSource pdfDataSource, PdfPTable pdf_table, TablePos pos) throws PDFDocumentException
+ public static PositioningInstruction adjustSignatureTableandCalculatePosition(final PdfDataSource pdfDataSource, PdfPTable pdf_table, TablePos pos, boolean legacy32) throws PDFDocumentException
{
PdfReader reader = null;
@@ -1389,7 +1400,7 @@ public abstract class PdfAS // up to here no checks have to be made if Tablesize and Pagesize are fit
// Now we have to getfreespace in page and reguard footerline
float footer_line = pos.getFooterLine();
- float pre_page_length = PDFUtilities.calculatePageLength(pdfDataSource, page - 1, page_height - footer_line, page_rotation);
+ float pre_page_length = PDFUtilities.calculatePageLength(pdfDataSource, page - 1, page_height - footer_line, page_rotation, legacy32);
if (pre_page_length == Float.NEGATIVE_INFINITY)
{
// we do have an empty page or nothing in area above footerline
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 138f334..32a043d 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 @@ -117,7 +117,7 @@ public class PDFPage extends PDFTextStripper { *
* @throws IOException
*/
- public PDFPage(float effectivePageHeight) throws IOException {
+ public PDFPage(float effectivePageHeight, boolean legacy32) throws IOException {
super();
this.effectivePageHeight = effectivePageHeight;
@@ -126,22 +126,7 @@ public class PDFPage extends PDFTextStripper { newInvoke.setContext(this);
operators.put("Do", newInvoke);
- boolean legacy = false;
-
- try {
- String leg = SettingsReader.getInstance().getSetting("legacy.pos",
- "false");
- if (leg != null) {
- if ("true".equals(leg.trim())) {
- legacy = true;
- }
- }
- } catch (SettingsException e) {
- // TODO Auto-generated catch block
- e.printStackTrace();
- }
-
- if (!legacy) {
+ if (!legacy32) {
registerCustomPathOperators();
}
}
diff --git a/pdf-as-lib/src/main/java/at/knowcenter/wag/egov/egiz/pdf/PDFUtilities.java b/pdf-as-lib/src/main/java/at/knowcenter/wag/egov/egiz/pdf/PDFUtilities.java index b3adb71..6009995 100644 --- a/pdf-as-lib/src/main/java/at/knowcenter/wag/egov/egiz/pdf/PDFUtilities.java +++ b/pdf-as-lib/src/main/java/at/knowcenter/wag/egov/egiz/pdf/PDFUtilities.java @@ -51,7 +51,7 @@ import com.lowagie.text.DocumentException; */
public abstract class PDFUtilities
{
- public static float calculatePageLength(final PdfDataSource pdfDataSource, int page, float effectivePageHeight, int pagerotation) throws PDFDocumentException
+ public static float calculatePageLength(final PdfDataSource pdfDataSource, int page, float effectivePageHeight, int pagerotation, boolean legacy32) throws PDFDocumentException
{
PDDocument pdfDocument_ = null;
try
@@ -69,7 +69,7 @@ public abstract class PDFUtilities parser.parse();
pdfDocument_ = parser.getPDDocument();
- float page_length = calculatePageLength(pdfDocument_, page, effectivePageHeight, pagerotation);
+ float page_length = calculatePageLength(pdfDocument_, page, effectivePageHeight, pagerotation, legacy32);
return page_length;
}
catch (IOException e)
@@ -83,13 +83,13 @@ public abstract class PDFUtilities PDFASUtils.closeQuietly(pdfDocument_);
}
}
- public static float calculatePageLength(PDDocument document, int page, float effectivePageHeight, int pagerotation) throws IOException
+ public static float calculatePageLength(PDDocument document, int page, float effectivePageHeight, int pagerotation, boolean legacy32) throws IOException
{
//int last_page_id = document.getNumberOfPages();
List allPages = document.getDocumentCatalog().getAllPages();
PDPage pdpage = (PDPage) allPages.get(page);
pdpage.setRotation(pagerotation);
- return calculatePageLength(pdpage, effectivePageHeight);
+ return calculatePageLength(pdpage, effectivePageHeight, legacy32);
}
/**
@@ -99,7 +99,7 @@ public abstract class PDFUtilities * @return
* @throws PDFDocumentException
*/
- public static float calculateLastPageLength(final byte[] pdf, float effectivePageHeight) throws PDFDocumentException
+ public static float calculateLastPageLength(final byte[] pdf, float effectivePageHeight, boolean legacy32) throws PDFDocumentException
{
PDDocument pdfDocument_ = null;
try
@@ -116,7 +116,7 @@ public abstract class PDFUtilities parser.parse();
pdfDocument_ = parser.getPDDocument();
- float last_page_length = calculateLastPageLength(pdfDocument_, effectivePageHeight);
+ float last_page_length = calculateLastPageLength(pdfDocument_, effectivePageHeight, legacy32);
return last_page_length;
}
@@ -132,20 +132,20 @@ public abstract class PDFUtilities }
}
- public static float calculateLastPageLength(PDDocument document, float effectivePageHeight) throws IOException
+ public static float calculateLastPageLength(PDDocument document, float effectivePageHeight, boolean legacy32) throws IOException
{
int last_page_id = document.getNumberOfPages();
List allPages = document.getDocumentCatalog().getAllPages();
PDPage last_page = (PDPage) allPages.get(last_page_id - 1);
- return calculatePageLength(last_page, effectivePageHeight);
+ return calculatePageLength(last_page, effectivePageHeight, legacy32);
}
- public static float calculatePageLength(PDPage page, float effectivePageHeight) throws IOException
+ public static float calculatePageLength(PDPage page, float effectivePageHeight, boolean legacy32) throws IOException
{
// logger_.debug("Last Page id:" + last_page_id);
// PDPage last_page = (PDPage) allPages.get(0);
- PDFPage my_page = new PDFPage(effectivePageHeight);
+ PDFPage my_page = new PDFPage(effectivePageHeight, legacy32);
my_page.processStream(page, page.findResources(), page.getContents().getStream());
return my_page.getMaxPageLength();
}
|