Discussion:
[iText-questions] PDF header signature not found
ktanzer
2016-05-27 23:51:16 UTC
Permalink
Addendum:
If I use the physical file to get the page count, using the similar function
below, it works! Why does writing the file to disk, versus using an
InputStream object, do something to flush/fix/correct the document?

private int getPDFPageCount(String nameFile) {
if (LOG.isTraceEnabled())
LOG.trace(LogHelper.getMethodName(LogHelper.THIS_METHOD) + " enter");
int result = 0;

try {
PdfReader reader = new PdfReader(nameFile);
result = reader.getNumberOfPages();
reader.close();
} catch (IOException e) {
LOG.error(LogHelper.getMethodName(LogHelper.THIS_METHOD) + " caught
IOException",e);
} //end-catch

if (LOG.isTraceEnabled())
LOG.trace(LogHelper.getMethodName(LogHelper.THIS_METHOD) + " result = " +
result);
return result;
}




--
View this message in context: http://itext.2136553.n4.nabble.com/PDF-header-signature-not-found-tp4661046p4661047.html
Sent from the iText mailing list archive at Nabble.com.

------------------------------------------------------------------------------
What NetFlow Analyzer can do for you? Monitors network bandwidth and traffic
patterns at an interface-level. Reveals which users, apps, and protocols are
consuming the most bandwidth. Provides multi-vendor support for NetFlow,
J-Flow, sFlow and other flows. Make informed decisions using capacity
planning reports. https://ad.doubleclick.net/ddm/clk/305295220;132659582;e
_______________________________________________
iText-questions mailing list
iText-***@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/itext-questions

iText(R) is a registered trademark of 1T3XT BVBA.
Many questions posted to this list can (and will) be answered with a reference to the iText book: http://www.itextpdf.com/book/
Please check the keywords list before you ask for examples: http://itextpdf.com/themes/keywords.php
blowagie
2016-05-28 13:19:49 UTC
Permalink
You probably create the InputStream incorrectly. Remove iText from your test
and read the first characters from your InputStream to a file. You'll see
that the file read from the InputStream doesn't start with %PDF-1.4



--
View this message in context: http://itext.2136553.n4.nabble.com/PDF-header-signature-not-found-tp4661046p4661048.html
Sent from the iText mailing list archive at Nabble.com.

------------------------------------------------------------------------------
What NetFlow Analyzer can do for you? Monitors network bandwidth and traffic
patterns at an interface-level. Reveals which users, apps, and protocols are
consuming the most bandwidth. Provides multi-vendor support for NetFlow,
J-Flow, sFlow and other flows. Make informed decisions using capacity
planning reports. https://ad.doubleclick.net/ddm/clk/305295220;132659582;e
_______________________________________________
iText-questions mailing list
iText-***@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/itext-questions

iText(R) is a registered trademark of 1T3XT BVBA.
Many questions posted to this list can (and will) be answered with a reference to the iText book: http://www.itextpdf.com/book/
Please check the keywords list before you ask for examples: http://itextpdf.com/themes/keywords.php
Loading...