Chip,

Chip Whitmer-2 wrote:
> If I use PdfStamper two times to edit the same file, I get the message 
> "[Fatal Error] :-1:-1: Premature end of file" when I close the stamper the
> second time.

I ran your example and all output I got was this:

Processing data\stamper_test.pdf...
> Closing stamper
> Stamper closed
> Processing data\stamper_test.pdf...
> Closing stamper
> Stamper closed

Maybe the error you got was version dependent, I tested against SVN trunk.

Checking the result file, though, a shortcoming is apparant: The XML
metadata stream is empty while it was not in your original file.
Additionally the error message you got sounds very much like a XML parser
error.

When debugging into PdfStamper.close(), XmpReader.serializeDoc() (which
generates the XML metadata stored in the new file) actually does not
serialize its whole domDocument member (which was initialized by parsing the
original XML metadata) but merely the first match of
domDocument.getElementsByTagName("x:xmpmeta"). Unfortunately your original
metadata does not contain such an element at all. Therefore, you lose your
XML metadata.

BTW, the XML metadata in your original file are:

<?xpacket begin='' id='W5M0MpCehiHzreSzNTczkc9d' bytes='770'?>
> 
> <rdf:RDF xmlns:rdf='http://www.w3.org/1999/02/22-rdf-syntax-ns#'
>  xmlns:iX='http://ns.adobe.com/iX/1.0/'>
> 
>  <rdf:Description about=''
>   xmlns='http://ns.adobe.com/pdf/1.3/'
>   xmlns:pdf='http://ns.adobe.com/pdf/1.3/'>
>   <pdf:ModDate>2003-08-01T15:56:01-03:00</pdf:ModDate>
>   <pdf:CreationDate>2003-08-01T15:55:22-03:00</pdf:CreationDate>
>  </rdf:Description>
> 
>  <rdf:Description about=''
>   xmlns='http://ns.adobe.com/xap/1.0/'
>   xmlns:xap='http://ns.adobe.com/xap/1.0/'>
>   <xap:ModifyDate>2003-08-01T15:56:01-03:00</xap:ModifyDate>
>   <xap:CreateDate>2003-08-01T15:55:22-03:00</xap:CreateDate>
>   <xap:MetadataDate>2003-08-01T15:56:01-03:00</xap:MetadataDate>
>  </rdf:Description>
> 
> </rdf:RDF>
> <?xpacket end='r'?>

Maybe someone has an idea whether they are wrong or iText's handling of them
is wrong.

Regards,   Michael.

-- 
View this message in context: 
http://itext-general.2136553.n4.nabble.com/PdfStamper-error-Premature-end-of-file-tp2304334p2304521.html
Sent from the iText - General mailing list archive at Nabble.com.

------------------------------------------------------------------------------
The Palm PDK Hot Apps Program offers developers who use the
Plug-In Development Kit to bring their C/C++ apps to Palm for a share 
of $1 Million in cash or HP Products. Visit us here for more details:
http://ad.doubleclick.net/clk;226879339;13503038;l?
http://clk.atdmt.com/CRS/go/247765532/direct/01/
_______________________________________________
iText-questions mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/itext-questions

Buy the iText book: http://www.itextpdf.com/book/
Check the site with examples before you ask questions: 
http://www.1t3xt.info/examples/
You can also search the keywords list: http://1t3xt.info/tutorials/keywords/

Reply via email to