Paulo,
Solved ! But still 1 question remaining (see below)
FYI:
The problem was appearing when an annotation had associated stream.
1- The annotation is stored into an FDF file
The PRStream was instantiated with offset / length, but no content
(bytes member remained null)
2- I create a pdfstamper, using the PDF file as reader
3- When copying the stream, I was using the constructor PRStream(PRStream
stream, PdfDictionary newDic).
When saving, the PDF file was used to retrieve the content rather than
the original FDF file
To fix it:
3- When copying the stream, I am now using the PdfReader.getStreamByte () as
follows:
/**
* The method copies a stream
* @param srcStream if the source stream
* @return a copied stream
*/
protected PdfStream copyStream (PRStream srcStream)
throws IOException
{
PRStream destStream = null;
byte buf[] = srcStream.getBytes ();
if (null == buf)
{
// Should read the content of source stream...
RandomAccessFileOrArray raf =
srcStream.getReader().getSafeFile ();
buf = PdfReader.getStreamBytes (srcStream, raf);
destStream = new PRStream (srcStream.getReader(), buf);
}
else
destStream = new PRStream (srcStream, null);
Iterator srcIt = srcStream.getKeys().iterator ();
while (srcIt.hasNext ())
{
PdfName key = (PdfName) srcIt.next();
PdfObject value = srcStream.get(key);
destStream.put (key, copyObject (value));
}
return destStream;
}
Q1: I noticed the original size of the stream was 2133 with /FlatDecode
filter.
The buffer was then decoded using PdfReader.FlateDecode () (length
5852)
The buffer is then zipped in the PRStream constructor
(Document.compress = true)
The buffer size is then 2130.
So question is: Is this acceptable / normal ?
(Special thank goes to Paulo for his kindness at quickly helping),
Regards,
-----Original Message-----
From: Paulo Soares [mailto:[EMAIL PROTECTED]
Sent: Tuesday, November 16, 2004 11:49 PM
To: Nguyen, Daniel; [EMAIL PROTECTED]
Subject: Re: [iText-questions] Merging annotations in FDF to original PDF
----- Original Message -----
From: "Nguyen, Daniel" <[EMAIL PROTECTED]>
To: <[EMAIL PROTECTED]>
Sent: Tuesday, November 16, 2004 21:19
Subject: [iText-questions] Merging annotations in FDF to original PDF
> Hi,
>
> I'm trying to merge annotations contained in an FDF file to the PDF file
it
> relates to.
> I've been testing the PdfStamper class to do so, however, I noticed the
> generated object id's were not unique within the document.
>
Yes they are.
> Q1: Should I continue looking at this class for such a purpose ? If not,
can
> anyone give me any advice on how to proceed ?
PdfStamper is the class to use.
> Q2: How should I handle annotations that refer to other using reference in
a
> circular way (ie: Popup -> Parent, and Parent -> Popup) ?
>
Not a problem but depends exactly on the specific annotation. In general the
indirect reference is created first and is attributed to each dic.
> Any answer would be greatly appreciated,
>
> ----------------------------------------
> Daniel Nguyen Thanh Son
> ----------------------------------------
>
-------------------------------------------------------
This SF.Net email is sponsored by: InterSystems CACHE
FREE OODBMS DOWNLOAD - A multidimensional database that combines
robust object and relational technologies, making it a perfect match
for Java, C++,COM, XML, ODBC and JDBC. www.intersystems.com/match8
_______________________________________________
iText-questions mailing list
[EMAIL PROTECTED]
https://lists.sourceforge.net/lists/listinfo/itext-questions