Title: RE: [iText-questions] Merging annotations in FDF to original PDF

Paulo,

Q1 was refering to the delta in the size: originally, I had a length of 2133, then after expand/compress, I have a length of 2130  bytes.

3 bytes difference. Is this normal ?



-----Original Message-----
From: Paulo Soares [mailto:[EMAIL PROTECTED]]
Sent: Wednesday, November 17, 2004 6:19 PM
To: Nguyen, Daniel; [EMAIL PROTECTED]
Subject: RE: [iText-questions] Merging annotations in FDF to original PDF

That's not a problem, there are 9 compression levels for flate.

> -----Original Message-----
> From: Nguyen, Daniel [mailto:[EMAIL PROTECTED]]
> Sent: Wednesday, November 17, 2004 4:03 PM
> To: Paulo Soares; [EMAIL PROTECTED]
> Subject: RE: [iText-questions] Merging annotations in FDF to original
> PDF
>
>  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
> > ----------------------------------------
> >
>

Reply via email to