aboutsummaryrefslogtreecommitdiff
path: root/pdf-as-lib/src/main/java/at/knowcenter/wag/egov/egiz/pdf
diff options
context:
space:
mode:
Diffstat (limited to 'pdf-as-lib/src/main/java/at/knowcenter/wag/egov/egiz/pdf')
-rw-r--r--pdf-as-lib/src/main/java/at/knowcenter/wag/egov/egiz/pdf/AdobeSignatureHelper.java3
-rw-r--r--pdf-as-lib/src/main/java/at/knowcenter/wag/egov/egiz/pdf/ObjectExtractor.java2
-rw-r--r--pdf-as-lib/src/main/java/at/knowcenter/wag/egov/egiz/pdf/PDFPage.java31
-rw-r--r--pdf-as-lib/src/main/java/at/knowcenter/wag/egov/egiz/pdf/PDFSignatureObjectIText.java8
-rw-r--r--pdf-as-lib/src/main/java/at/knowcenter/wag/egov/egiz/pdf/PDFUtilities.java22
-rw-r--r--pdf-as-lib/src/main/java/at/knowcenter/wag/egov/egiz/pdf/Placeholder.java2
-rw-r--r--pdf-as-lib/src/main/java/at/knowcenter/wag/egov/egiz/pdf/PositioningInstruction.java43
-rw-r--r--pdf-as-lib/src/main/java/at/knowcenter/wag/egov/egiz/pdf/StructContentHelper.java2
8 files changed, 74 insertions, 39 deletions
diff --git a/pdf-as-lib/src/main/java/at/knowcenter/wag/egov/egiz/pdf/AdobeSignatureHelper.java b/pdf-as-lib/src/main/java/at/knowcenter/wag/egov/egiz/pdf/AdobeSignatureHelper.java
index e337e71..a67f789 100644
--- a/pdf-as-lib/src/main/java/at/knowcenter/wag/egov/egiz/pdf/AdobeSignatureHelper.java
+++ b/pdf-as-lib/src/main/java/at/knowcenter/wag/egov/egiz/pdf/AdobeSignatureHelper.java
@@ -123,6 +123,7 @@ public class AdobeSignatureHelper {
// the following line marks the sig block as adobe sig
// sap.setVisibleSignature(createRectangleFromTablePos(iui.actualTablePos),
// iui.actualTablePos.page, "PDF-AS-Signatur");
+ // zero size rectangle -> signature block not shown as adobe visible signature
sap.setVisibleSignature(new Rectangle(0, 0, 0, 0), atp.page, finalFieldName);
String subfilter = "unknown";
if (so != null && so.getKZ() != null) {
@@ -207,7 +208,7 @@ public class AdobeSignatureHelper {
}
private static String getAdobeReasonName(String sigProfile) {
- return getDefaultableConfigProperty(sigProfile, ADOBE_SIGN_REASONNAME_KEY, "Informationen zur Prüfung finden Sie unter http://www.signaturpruefung.gv.at");
+ return getDefaultableConfigProperty(sigProfile, ADOBE_SIGN_REASONNAME_KEY, "Informationen zur Pr\u00FCfung finden Sie unter http://www.signaturpruefung.gv.at");
}
private static String getVerifyUrl(String sigProfile) {
diff --git a/pdf-as-lib/src/main/java/at/knowcenter/wag/egov/egiz/pdf/ObjectExtractor.java b/pdf-as-lib/src/main/java/at/knowcenter/wag/egov/egiz/pdf/ObjectExtractor.java
index eb7377a..09f6d38 100644
--- a/pdf-as-lib/src/main/java/at/knowcenter/wag/egov/egiz/pdf/ObjectExtractor.java
+++ b/pdf-as-lib/src/main/java/at/knowcenter/wag/egov/egiz/pdf/ObjectExtractor.java
@@ -158,7 +158,7 @@ public class ObjectExtractor {
objInfo.setHeight(image.getHeight());
objInfo.setWidth(image.getWidth());
- objInfo.setName(key + image.getSuffix());
+ objInfo.setName(key + "." + image.getSuffix());
objInfo.setObjectType(NonTextObjectInfo.TYPE_IMAGE);
objInfo.setPageNr(pageNr);
objectInfos.add(objInfo);
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 a0311da..7de89d2 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
@@ -74,22 +74,22 @@ public class PDFPage extends PDFTextStripper
protected float max_image_ypos = Float.NEGATIVE_INFINITY;
/**
- * The y coordinate of the footer line. PDF elements below this footer line will not be regarded.
+ * The effective page height.
*/
- protected float footer_line = 0.0f;
+ protected float effectivePageHeight;
/**
* Constructor.
*
- * @param footer_line The y coordinate of the footer line. PDF elements below this footer line will not be regarded.
+ * @param effectivePageHeight The height of the page to be evaluated. PDF elements outside this height will not be considered.
*
* @throws IOException
*/
- public PDFPage(float footer_line) throws IOException
+ public PDFPage(float effectivePageHeight) throws IOException
{
super();
- this.footer_line = footer_line;
+ this.effectivePageHeight = effectivePageHeight;
OperatorProcessor newInvoke = new MyInvoke();
newInvoke.setContext(this);
@@ -140,9 +140,8 @@ public class PDFPage extends PDFTextStripper
float page_height = page.findMediaBox().getHeight();
current_y = page_height - text.getX();
}
-
-
- if (current_y > this.footer_line)
+
+ if (current_y > this.effectivePageHeight)
{
//logger_.debug("character is below footer_line. footer_line = " + this.footer_line + ", text.character=" + character + ", y=" + current_y);
return;
@@ -152,12 +151,8 @@ public class PDFPage extends PDFTextStripper
if (!character.equals(" ") && current_y > this.max_character_ypos)
{
this.max_character_ypos = current_y;
- //logger_.debug("text.character=" + character + ", y=" + current_y);
- // System.err.println(character + "|" + current_y);
}
- //logger_.error("text.character=" + character + ", y=" + current_y + " max_c=" + this.max_character_ypos);
- // System.err.println(character + "|" + current_y);
}
// use this funtion getting an unsorted text output
@@ -182,7 +177,7 @@ public class PDFPage extends PDFTextStripper
{
max_ypos = this.max_image_ypos;
}
- //logger_.error("max len=" + max_ypos);
+
return max_ypos;
}
@@ -192,7 +187,6 @@ public class PDFPage extends PDFTextStripper
public void process(PDFOperator operator, List arguments) throws IOException
{
COSName name = (COSName) arguments.get(0);
- //logger_.error("<Do name=\"" + name.getName() + "\">");
// PDResources res = context.getResources();
@@ -203,13 +197,12 @@ public class PDFPage extends PDFTextStripper
COSStream cos_stream = stream.getStream();
COSName subtype = (COSName) cos_stream.getDictionaryObject(COSName.SUBTYPE);
- //logger_.error("<Do subtype name=\"" + subtype.getName() + "\">");
if (subtype.equals(COSName.IMAGE))
{
- //logger_.error("XObject Image");
+ logger_.debug("XObject Image");
Matrix ctm = context.getGraphicsState().getCurrentTransformationMatrix();
- //logger_.debug("ctm = " + ctm);
+ logger_.debug("ctm = " + ctm);
Pos [] coordinates = new Pos [] {
new Pos(0, 0, 1),
@@ -275,9 +268,9 @@ public class PDFPage extends PDFTextStripper
logger_.debug("actual_lowest_point = " + actual_lowest_point);
- if (actual_lowest_point > PDFPage.this.footer_line && actual_starting_point > PDFPage.this.footer_line)
+ if (actual_lowest_point > PDFPage.this.effectivePageHeight && actual_starting_point > PDFPage.this.effectivePageHeight)
{
- logger_.debug("image is below footer_line. footer_line = " + PDFPage.this.footer_line);
+ logger_.debug("image is below footer_line");
return;
}
diff --git a/pdf-as-lib/src/main/java/at/knowcenter/wag/egov/egiz/pdf/PDFSignatureObjectIText.java b/pdf-as-lib/src/main/java/at/knowcenter/wag/egov/egiz/pdf/PDFSignatureObjectIText.java
index 1145619..a8a150e 100644
--- a/pdf-as-lib/src/main/java/at/knowcenter/wag/egov/egiz/pdf/PDFSignatureObjectIText.java
+++ b/pdf-as-lib/src/main/java/at/knowcenter/wag/egov/egiz/pdf/PDFSignatureObjectIText.java
@@ -418,7 +418,7 @@ public class PDFSignatureObjectIText implements PDFSignatureObject
logger_.debug("Image file declaration is relative. Prepending path of resources directory.");
img_file = new File(SettingsReader.relocateFile(img_ref));
} else {
- logger_.debug("Image file declaration is absolute. Skipping file relocation.");
+ logger_.debug("Image file declaration is absolute. Skipping file relocation.");
}
// String img_location = SettingsReader.relocateFile(img_ref);
// File img_file = new File (img_location);
@@ -447,7 +447,7 @@ public class PDFSignatureObjectIText implements PDFSignatureObject
{
logger_.error("BadElementException:" + e.getMessage());
}
- PDFDocumentException pde = new PDFDocumentException(220, "PDF table can not created");
+ PDFDocumentException pde = new PDFDocumentException(220, "Unable to create PDF table.");
throw pde;
}
catch (MalformedURLException e)
@@ -456,7 +456,7 @@ public class PDFSignatureObjectIText implements PDFSignatureObject
{
logger_.error("MalformedURLException:" + e.getMessage());
}
- PDFDocumentException pde = new PDFDocumentException(221, "PDF table can not created");
+ PDFDocumentException pde = new PDFDocumentException(221, "Unable to create PDF table.");
throw pde;
}
catch (IOException e)
@@ -465,7 +465,7 @@ public class PDFSignatureObjectIText implements PDFSignatureObject
{
logger_.error("Error Code: 222, IOException:" + e.getMessage());
}
- PDFDocumentException pde = new PDFDocumentException(222, "PDF table can not created: Image can not loaded");
+ PDFDocumentException pde = new PDFDocumentException(222, "Unable to create PDF table, unable to load image.");
throw pde;
}
break;
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 e2a3d06..bdc1078 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
@@ -50,7 +50,7 @@ import com.lowagie.text.DocumentException;
*/
public abstract class PDFUtilities
{
- public static float calculatePageLength(final PdfDataSource pdfDataSource,int page ,float footer_line, int pagerotation) throws PDFDocumentException
+ public static float calculatePageLength(final PdfDataSource pdfDataSource, int page, float effectivePageHeight, int pagerotation) throws PDFDocumentException
{
try
{
@@ -67,7 +67,7 @@ public abstract class PDFUtilities
parser.parse();
PDDocument pdfDocument_ = parser.getPDDocument();
- float page_length = calculatePageLength(pdfDocument_,page , footer_line, pagerotation);
+ float page_length = calculatePageLength(pdfDocument_, page, effectivePageHeight, pagerotation);
pdfDocument_.close();
return page_length;
}
@@ -80,23 +80,23 @@ public abstract class PDFUtilities
throw new PDFDocumentException(201, e);
}
}
- public static float calculatePageLength(PDDocument document,int page ,float footer_line, int pagerotation) throws IOException
+ public static float calculatePageLength(PDDocument document, int page, float effectivePageHeight, int pagerotation) 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, footer_line);
+ return calculatePageLength(pdpage, effectivePageHeight);
}
/**
* @deprecated
* @param pdf
- * @param footer_line
+ * @param effectivePageHeight
* @return
* @throws PDFDocumentException
*/
- public static float calculateLastPageLength(final byte[] pdf, float footer_line) throws PDFDocumentException
+ public static float calculateLastPageLength(final byte[] pdf, float effectivePageHeight) throws PDFDocumentException
{
try
{
@@ -112,7 +112,7 @@ public abstract class PDFUtilities
parser.parse();
PDDocument pdfDocument_ = parser.getPDDocument();
- float last_page_length = calculateLastPageLength(pdfDocument_, footer_line);
+ float last_page_length = calculateLastPageLength(pdfDocument_, effectivePageHeight);
pdfDocument_.close();
return last_page_length;
@@ -127,20 +127,20 @@ public abstract class PDFUtilities
}
}
- public static float calculateLastPageLength(PDDocument document, float footer_line) throws IOException
+ public static float calculateLastPageLength(PDDocument document, float effectivePageHeight) 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, footer_line);
+ return calculatePageLength(last_page, effectivePageHeight);
}
- public static float calculatePageLength(PDPage page, float footer_line) throws IOException
+ public static float calculatePageLength(PDPage page, float effectivePageHeight) throws IOException
{
// logger_.debug("Last Page id:" + last_page_id);
// PDPage last_page = (PDPage) allPages.get(0);
- PDFPage my_page = new PDFPage(footer_line);
+ PDFPage my_page = new PDFPage(effectivePageHeight);
my_page.processStream(page, page.findResources(), page.getContents().getStream());
return my_page.getMaxPageLength();
}
diff --git a/pdf-as-lib/src/main/java/at/knowcenter/wag/egov/egiz/pdf/Placeholder.java b/pdf-as-lib/src/main/java/at/knowcenter/wag/egov/egiz/pdf/Placeholder.java
index 9249985..101a2b0 100644
--- a/pdf-as-lib/src/main/java/at/knowcenter/wag/egov/egiz/pdf/Placeholder.java
+++ b/pdf-as-lib/src/main/java/at/knowcenter/wag/egov/egiz/pdf/Placeholder.java
@@ -32,8 +32,6 @@ import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;
-import javax.sound.midi.SysexMessage;
-
import org.apache.commons.codec.net.URLCodec;
import org.apache.log4j.Logger;
diff --git a/pdf-as-lib/src/main/java/at/knowcenter/wag/egov/egiz/pdf/PositioningInstruction.java b/pdf-as-lib/src/main/java/at/knowcenter/wag/egov/egiz/pdf/PositioningInstruction.java
index 7af4ce7..0fe399c 100644
--- a/pdf-as-lib/src/main/java/at/knowcenter/wag/egov/egiz/pdf/PositioningInstruction.java
+++ b/pdf-as-lib/src/main/java/at/knowcenter/wag/egov/egiz/pdf/PositioningInstruction.java
@@ -136,4 +136,47 @@ public class PositioningInstruction
return this.y;
}
+ public int hashCode() {
+ final int prime = 31;
+ int result = 1;
+ result = prime * result + (make_new_page ? 1231 : 1237);
+ result = prime * result + page;
+ result = prime * result + Float.floatToIntBits(x);
+ result = prime * result + Float.floatToIntBits(y);
+ return result;
+ }
+
+ public boolean equals(Object obj) {
+ if (this == obj)
+ return true;
+ if (obj == null)
+ return false;
+ if (!(obj instanceof PositioningInstruction))
+ return false;
+ PositioningInstruction other = (PositioningInstruction) obj;
+ if (make_new_page != other.make_new_page)
+ return false;
+ if (page != other.page)
+ return false;
+ if (Float.floatToIntBits(x) != Float.floatToIntBits(other.x))
+ return false;
+ if (Float.floatToIntBits(y) != Float.floatToIntBits(other.y))
+ return false;
+ return true;
+ }
+
+ public String toString() {
+ StringBuffer buffer = new StringBuffer();
+ buffer.append("PositioningInstruction [page=");
+ buffer.append(page);
+ buffer.append(", make_new_page=");
+ buffer.append(make_new_page);
+ buffer.append(", x=");
+ buffer.append(x);
+ buffer.append(", y=");
+ buffer.append(y);
+ buffer.append("]");
+ return buffer.toString();
+ }
+
}
diff --git a/pdf-as-lib/src/main/java/at/knowcenter/wag/egov/egiz/pdf/StructContentHelper.java b/pdf-as-lib/src/main/java/at/knowcenter/wag/egov/egiz/pdf/StructContentHelper.java
index 7ca5a0a..a9c1c54 100644
--- a/pdf-as-lib/src/main/java/at/knowcenter/wag/egov/egiz/pdf/StructContentHelper.java
+++ b/pdf-as-lib/src/main/java/at/knowcenter/wag/egov/egiz/pdf/StructContentHelper.java
@@ -167,7 +167,7 @@ public class StructContentHelper implements StructContentWriter {
this.structTreeRootKids = obtainStructTreeRootKids(structTreeRoot);
- if(this.structTreeRootKids == null)
+ if (this.structTreeRootKids == null)
{
this.structTreeRootKids = this.createStructTreeRootKids(structTreeRoot);
}