aboutsummaryrefslogtreecommitdiff
path: root/src/main/java/at/knowcenter/wag/egov
diff options
context:
space:
mode:
authorknowcenter <knowcenter@7b5415b0-85f9-ee4d-85bd-d5d0c3b42d1c>2007-03-02 08:25:07 +0000
committerknowcenter <knowcenter@7b5415b0-85f9-ee4d-85bd-d5d0c3b42d1c>2007-03-02 08:25:07 +0000
commitade592d842b1880b7f01b1c6ad4b382569d67014 (patch)
tree875e2c857b0715e7113987ed03513033aec893f6 /src/main/java/at/knowcenter/wag/egov
parent713a5a31d7ec4b02b6ca137404ea7f261d02254c (diff)
downloadpdf-as-3-ade592d842b1880b7f01b1c6ad4b382569d67014.tar.gz
pdf-as-3-ade592d842b1880b7f01b1c6ad4b382569d67014.tar.bz2
pdf-as-3-ade592d842b1880b7f01b1c6ad4b382569d67014.zip
now its posible to calculate pagelength of arbitrary page
git-svn-id: https://joinup.ec.europa.eu/svn/pdf-as/trunk@40 7b5415b0-85f9-ee4d-85bd-d5d0c3b42d1c
Diffstat (limited to 'src/main/java/at/knowcenter/wag/egov')
-rw-r--r--src/main/java/at/knowcenter/wag/egov/egiz/pdf/PDFUtilities.java38
1 files changed, 38 insertions, 0 deletions
diff --git a/src/main/java/at/knowcenter/wag/egov/egiz/pdf/PDFUtilities.java b/src/main/java/at/knowcenter/wag/egov/egiz/pdf/PDFUtilities.java
index 05854dd..5384a8c 100644
--- a/src/main/java/at/knowcenter/wag/egov/egiz/pdf/PDFUtilities.java
+++ b/src/main/java/at/knowcenter/wag/egov/egiz/pdf/PDFUtilities.java
@@ -35,9 +35,47 @@ import com.lowagie.text.DocumentException;
* Contains useful helpers for accessing PDF documents.
*
* @author wprinz
+ * @author mruhmer
*/
public abstract class PDFUtilities
{
+ public static float calculatePageLength(final byte[] pdf,int page ,float footer_line) throws PDFDocumentException
+ {
+ try
+ {
+ ByteArrayInputStream original_bais = new ByteArrayInputStream(pdf);
+ byte [] normalized_pdf = TextualSignature.normalizePDF(original_bais);
+
+ ByteArrayInputStream bais = new ByteArrayInputStream(normalized_pdf);
+
+ PDFParser parser = new PDFParser(bais);
+ File temporary_dir = SettingsReader.getTemporaryDirectory();
+ parser.setTempDirectory(temporary_dir);
+ parser.parse();
+
+ PDDocument pdfDocument_ = parser.getPDDocument();
+ float page_length = calculatePageLength(pdfDocument_,page , footer_line);
+ pdfDocument_.close();
+ return page_length;
+ }
+ catch (IOException e)
+ {
+ throw new PDFDocumentException(201, e);
+ }
+ catch (DocumentException e)
+ {
+ throw new PDFDocumentException(201, e);
+ }
+ }
+ public static float calculatePageLength(PDDocument document,int page ,float footer_line) throws IOException
+ {
+ //int last_page_id = document.getNumberOfPages();
+ List allPages = document.getDocumentCatalog().getAllPages();
+ PDPage pdpage = (PDPage) allPages.get(page);
+
+ return calculatePageLength(pdpage, footer_line);
+ }
+
public static float calculateLastPageLength(final byte[] pdf, float footer_line) throws PDFDocumentException
{
try