pdfbox-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From <pie...@huttin.com>
Subject Error with saved PDF file and error in openning with conforming parser
Date Mon, 23 Jul 2012 12:22:07 GMT
Hello,

I have some pdf documents who generate me some strange error, when I 
just open it and save it the resulting PDF is not opennable anymore by 
adobe reader (it block adobe reader and crash it), also the resulting 
file is bigger than the orignal one.

the code I use to open the file and save it into a new one :

PDDocument document = null;
File f = new File(args[0]);
if (f.exists()) {
	document = PDDocument.load(f);
	FileOutputStream fos = new FileOutputStream(new File(f.getParent(), 
"OUPUT-"+f.getName()));
	document.save(fos);
	document.close();
	fos.close();
}

SO I have decide to open it using the conforming parser but I recive 
the following error message:

java.io.IOException: Invalid hex string: 
10477c80ad68883700693730a39c8cc2><54ffd9970b64a157a094b79269584729
	at 
org.apache.pdfbox.cos.COSString.createFromHexString(COSString.java:218)
	at 
org.apache.pdfbox.cos.COSString.createFromHexString(COSString.java:188)
	at 
org.apache.pdfbox.pdfparser.ConformingPDFParser.readObjectBackwards(ConformingPDFParser.java:329)
	at 
org.apache.pdfbox.pdfparser.ConformingPDFParser.readDictionaryBackwards(ConformingPDFParser.java:572)
	at 
org.apache.pdfbox.pdfparser.ConformingPDFParser.parseTrailerInformation(ConformingPDFParser.java:152)
	at 
org.apache.pdfbox.pdfparser.ConformingPDFParser.parse(ConformingPDFParser.java:77)
	at com.xxxxx.tests.PDFDocOpenSave.main(PDFDocOpenSave.java:23)
Caused by: java.lang.NumberFormatException: For input string: "><"
	at java.lang.NumberFormatException.forInputString(Unknown Source)
	at java.lang.Integer.parseInt(Unknown Source)
	at 
org.apache.pdfbox.cos.COSString.createFromHexString(COSString.java:212)
	... 6 more

and effectivley if I check in the orignal file I found the value in 
the trailer :

0000146487 00000 n
trailer
<</Size 295/Root 3 0 R/Info 1 0 R/ID 
[<10477c80ad68883700693730a39c8cc2><54ffd9970b64a157a094b79269584729>]>>
startxref
197312
%%EOF

Thanks in advance for your help.

Best regards,

Pierre Huttin


Mime
View raw message