Leonard,
Q1: My understanding of what Acrobat does is
:
1- store the page's content into the page's resources
named 'F'
2- create an array, call it 'A'
Then, for each annotation:
3- builds an XObject/Form stream that contains the
annotation's normal appearance (call it 'N')
4- update the 'F' stream to display the created
'N'
5- adds a stream to the 'A' array of the page that
display a reference number (ie: '1', or 'n', being the index of the annotation
in the page)
6- remove the annotation
Then, it finally :
- adds a stream that displays the 'F' stream as 'A'
element
- associates the 'A' array as the 'Contents' value
of the page
...
and then generate another page(s ?) for the comments
itself.
This is what I'm intending to
simulate.
What i've been able to do:
1- remove the page's annotations
2- copy the page
Now, what's missing:
1- I don't have normal appearance of the
annotations on the pages
2- I should update the page content to display the
annotation numbers comments on next page(s) refer to.
Possibly, I might not need to do exactly what Adobe
does, however, I should be able to add the annotation's normal appearance and
little numbers at their top-right corner
How can i update the page's associated dictionnary with
new PdfObjects's reference ? How do these objects get numbered at this
time...then get renumbered upon saving the page ?
The code extract should be more
explicit:
public int
copyPage (int srcPageNum, Page page)
throws FileNotFoundException, DocumentException, IOException
{
PdfCopy copy = getCopy ();
// Get the page dictionary at the source...
PdfDictionary pageDict = page.getPageDict ();
Map refs = new HashMap ();
// 1- Converts the content into a new Stream
byte [] content = page.getContent ();
PRStream newContent = new PRStream (getReader(), content);
PdfIndirectReference iRefContent = copy.getPdfIndirectReference ();
PdfIndirectObject iNewContent = copy.addToBody (newContent, iRefContent);
PdfArray newStreams = new PdfArray ();
PdfIndirectReference iRefStreams = copy.getPdfIndirectReference ();
PdfIndirectObject iNewStreams = copy.addToBody (newStreams, iRefStreams);
//newStreams.add (iRefStreams);
throws FileNotFoundException, DocumentException, IOException
{
PdfCopy copy = getCopy ();
// Get the page dictionary at the source...
PdfDictionary pageDict = page.getPageDict ();
Map refs = new HashMap ();
// 1- Converts the content into a new Stream
byte [] content = page.getContent ();
PRStream newContent = new PRStream (getReader(), content);
PdfIndirectReference iRefContent = copy.getPdfIndirectReference ();
PdfIndirectObject iNewContent = copy.addToBody (newContent, iRefContent);
PdfArray newStreams = new PdfArray ();
PdfIndirectReference iRefStreams = copy.getPdfIndirectReference ();
PdfIndirectObject iNewStreams = copy.addToBody (newStreams, iRefStreams);
//newStreams.add (iRefStreams);
pageDict.put (PdfName.CONTENTS,
iRefStreams);
// 2- Remove the
annotations...
pageDict.remove (PdfName.ANNOTS);
// OK, do it
then...
PdfImportedPage importedPage = copy.getImportedPage (_reader,
srcPageNum);
// The 'Content' now relate to an array
of streams
copy.addPage (importedPage); //
<- Exception occurs here: see below
return copy.getPageNumber
();
}
when copying the page, the iRefStreams is copied to
null (i'm getting output: 'CANNOT COPY type 0' from
PdfCopy:copyObject () method) because my indirect reference is not a
PRIndirectReference.
I feel stucked.
But I guess there should be a way, possibly much
simpler
Any advice, guidance would be very much
appreciated,
Regards,
From: Leonard Rosenthol
[mailto:[EMAIL PROTECTED]
Sent: Thursday, November 18, 2004 7:34 PM
To: Nguyen, Daniel; [EMAIL PROTECTED]
Subject: RE: [iText-questions] Comment summary generation
At 12:50 PM 11/18/2004, Nguyen, Daniel wrote:Sent: Thursday, November 18, 2004 7:34 PM
To: Nguyen, Daniel; [EMAIL PROTECTED]
Subject: RE: [iText-questions] Comment summary generation
Q1: Can you indicate me where can I get this 'slide notes' sample and the name of associated source file ?
What I would like to do:
1- get a copy of an annotated page
2- remove annotations
3- reference the 'Contents' stream in the 'Resource' of the page as an XObject/Form, giving it a unique name (call it Xmain)
4- change the 'Content' of the page so that rather than referencing directly the stream, it references a array of streams and in the 1st stream, it will reference a the 'Xmain' Xobject
Q2: The feature as seen in Acrobat 6 generates, for each annotated page, a new page listing all comments.
For each comment, an icon/image is displayed. These are the images I was refering to
Leonard
---------------------------------------------------------------------------
Leonard
Rosenthol
<mailto:[EMAIL PROTECTED]>
Chief Technical
Officer
<http://www.pdfsages.com>
PDF Sages,
Inc.
215-938-7080 (voice)
215-938-0880 (fax)
