You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@pdfbox.apache.org by Dale King <da...@gmail.com> on 2017/11/14 23:47:04 UTC

Imposition with annotations

I am doing PDF imposition following the SuperImpose example (
https://svn.apache.org/viewvc/pdfbox/trunk/examples/src/main/java/org/apache/pdfbox/examples/pdmodel/SuperimposePage.java?view=markup)
and the content is appearing. What doesn't appear on the superimposed page
however are the annotations on the original page.

Is it possible to do superimpostion including the annotations?

-- 
Dale King

Re: Imposition with annotations

Posted by Dale King <da...@gmail.com>.
I think I have a solution that works for my need. I don't actually need the
annotations to be annotations in the output document. I just need the
annotations to be drawn in the document. The annotations in question are
either white squares to "erase" portions of original page or
semi-transparent colors to highlight something.

So, instead of copying the actual annotation I am grabbing the appearance
stream from the annotation and after proper matrix transformations to get
it in the right spot drawing the appearance stream using drawForm.

On Wed, Dec 27, 2017 at 4:34 AM, Tilman Hausherr <TH...@t-online.de>
wrote:

> You could call acroForm.setNeedAppearances(true) to have Adobe (don't
> know about apple) recreate the apperance streams.
>
> If you don't use that, then yes, you'd need to modify the content stream
> (and also the bbox, and possibly the matrix) to the new rectangle, by
> reverse-engineering what's there. The content stream is the gibberish.
>
> Tilman
>
>
> Am 27.12.2017 um 01:12 schrieb Dale King:
>
>> So I understand what is going on and my theory of missing resources was
>> incorrect.
>>
>> So the first question was why when I changed the rectangle of the square
>> annotation did it not visually appear to be the size I had set (appeared
>> to
>> be inset)? The annotation was created in apple Preview app. When the
>> annotation was added my settings in Preview included a thick dashed border
>> line, but using a transparent color. When Preview creates the annotation
>> it
>> creates it using an appearance stream which includes the instructions to
>> draw the filled square and to also draw the border even though it is
>> transparent. When you change the rectangle on an annotation with an
>> appearance stream the PDF viewer creates a matrix to translate the
>> coordinates from the BBox of the appearance stream to the rectangle of the
>> annotation (See section 12.5.5 of the PDF spec). The issue is that the
>> rectangle of the annotation from the original annotation included the
>> thick
>> transparent border line so the rectangle was bigger than the actual
>> visible
>> square annotation. Changing the rectangle scales the dimension of the
>> visiblie square but also scales up the thickness of the transparent
>> border.
>> So scaling a little rectangle to the size of the page also scales up the
>> difference between the bounding box of the appearance stream and the fill
>> operation in the appearance stream.
>>
>> The other question was why after copying the annotation to a new file and
>> interacting with the annotation in Apple Preview does it suddenly change
>> appearance and become the correct size, but with a dashed border and loses
>> the fill color if the fill was semi-transparent? When Apple preview
>> creates
>> an annotation it creates a copy of the annotation in an Apple specific
>> entry. My theory is that after I alter the rectangle and re-edit the new
>> PDF and interact with the annotation it sees that its copy and the basic
>> info in the annotation don't agree so decides it needs to recreate the
>> annotation based on the basic information in the annotation. However
>> transparency isn't really specified in the basic annotation information.
>> Transparency only comes from an ExtGState resource loaded by the
>> appearance
>> stream. So when it recreates it doesn't know anything about the
>> transparency and creates it without transparency.
>>
>> So it appears trying to copy and resize annotations that involve
>> transparency is going to be very problematic and would require a deep dive
>> into recreating the annotation.
>>
>> On Mon, Dec 25, 2017 at 4:28 AM, Tilman Hausherr <TH...@t-online.de>
>> wrote:
>>
>> In PDFBox, either keep the source open and don't close it before saving
>>> your copy document; or use PDFCloneUtility.
>>>
>>> I suspect you mean the resources... these you could simply assign the
>>> resources from the old to the new, while creating an adjusted content
>>> stream.
>>>
>>> I also suggest you use the PDFDebugger app to look at what's really in
>>> your document.
>>>
>>> Tilman
>>>
>>>
>>> Am 25.12.2017 um 07:18 schrieb Dale King:
>>>
>>> I am still trying to get this to work. I tried switching to iText library
>>>> and while initially getting better results with annotations, it still
>>>> did
>>>> not work. I am coming to the conclusion that the primary issue is that
>>>> if
>>>> I
>>>> copy an annotation from one document to another the problem is that the
>>>> annotation dictionary is a shallow copy. The annotation dictionary
>>>> references other objects that are not copied to the destination
>>>> document.
>>>> So I am wondering if there is a simple way given a dictionary to do a
>>>> deep
>>>> copy to another document?
>>>>
>>>> On Mon, Dec 4, 2017 at 4:44 PM, Dale King <da...@gmail.com> wrote:
>>>>
>>>> So what I was missing was that annotations can have their own content
>>>>
>>>>> streams. This is going to be difficult. I know it is easier programming
>>>>> wise to add the annotations afterward, but usability wise it is easier
>>>>> to
>>>>> do it before hand.
>>>>>
>>>>> So to understand the problem more what my program is doing is it takes
>>>>> an
>>>>> input that looks like the input I showed you except that there are
>>>>> perhaps
>>>>> 20-30 pages like that that are a single line of music. My program
>>>>> builds
>>>>> another document with pages that are 8"x5" (to match my tablet that
>>>>> has a
>>>>> 16x10 aspect ratio). The program puts as many lines of music it can per
>>>>> page (and can actually put several short lines together horizontally.
>>>>>
>>>>> On Mon, Dec 4, 2017 at 2:11 PM, Tilman Hausherr <THausherr@t-online.de
>>>>> >
>>>>> wrote:
>>>>>
>>>>> Am 04.12.2017 um 19:57 schrieb Dale King:
>>>>>
>>>>>> OK that is really odd. I am on Mac and in preview the blue rectangle
>>>>>> is
>>>>>>
>>>>>>> not the same size as yours, but when I click on it it changes to a
>>>>>>> dashed
>>>>>>> black rectangle bordering the enter page and the blue goes away.
>>>>>>>
>>>>>>> Sorry, I don't speak PDF content streams to know what the content
>>>>>>> stream
>>>>>>> is telling me.
>>>>>>>
>>>>>>> In the PDF 32000 specification look for "operator summary". I'll
>>>>>>>
>>>>>> annotate
>>>>>> a few below.
>>>>>>
>>>>>> For what you want to do (I haven't understood all the words - I assume
>>>>>> you want to cover parts so that you see only one line of notes) it
>>>>>> would be
>>>>>> easier to create the annotations as new instead of copying them.
>>>>>>
>>>>>> Tilman
>>>>>>
>>>>>>
>>>>>> On Mon, Dec 4, 2017 at 1:34 PM, Tilman Hausherr <
>>>>>> THausherr@t-online.de
>>>>>>
>>>>>>> <ma...@t-online.de>> wrote:
>>>>>>>
>>>>>>>       Am 04.12.2017 um 18:42 schrieb Dale King:
>>>>>>>
>>>>>>>       I tried for a simpler goal, just take that annotation and
>>>>>>>
>>>>>>>>       translate it to cover the entire output page, but even that
>>>>>>>> did
>>>>>>>>       not work as can be seen in the output pdf. Something is
>>>>>>>> getting
>>>>>>>>       in the way and adding its own coordinate translation but I
>>>>>>>> cannot
>>>>>>>>       figure out what.
>>>>>>>>
>>>>>>>>       The annotation of the target PDF does cover the entire page.
>>>>>>>>
>>>>>>> Click
>>>>>>>       on the left border of the page in Adobe Reader and you'll see
>>>>>>> the
>>>>>>>       rectangle. However...
>>>>>>>
>>>>>>>       I suspect you're unhappy with the blue rectangle. This could be
>>>>>>>       because of the appearance stream which you took from the source
>>>>>>>       unchanged:
>>>>>>>
>>>>>>>
>>>>>>>       q
>>>>>>>       Q
>>>>>>>       q
>>>>>>>         7.044313E-5 4.893184E-6 112.2815 29.0435 re   <==== sets a
>>>>>>>       rectangle and clip
>>>>>>>         W
>>>>>>>         n
>>>>>>>         /Cs1 cs
>>>>>>>         0 0.3813631 0.9982447 sc  <==== color
>>>>>>>         /Gs1 gs
>>>>>>>         3.498857 3.498791 105.2839 22.04592 re <=== sets a rectangle
>>>>>>> and
>>>>>>>       fill
>>>>>>>         f
>>>>>>>         4.997579 w
>>>>>>>         2 J
>>>>>>>         [ 11.99758 18.99274 ] 1 d
>>>>>>>         /Cs1 CS
>>>>>>>         0 0 0 SC  <===== black
>>>>>>>         /Gs2 gs
>>>>>>>         q
>>>>>>>           1 0 0 1 -399.6912 -556.2903 cm <==== position
>>>>>>>           403.1903 559.7895 105.284 22.04594 re  <==== sets a
>>>>>>> rectangle
>>>>>>>       and stroke
>>>>>>>           S
>>>>>>>         Q
>>>>>>>       Q
>>>>>>>
>>>>>>>
>>>>>>>       Tilman
>>>>>>>
>>>>>>>
>>>>>>>
>>>>>>>
>>>>>>> --
>>>>>>> Dale King
>>>>>>>
>>>>>>>
>>>>>>>
>>>>>> --
>>>>> Dale King
>>>>>
>>>>>
>>>>>
>>>> ---------------------------------------------------------------------
>>> To unsubscribe, e-mail: users-unsubscribe@pdfbox.apache.org
>>> For additional commands, e-mail: users-help@pdfbox.apache.org
>>>
>>>
>>>
>>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@pdfbox.apache.org
> For additional commands, e-mail: users-help@pdfbox.apache.org
>
>


-- 
Dale King

Re: Imposition with annotations

Posted by Tilman Hausherr <TH...@t-online.de>.
You could call acroForm.setNeedAppearances(true) to have Adobe (don't 
know about apple) recreate the apperance streams.

If you don't use that, then yes, you'd need to modify the content stream 
(and also the bbox, and possibly the matrix) to the new rectangle, by 
reverse-engineering what's there. The content stream is the gibberish.

Tilman

Am 27.12.2017 um 01:12 schrieb Dale King:
> So I understand what is going on and my theory of missing resources was
> incorrect.
>
> So the first question was why when I changed the rectangle of the square
> annotation did it not visually appear to be the size I had set (appeared to
> be inset)? The annotation was created in apple Preview app. When the
> annotation was added my settings in Preview included a thick dashed border
> line, but using a transparent color. When Preview creates the annotation it
> creates it using an appearance stream which includes the instructions to
> draw the filled square and to also draw the border even though it is
> transparent. When you change the rectangle on an annotation with an
> appearance stream the PDF viewer creates a matrix to translate the
> coordinates from the BBox of the appearance stream to the rectangle of the
> annotation (See section 12.5.5 of the PDF spec). The issue is that the
> rectangle of the annotation from the original annotation included the thick
> transparent border line so the rectangle was bigger than the actual visible
> square annotation. Changing the rectangle scales the dimension of the
> visiblie square but also scales up the thickness of the transparent border.
> So scaling a little rectangle to the size of the page also scales up the
> difference between the bounding box of the appearance stream and the fill
> operation in the appearance stream.
>
> The other question was why after copying the annotation to a new file and
> interacting with the annotation in Apple Preview does it suddenly change
> appearance and become the correct size, but with a dashed border and loses
> the fill color if the fill was semi-transparent? When Apple preview creates
> an annotation it creates a copy of the annotation in an Apple specific
> entry. My theory is that after I alter the rectangle and re-edit the new
> PDF and interact with the annotation it sees that its copy and the basic
> info in the annotation don't agree so decides it needs to recreate the
> annotation based on the basic information in the annotation. However
> transparency isn't really specified in the basic annotation information.
> Transparency only comes from an ExtGState resource loaded by the appearance
> stream. So when it recreates it doesn't know anything about the
> transparency and creates it without transparency.
>
> So it appears trying to copy and resize annotations that involve
> transparency is going to be very problematic and would require a deep dive
> into recreating the annotation.
>
> On Mon, Dec 25, 2017 at 4:28 AM, Tilman Hausherr <TH...@t-online.de>
> wrote:
>
>> In PDFBox, either keep the source open and don't close it before saving
>> your copy document; or use PDFCloneUtility.
>>
>> I suspect you mean the resources... these you could simply assign the
>> resources from the old to the new, while creating an adjusted content
>> stream.
>>
>> I also suggest you use the PDFDebugger app to look at what's really in
>> your document.
>>
>> Tilman
>>
>>
>> Am 25.12.2017 um 07:18 schrieb Dale King:
>>
>>> I am still trying to get this to work. I tried switching to iText library
>>> and while initially getting better results with annotations, it still did
>>> not work. I am coming to the conclusion that the primary issue is that if
>>> I
>>> copy an annotation from one document to another the problem is that the
>>> annotation dictionary is a shallow copy. The annotation dictionary
>>> references other objects that are not copied to the destination document.
>>> So I am wondering if there is a simple way given a dictionary to do a deep
>>> copy to another document?
>>>
>>> On Mon, Dec 4, 2017 at 4:44 PM, Dale King <da...@gmail.com> wrote:
>>>
>>> So what I was missing was that annotations can have their own content
>>>> streams. This is going to be difficult. I know it is easier programming
>>>> wise to add the annotations afterward, but usability wise it is easier to
>>>> do it before hand.
>>>>
>>>> So to understand the problem more what my program is doing is it takes an
>>>> input that looks like the input I showed you except that there are
>>>> perhaps
>>>> 20-30 pages like that that are a single line of music. My program builds
>>>> another document with pages that are 8"x5" (to match my tablet that has a
>>>> 16x10 aspect ratio). The program puts as many lines of music it can per
>>>> page (and can actually put several short lines together horizontally.
>>>>
>>>> On Mon, Dec 4, 2017 at 2:11 PM, Tilman Hausherr <TH...@t-online.de>
>>>> wrote:
>>>>
>>>> Am 04.12.2017 um 19:57 schrieb Dale King:
>>>>> OK that is really odd. I am on Mac and in preview the blue rectangle is
>>>>>> not the same size as yours, but when I click on it it changes to a
>>>>>> dashed
>>>>>> black rectangle bordering the enter page and the blue goes away.
>>>>>>
>>>>>> Sorry, I don't speak PDF content streams to know what the content
>>>>>> stream
>>>>>> is telling me.
>>>>>>
>>>>>> In the PDF 32000 specification look for "operator summary". I'll
>>>>> annotate
>>>>> a few below.
>>>>>
>>>>> For what you want to do (I haven't understood all the words - I assume
>>>>> you want to cover parts so that you see only one line of notes) it
>>>>> would be
>>>>> easier to create the annotations as new instead of copying them.
>>>>>
>>>>> Tilman
>>>>>
>>>>>
>>>>> On Mon, Dec 4, 2017 at 1:34 PM, Tilman Hausherr <THausherr@t-online.de
>>>>>> <ma...@t-online.de>> wrote:
>>>>>>
>>>>>>       Am 04.12.2017 um 18:42 schrieb Dale King:
>>>>>>
>>>>>>       I tried for a simpler goal, just take that annotation and
>>>>>>>       translate it to cover the entire output page, but even that did
>>>>>>>       not work as can be seen in the output pdf. Something is getting
>>>>>>>       in the way and adding its own coordinate translation but I cannot
>>>>>>>       figure out what.
>>>>>>>
>>>>>>>       The annotation of the target PDF does cover the entire page.
>>>>>> Click
>>>>>>       on the left border of the page in Adobe Reader and you'll see the
>>>>>>       rectangle. However...
>>>>>>
>>>>>>       I suspect you're unhappy with the blue rectangle. This could be
>>>>>>       because of the appearance stream which you took from the source
>>>>>>       unchanged:
>>>>>>
>>>>>>
>>>>>>       q
>>>>>>       Q
>>>>>>       q
>>>>>>         7.044313E-5 4.893184E-6 112.2815 29.0435 re   <==== sets a
>>>>>>       rectangle and clip
>>>>>>         W
>>>>>>         n
>>>>>>         /Cs1 cs
>>>>>>         0 0.3813631 0.9982447 sc  <==== color
>>>>>>         /Gs1 gs
>>>>>>         3.498857 3.498791 105.2839 22.04592 re <=== sets a rectangle and
>>>>>>       fill
>>>>>>         f
>>>>>>         4.997579 w
>>>>>>         2 J
>>>>>>         [ 11.99758 18.99274 ] 1 d
>>>>>>         /Cs1 CS
>>>>>>         0 0 0 SC  <===== black
>>>>>>         /Gs2 gs
>>>>>>         q
>>>>>>           1 0 0 1 -399.6912 -556.2903 cm <==== position
>>>>>>           403.1903 559.7895 105.284 22.04594 re  <==== sets a rectangle
>>>>>>       and stroke
>>>>>>           S
>>>>>>         Q
>>>>>>       Q
>>>>>>
>>>>>>
>>>>>>       Tilman
>>>>>>
>>>>>>
>>>>>>
>>>>>>
>>>>>> --
>>>>>> Dale King
>>>>>>
>>>>>>
>>>>>
>>>> --
>>>> Dale King
>>>>
>>>>
>>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: users-unsubscribe@pdfbox.apache.org
>> For additional commands, e-mail: users-help@pdfbox.apache.org
>>
>>
>


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@pdfbox.apache.org
For additional commands, e-mail: users-help@pdfbox.apache.org


Re: Imposition with annotations

Posted by Dale King <da...@gmail.com>.
So I understand what is going on and my theory of missing resources was
incorrect.

So the first question was why when I changed the rectangle of the square
annotation did it not visually appear to be the size I had set (appeared to
be inset)? The annotation was created in apple Preview app. When the
annotation was added my settings in Preview included a thick dashed border
line, but using a transparent color. When Preview creates the annotation it
creates it using an appearance stream which includes the instructions to
draw the filled square and to also draw the border even though it is
transparent. When you change the rectangle on an annotation with an
appearance stream the PDF viewer creates a matrix to translate the
coordinates from the BBox of the appearance stream to the rectangle of the
annotation (See section 12.5.5 of the PDF spec). The issue is that the
rectangle of the annotation from the original annotation included the thick
transparent border line so the rectangle was bigger than the actual visible
square annotation. Changing the rectangle scales the dimension of the
visiblie square but also scales up the thickness of the transparent border.
So scaling a little rectangle to the size of the page also scales up the
difference between the bounding box of the appearance stream and the fill
operation in the appearance stream.

The other question was why after copying the annotation to a new file and
interacting with the annotation in Apple Preview does it suddenly change
appearance and become the correct size, but with a dashed border and loses
the fill color if the fill was semi-transparent? When Apple preview creates
an annotation it creates a copy of the annotation in an Apple specific
entry. My theory is that after I alter the rectangle and re-edit the new
PDF and interact with the annotation it sees that its copy and the basic
info in the annotation don't agree so decides it needs to recreate the
annotation based on the basic information in the annotation. However
transparency isn't really specified in the basic annotation information.
Transparency only comes from an ExtGState resource loaded by the appearance
stream. So when it recreates it doesn't know anything about the
transparency and creates it without transparency.

So it appears trying to copy and resize annotations that involve
transparency is going to be very problematic and would require a deep dive
into recreating the annotation.

On Mon, Dec 25, 2017 at 4:28 AM, Tilman Hausherr <TH...@t-online.de>
wrote:

> In PDFBox, either keep the source open and don't close it before saving
> your copy document; or use PDFCloneUtility.
>
> I suspect you mean the resources... these you could simply assign the
> resources from the old to the new, while creating an adjusted content
> stream.
>
> I also suggest you use the PDFDebugger app to look at what's really in
> your document.
>
> Tilman
>
>
> Am 25.12.2017 um 07:18 schrieb Dale King:
>
>> I am still trying to get this to work. I tried switching to iText library
>> and while initially getting better results with annotations, it still did
>> not work. I am coming to the conclusion that the primary issue is that if
>> I
>> copy an annotation from one document to another the problem is that the
>> annotation dictionary is a shallow copy. The annotation dictionary
>> references other objects that are not copied to the destination document.
>> So I am wondering if there is a simple way given a dictionary to do a deep
>> copy to another document?
>>
>> On Mon, Dec 4, 2017 at 4:44 PM, Dale King <da...@gmail.com> wrote:
>>
>> So what I was missing was that annotations can have their own content
>>> streams. This is going to be difficult. I know it is easier programming
>>> wise to add the annotations afterward, but usability wise it is easier to
>>> do it before hand.
>>>
>>> So to understand the problem more what my program is doing is it takes an
>>> input that looks like the input I showed you except that there are
>>> perhaps
>>> 20-30 pages like that that are a single line of music. My program builds
>>> another document with pages that are 8"x5" (to match my tablet that has a
>>> 16x10 aspect ratio). The program puts as many lines of music it can per
>>> page (and can actually put several short lines together horizontally.
>>>
>>> On Mon, Dec 4, 2017 at 2:11 PM, Tilman Hausherr <TH...@t-online.de>
>>> wrote:
>>>
>>> Am 04.12.2017 um 19:57 schrieb Dale King:
>>>>
>>>> OK that is really odd. I am on Mac and in preview the blue rectangle is
>>>>> not the same size as yours, but when I click on it it changes to a
>>>>> dashed
>>>>> black rectangle bordering the enter page and the blue goes away.
>>>>>
>>>>> Sorry, I don't speak PDF content streams to know what the content
>>>>> stream
>>>>> is telling me.
>>>>>
>>>>> In the PDF 32000 specification look for "operator summary". I'll
>>>> annotate
>>>> a few below.
>>>>
>>>> For what you want to do (I haven't understood all the words - I assume
>>>> you want to cover parts so that you see only one line of notes) it
>>>> would be
>>>> easier to create the annotations as new instead of copying them.
>>>>
>>>> Tilman
>>>>
>>>>
>>>> On Mon, Dec 4, 2017 at 1:34 PM, Tilman Hausherr <THausherr@t-online.de
>>>>> <ma...@t-online.de>> wrote:
>>>>>
>>>>>      Am 04.12.2017 um 18:42 schrieb Dale King:
>>>>>
>>>>>      I tried for a simpler goal, just take that annotation and
>>>>>>      translate it to cover the entire output page, but even that did
>>>>>>      not work as can be seen in the output pdf. Something is getting
>>>>>>      in the way and adding its own coordinate translation but I cannot
>>>>>>      figure out what.
>>>>>>
>>>>>>      The annotation of the target PDF does cover the entire page.
>>>>> Click
>>>>>      on the left border of the page in Adobe Reader and you'll see the
>>>>>      rectangle. However...
>>>>>
>>>>>      I suspect you're unhappy with the blue rectangle. This could be
>>>>>      because of the appearance stream which you took from the source
>>>>>      unchanged:
>>>>>
>>>>>
>>>>>      q
>>>>>      Q
>>>>>      q
>>>>>        7.044313E-5 4.893184E-6 112.2815 29.0435 re   <==== sets a
>>>>>      rectangle and clip
>>>>>        W
>>>>>        n
>>>>>        /Cs1 cs
>>>>>        0 0.3813631 0.9982447 sc  <==== color
>>>>>        /Gs1 gs
>>>>>        3.498857 3.498791 105.2839 22.04592 re <=== sets a rectangle and
>>>>>      fill
>>>>>        f
>>>>>        4.997579 w
>>>>>        2 J
>>>>>        [ 11.99758 18.99274 ] 1 d
>>>>>        /Cs1 CS
>>>>>        0 0 0 SC  <===== black
>>>>>        /Gs2 gs
>>>>>        q
>>>>>          1 0 0 1 -399.6912 -556.2903 cm
>>>>>          403.1903 559.7895 105.284 22.04594 re  <==== sets a rectangle
>>>>>      and stroke
>>>>>          S
>>>>>        Q
>>>>>      Q
>>>>>
>>>>>
>>>>>      Tilman
>>>>>
>>>>>
>>>>>
>>>>>
>>>>> --
>>>>> Dale King
>>>>>
>>>>>
>>>>
>>>>
>>> --
>>> Dale King
>>>
>>>
>>
>>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@pdfbox.apache.org
> For additional commands, e-mail: users-help@pdfbox.apache.org
>
>


-- 
Dale King

Re: Imposition with annotations

Posted by Tilman Hausherr <TH...@t-online.de>.
In PDFBox, either keep the source open and don't close it before saving 
your copy document; or use PDFCloneUtility.

I suspect you mean the resources... these you could simply assign the 
resources from the old to the new, while creating an adjusted content 
stream.

I also suggest you use the PDFDebugger app to look at what's really in 
your document.

Tilman

Am 25.12.2017 um 07:18 schrieb Dale King:
> I am still trying to get this to work. I tried switching to iText library
> and while initially getting better results with annotations, it still did
> not work. I am coming to the conclusion that the primary issue is that if I
> copy an annotation from one document to another the problem is that the
> annotation dictionary is a shallow copy. The annotation dictionary
> references other objects that are not copied to the destination document.
> So I am wondering if there is a simple way given a dictionary to do a deep
> copy to another document?
>
> On Mon, Dec 4, 2017 at 4:44 PM, Dale King <da...@gmail.com> wrote:
>
>> So what I was missing was that annotations can have their own content
>> streams. This is going to be difficult. I know it is easier programming
>> wise to add the annotations afterward, but usability wise it is easier to
>> do it before hand.
>>
>> So to understand the problem more what my program is doing is it takes an
>> input that looks like the input I showed you except that there are perhaps
>> 20-30 pages like that that are a single line of music. My program builds
>> another document with pages that are 8"x5" (to match my tablet that has a
>> 16x10 aspect ratio). The program puts as many lines of music it can per
>> page (and can actually put several short lines together horizontally.
>>
>> On Mon, Dec 4, 2017 at 2:11 PM, Tilman Hausherr <TH...@t-online.de>
>> wrote:
>>
>>> Am 04.12.2017 um 19:57 schrieb Dale King:
>>>
>>>> OK that is really odd. I am on Mac and in preview the blue rectangle is
>>>> not the same size as yours, but when I click on it it changes to a dashed
>>>> black rectangle bordering the enter page and the blue goes away.
>>>>
>>>> Sorry, I don't speak PDF content streams to know what the content stream
>>>> is telling me.
>>>>
>>> In the PDF 32000 specification look for "operator summary". I'll annotate
>>> a few below.
>>>
>>> For what you want to do (I haven't understood all the words - I assume
>>> you want to cover parts so that you see only one line of notes) it would be
>>> easier to create the annotations as new instead of copying them.
>>>
>>> Tilman
>>>
>>>
>>>> On Mon, Dec 4, 2017 at 1:34 PM, Tilman Hausherr <THausherr@t-online.de
>>>> <ma...@t-online.de>> wrote:
>>>>
>>>>      Am 04.12.2017 um 18:42 schrieb Dale King:
>>>>
>>>>>      I tried for a simpler goal, just take that annotation and
>>>>>      translate it to cover the entire output page, but even that did
>>>>>      not work as can be seen in the output pdf. Something is getting
>>>>>      in the way and adding its own coordinate translation but I cannot
>>>>>      figure out what.
>>>>>
>>>>      The annotation of the target PDF does cover the entire page. Click
>>>>      on the left border of the page in Adobe Reader and you'll see the
>>>>      rectangle. However...
>>>>
>>>>      I suspect you're unhappy with the blue rectangle. This could be
>>>>      because of the appearance stream which you took from the source
>>>>      unchanged:
>>>>
>>>>
>>>>      q
>>>>      Q
>>>>      q
>>>>        7.044313E-5 4.893184E-6 112.2815 29.0435 re   <==== sets a
>>>>      rectangle and clip
>>>>        W
>>>>        n
>>>>        /Cs1 cs
>>>>        0 0.3813631 0.9982447 sc  <==== color
>>>>        /Gs1 gs
>>>>        3.498857 3.498791 105.2839 22.04592 re <=== sets a rectangle and
>>>>      fill
>>>>        f
>>>>        4.997579 w
>>>>        2 J
>>>>        [ 11.99758 18.99274 ] 1 d
>>>>        /Cs1 CS
>>>>        0 0 0 SC  <===== black
>>>>        /Gs2 gs
>>>>        q
>>>>          1 0 0 1 -399.6912 -556.2903 cm
>>>>          403.1903 559.7895 105.284 22.04594 re  <==== sets a rectangle
>>>>      and stroke
>>>>          S
>>>>        Q
>>>>      Q
>>>>
>>>>
>>>>      Tilman
>>>>
>>>>
>>>>
>>>>
>>>> --
>>>> Dale King
>>>>
>>>
>>>
>>
>> --
>> Dale King
>>
>
>


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@pdfbox.apache.org
For additional commands, e-mail: users-help@pdfbox.apache.org


Re: Imposition with annotations

Posted by Dale King <da...@gmail.com>.
I am still trying to get this to work. I tried switching to iText library
and while initially getting better results with annotations, it still did
not work. I am coming to the conclusion that the primary issue is that if I
copy an annotation from one document to another the problem is that the
annotation dictionary is a shallow copy. The annotation dictionary
references other objects that are not copied to the destination document.
So I am wondering if there is a simple way given a dictionary to do a deep
copy to another document?

On Mon, Dec 4, 2017 at 4:44 PM, Dale King <da...@gmail.com> wrote:

> So what I was missing was that annotations can have their own content
> streams. This is going to be difficult. I know it is easier programming
> wise to add the annotations afterward, but usability wise it is easier to
> do it before hand.
>
> So to understand the problem more what my program is doing is it takes an
> input that looks like the input I showed you except that there are perhaps
> 20-30 pages like that that are a single line of music. My program builds
> another document with pages that are 8"x5" (to match my tablet that has a
> 16x10 aspect ratio). The program puts as many lines of music it can per
> page (and can actually put several short lines together horizontally.
>
> On Mon, Dec 4, 2017 at 2:11 PM, Tilman Hausherr <TH...@t-online.de>
> wrote:
>
>> Am 04.12.2017 um 19:57 schrieb Dale King:
>>
>>> OK that is really odd. I am on Mac and in preview the blue rectangle is
>>> not the same size as yours, but when I click on it it changes to a dashed
>>> black rectangle bordering the enter page and the blue goes away.
>>>
>>> Sorry, I don't speak PDF content streams to know what the content stream
>>> is telling me.
>>>
>>
>> In the PDF 32000 specification look for "operator summary". I'll annotate
>> a few below.
>>
>> For what you want to do (I haven't understood all the words - I assume
>> you want to cover parts so that you see only one line of notes) it would be
>> easier to create the annotations as new instead of copying them.
>>
>> Tilman
>>
>>
>>> On Mon, Dec 4, 2017 at 1:34 PM, Tilman Hausherr <THausherr@t-online.de
>>> <ma...@t-online.de>> wrote:
>>>
>>>     Am 04.12.2017 um 18:42 schrieb Dale King:
>>>
>>>>     I tried for a simpler goal, just take that annotation and
>>>>     translate it to cover the entire output page, but even that did
>>>>     not work as can be seen in the output pdf. Something is getting
>>>>     in the way and adding its own coordinate translation but I cannot
>>>>     figure out what.
>>>>
>>>
>>>     The annotation of the target PDF does cover the entire page. Click
>>>     on the left border of the page in Adobe Reader and you'll see the
>>>     rectangle. However...
>>>
>>>     I suspect you're unhappy with the blue rectangle. This could be
>>>     because of the appearance stream which you took from the source
>>>     unchanged:
>>>
>>>
>>>     q
>>>     Q
>>>     q
>>>       7.044313E-5 4.893184E-6 112.2815 29.0435 re   <==== sets a
>>>     rectangle and clip
>>>       W
>>>       n
>>>       /Cs1 cs
>>>       0 0.3813631 0.9982447 sc  <==== color
>>>       /Gs1 gs
>>>       3.498857 3.498791 105.2839 22.04592 re <=== sets a rectangle and
>>>     fill
>>>       f
>>>       4.997579 w
>>>       2 J
>>>       [ 11.99758 18.99274 ] 1 d
>>>       /Cs1 CS
>>>       0 0 0 SC  <===== black
>>>       /Gs2 gs
>>>       q
>>>         1 0 0 1 -399.6912 -556.2903 cm
>>>         403.1903 559.7895 105.284 22.04594 re  <==== sets a rectangle
>>>     and stroke
>>>         S
>>>       Q
>>>     Q
>>>
>>>
>>>     Tilman
>>>
>>>
>>>
>>>
>>> --
>>> Dale King
>>>
>>
>>
>>
>
>
> --
> Dale King
>



-- 
Dale King

Re: Imposition with annotations

Posted by Dale King <da...@gmail.com>.
So what I was missing was that annotations can have their own content
streams. This is going to be difficult. I know it is easier programming
wise to add the annotations afterward, but usability wise it is easier to
do it before hand.

So to understand the problem more what my program is doing is it takes an
input that looks like the input I showed you except that there are perhaps
20-30 pages like that that are a single line of music. My program builds
another document with pages that are 8"x5" (to match my tablet that has a
16x10 aspect ratio). The program puts as many lines of music it can per
page (and can actually put several short lines together horizontally.

On Mon, Dec 4, 2017 at 2:11 PM, Tilman Hausherr <TH...@t-online.de>
wrote:

> Am 04.12.2017 um 19:57 schrieb Dale King:
>
>> OK that is really odd. I am on Mac and in preview the blue rectangle is
>> not the same size as yours, but when I click on it it changes to a dashed
>> black rectangle bordering the enter page and the blue goes away.
>>
>> Sorry, I don't speak PDF content streams to know what the content stream
>> is telling me.
>>
>
> In the PDF 32000 specification look for "operator summary". I'll annotate
> a few below.
>
> For what you want to do (I haven't understood all the words - I assume you
> want to cover parts so that you see only one line of notes) it would be
> easier to create the annotations as new instead of copying them.
>
> Tilman
>
>
>> On Mon, Dec 4, 2017 at 1:34 PM, Tilman Hausherr <THausherr@t-online.de
>> <ma...@t-online.de>> wrote:
>>
>>     Am 04.12.2017 um 18:42 schrieb Dale King:
>>
>>>     I tried for a simpler goal, just take that annotation and
>>>     translate it to cover the entire output page, but even that did
>>>     not work as can be seen in the output pdf. Something is getting
>>>     in the way and adding its own coordinate translation but I cannot
>>>     figure out what.
>>>
>>
>>     The annotation of the target PDF does cover the entire page. Click
>>     on the left border of the page in Adobe Reader and you'll see the
>>     rectangle. However...
>>
>>     I suspect you're unhappy with the blue rectangle. This could be
>>     because of the appearance stream which you took from the source
>>     unchanged:
>>
>>
>>     q
>>     Q
>>     q
>>       7.044313E-5 4.893184E-6 112.2815 29.0435 re   <==== sets a
>>     rectangle and clip
>>       W
>>       n
>>       /Cs1 cs
>>       0 0.3813631 0.9982447 sc  <==== color
>>       /Gs1 gs
>>       3.498857 3.498791 105.2839 22.04592 re <=== sets a rectangle and
>>     fill
>>       f
>>       4.997579 w
>>       2 J
>>       [ 11.99758 18.99274 ] 1 d
>>       /Cs1 CS
>>       0 0 0 SC  <===== black
>>       /Gs2 gs
>>       q
>>         1 0 0 1 -399.6912 -556.2903 cm
>>         403.1903 559.7895 105.284 22.04594 re  <==== sets a rectangle
>>     and stroke
>>         S
>>       Q
>>     Q
>>
>>
>>     Tilman
>>
>>
>>
>>
>> --
>> Dale King
>>
>
>
>


-- 
Dale King

Re: Imposition with annotations

Posted by Tilman Hausherr <TH...@t-online.de>.
Am 04.12.2017 um 19:57 schrieb Dale King:
> OK that is really odd. I am on Mac and in preview the blue rectangle 
> is not the same size as yours, but when I click on it it changes to a 
> dashed black rectangle bordering the enter page and the blue goes away.
>
> Sorry, I don't speak PDF content streams to know what the content 
> stream is telling me.

In the PDF 32000 specification look for "operator summary". I'll 
annotate a few below.

For what you want to do (I haven't understood all the words - I assume 
you want to cover parts so that you see only one line of notes) it would 
be easier to create the annotations as new instead of copying them.

Tilman

>
> On Mon, Dec 4, 2017 at 1:34 PM, Tilman Hausherr <THausherr@t-online.de 
> <ma...@t-online.de>> wrote:
>
>     Am 04.12.2017 um 18:42 schrieb Dale King:
>>     I tried for a simpler goal, just take that annotation and
>>     translate it to cover the entire output page, but even that did
>>     not work as can be seen in the output pdf. Something is getting
>>     in the way and adding its own coordinate translation but I cannot
>>     figure out what.
>
>     The annotation of the target PDF does cover the entire page. Click
>     on the left border of the page in Adobe Reader and you'll see the
>     rectangle. However...
>
>     I suspect you're unhappy with the blue rectangle. This could be
>     because of the appearance stream which you took from the source
>     unchanged:
>
>
>     q
>     Q
>     q
>       7.044313E-5 4.893184E-6 112.2815 29.0435 re   <==== sets a
>     rectangle and clip
>       W
>       n
>       /Cs1 cs
>       0 0.3813631 0.9982447 sc  <==== color
>       /Gs1 gs
>       3.498857 3.498791 105.2839 22.04592 re <=== sets a rectangle and
>     fill
>       f
>       4.997579 w
>       2 J
>       [ 11.99758 18.99274 ] 1 d
>       /Cs1 CS
>       0 0 0 SC  <===== black
>       /Gs2 gs
>       q
>         1 0 0 1 -399.6912 -556.2903 cm
>         403.1903 559.7895 105.284 22.04594 re  <==== sets a rectangle
>     and stroke
>         S
>       Q
>     Q
>
>
>     Tilman
>
>
>
>
> -- 
> Dale King



Re: Imposition with annotations

Posted by Dale King <da...@gmail.com>.
OK that is really odd. I am on Mac and in preview the blue rectangle is not
the same size as yours, but when I click on it it changes to a dashed black
rectangle bordering the enter page and the blue goes away.

Sorry, I don't speak PDF content streams to know what the content stream is
telling me.

On Mon, Dec 4, 2017 at 1:34 PM, Tilman Hausherr <TH...@t-online.de>
wrote:

> Am 04.12.2017 um 18:42 schrieb Dale King:
>
> I tried for a simpler goal, just take that annotation and translate it to
> cover the entire output page, but even that did not work as can be seen in
> the output pdf. Something is getting in the way and adding its own
> coordinate translation but I cannot figure out what.
>
> The annotation of the target PDF does cover the entire page. Click on the
> left border of the page in Adobe Reader and you'll see the rectangle.
> However...
>
> I suspect you're unhappy with the blue rectangle. This could be because of
> the appearance stream which you took from the source unchanged:
>
>
> q
> Q
> q
>   7.044313E-5 4.893184E-6 112.2815 29.0435 re
>   W
>   n
>   /Cs1 cs
>   0 0.3813631 0.9982447 sc
>   /Gs1 gs
>   3.498857 3.498791 105.2839 22.04592 re
>   f
>   4.997579 w
>   2 J
>   [ 11.99758 18.99274 ] 1 d
>   /Cs1 CS
>   0 0 0 SC
>   /Gs2 gs
>   q
>     1 0 0 1 -399.6912 -556.2903 cm
>     403.1903 559.7895 105.284 22.04594 re
>     S
>   Q
> Q
>
>
> Tilman
>
>


-- 
Dale King

Re: Imposition with annotations

Posted by Tilman Hausherr <TH...@t-online.de>.
Am 04.12.2017 um 18:42 schrieb Dale King:
> I tried for a simpler goal, just take that annotation and translate it 
> to cover the entire output page, but even that did not work as can be 
> seen in the output pdf. Something is getting in the way and adding its 
> own coordinate translation but I cannot figure out what.

The annotation of the target PDF does cover the entire page. Click on 
the left border of the page in Adobe Reader and you'll see the 
rectangle. However...

I suspect you're unhappy with the blue rectangle. This could be because 
of the appearance stream which you took from the source unchanged:


q
Q
q
   7.044313E-5 4.893184E-6 112.2815 29.0435 re
   W
   n
   /Cs1 cs
   0 0.3813631 0.9982447 sc
   /Gs1 gs
   3.498857 3.498791 105.2839 22.04592 re
   f
   4.997579 w
   2 J
   [ 11.99758 18.99274 ] 1 d
   /Cs1 CS
   0 0 0 SC
   /Gs2 gs
   q
     1 0 0 1 -399.6912 -556.2903 cm
     403.1903 559.7895 105.284 22.04594 re
     S
   Q
Q


Tilman


Re: Imposition with annotations

Posted by Dale King <da...@gmail.com>.
Here is a link:
https://drive.google.com/open?id=1wyD9oyXV4YA0F8igxsomqRKM5OX2vqOT

On Mon, Dec 4, 2017 at 12:46 PM, Tilman Hausherr <TH...@t-online.de>
wrote:

> Am 04.12.2017 um 18:42 schrieb Dale King:
>
>> So I have attached an input PDF
>>
>
> Please upload this to a sharehoster, PDF attachments don't get through.
>
> Tilman
>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@pdfbox.apache.org
> For additional commands, e-mail: users-help@pdfbox.apache.org
>
>


-- 
Dale King

Re: Imposition with annotations

Posted by Tilman Hausherr <TH...@t-online.de>.
Am 04.12.2017 um 18:42 schrieb Dale King:
> So I have attached an input PDF 

Please upload this to a sharehoster, PDF attachments don't get through.

Tilman


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@pdfbox.apache.org
For additional commands, e-mail: users-help@pdfbox.apache.org


Re: Imposition with annotations

Posted by Dale King <da...@gmail.com>.
OK I now have an example to demonstrate the problem I am trying to solve.
First some background:

I am a bass player at my church and rather than use a music stand with
printed sheet music I use a tablet with a pedal to turn pages in a PDF
viewer. I used to try to crop out roughly tablet size chunks from the
original PDF of the music which worked for the most part, but due to where
page breaks landed in the original PDF it was not that great. I had one
song where literally it had a page break before a single measure with a
repeat so I had a page on my tablet with a single measure.

So I have been trying to get around the page break limitation. What I am
doing now is taking the original PDF, duplicating the pages and cropping
out the individual staves of the music. I duplicate and rearrange those
staves to get a linear forward only flow. Right now that is a manual
process, but I hope to automate that a bit more with PDFBox. Then I wrote
some software using PDFBox that takes those individual strips and lays them
out automatically to perfectly my tablet page size using imposition. That
all works.

Sometimes on a staff I need to remove some measures or highlight some
musical direction. To erase stuff I just put a white rectangle annotation
over it to hide it. It would be much more convenient to do this while they
are still strips instead of after being laid out since somtimes the layout
process can be an iterative process. But I have not been able to figure out
how to translate the annotation from the strips to the correct position on
the final page.

So I have attached an input PDF that has only one staff on it. I put a blue
rectangle over a couple of measures as a test. Below is a test program that
imposes that PDF on another page and tries to copy the annotation. Since I
could not come close to figuring out how to get it in the right place (and
I do completely understand matrices and coordinate transformations) I tried
for a simpler goal, just take that annotation and translate it to cover the
entire output page, but even that did not work as can be seen in the output
pdf. Something is getting in the way and adding its own coordinate
translation but I cannot figure out what.

Here is the sample code:

public class PdfTest
{
    // Pages are 8" x 5" for 1280 x 800 screen
    private static final float PAGE_WIDTH = 8f * 72f;
    private static final float PAGE_HEIGHT = 5f * 72f;

    public static void main(String[] args) throws Exception
    {
        PDDocument document = PDDocument.load(new File(args[0]));

        PDPage sourcePage = document.getPage(0);
        PDRectangle r = sourcePage.getCropBox();

        float maxWidth = r.getWidth();

        float scale = PAGE_WIDTH / maxWidth;

        PDDocument destinationDocument = new PDDocument();

        LayerUtility layerUtility = new LayerUtility(document);
        PDPage destinationPage = new PDPage(new
PDRectangle(PAGE_WIDTH, PAGE_HEIGHT));

        float scaledHeight = r.getHeight() * scale;

        float verticalGap = (PAGE_HEIGHT - scaledHeight) /  2;

        PDPageContentStream contents = new
PDPageContentStream(destinationDocument, destinationPage);
        contents.saveGraphicsState();

        contents.transform(Matrix.getTranslateInstance(0f, PAGE_HEIGHT
- verticalGap));
        contents.transform(Matrix.getScaleInstance(scale, scale));

        contents.transform(Matrix.getTranslateInstance(r.getLowerLeftX(),
r.getLowerLeftY() - r.getHeight()));
        contents.drawForm(layerUtility.importPageAsForm(document, 0));

        contents.restoreGraphicsState();

        PDAnnotationSquareCircle ann =
(PDAnnotationSquareCircle)sourcePage.getAnnotations().get(0);
        ann.setRectangle(destinationPage.getCropBox());
        destinationPage.getAnnotations().add(ann);

        contents.close();

        destinationDocument.addPage(destinationPage);

        destinationDocument.save("output.pdf");
    }
}


On Sat, Nov 18, 2017 at 2:23 PM, Tilman Hausherr <TH...@t-online.de>
wrote:

> I could have a look if you share the files and the code segment.
>
> Alternatively grab the source code and have a look at
> PDVisibleSignDesigner.java . While there's probably nothing to copy 1:1 as
> a solution, the code in adjustForRotation() might provide some inspiration.
>
> Tilman
>
>
> Am 18.11.2017 um 19:10 schrieb Dale King:
>
>> Still having no luck trying to figure out translating coordinates for the
>> copied annotations. I an create a new annotation and add it and it goes
>> where I want it, but the copied one seems to have some other transform
>> applied to it and I cannot figure out where that Matrix is coming from.
>> Setting the same rectangle on and annotation that I create vs. one that I
>> copy do not place it in the same place.
>>
>> On Wed, Nov 15, 2017 at 8:50 PM, Dale King <da...@gmail.com> wrote:
>>
>> First off, in my case the annotations are not widgets, so the if is not
>>> necessary. The annotations I am most interested in are rectangles to
>>> either
>>> highlight or white to block out content visually.
>>>
>>> But removing the if still did not allow it to work because I think I need
>>> to have the annotation take into account the matrix transformations
>>> applied
>>> at the time of adding the page. The annotations have rectangle relative
>>> to
>>> the original page, which and not relative to the transformed page. Looks
>>> like it will be a bit of work to track the many matrix transformations
>>> applied and reversed with restoring graphics state but it is doable.
>>>
>>> I will try that and see if it works
>>>
>>> On Wed, Nov 15, 2017 at 2:11 PM, Tilman Hausherr <TH...@t-online.de>
>>> wrote:
>>>
>>> Please try this and tell if it works as wished. It copies all annotations
>>>> except those from Acroform.
>>>>
>>>> List<PDAnnotation> annotations = page.getAnnotations();
>>>> for (PDAnnotation ann : doc.getPage(sourcePage - 1).getAnnotations())
>>>> {
>>>>      if (ann instanceof PDAnnotationWidget)
>>>>      {
>>>>           annotations.add(ann);
>>>>      }
>>>> }
>>>>
>>>> Tilman
>>>>
>>>> Am 15.11.2017 um 00:47 schrieb Dale King:
>>>>
>>>> I am doing PDF imposition following the SuperImpose example (
>>>>> https://svn.apache.org/viewvc/pdfbox/trunk/examples/src/main
>>>>> /java/org/apache/pdfbox/examples/pdmodel/SuperimposePage.jav
>>>>> a?view=markup)
>>>>> and the content is appearing. What doesn't appear on the superimposed
>>>>> page
>>>>> however are the annotations on the original page.
>>>>>
>>>>> Is it possible to do superimpostion including the annotations?
>>>>>
>>>>>
>>>>> ---------------------------------------------------------------------
>>>> To unsubscribe, e-mail: users-unsubscribe@pdfbox.apache.org
>>>> For additional commands, e-mail: users-help@pdfbox.apache.org
>>>>
>>>>
>>>>
>>> --
>>> Dale King
>>>
>>>
>>
>>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@pdfbox.apache.org
> For additional commands, e-mail: users-help@pdfbox.apache.org
>
>


-- 
Dale King

Re: Imposition with annotations

Posted by Tilman Hausherr <TH...@t-online.de>.
I could have a look if you share the files and the code segment.

Alternatively grab the source code and have a look at 
PDVisibleSignDesigner.java . While there's probably nothing to copy 1:1 
as a solution, the code in adjustForRotation() might provide some 
inspiration.

Tilman

Am 18.11.2017 um 19:10 schrieb Dale King:
> Still having no luck trying to figure out translating coordinates for the
> copied annotations. I an create a new annotation and add it and it goes
> where I want it, but the copied one seems to have some other transform
> applied to it and I cannot figure out where that Matrix is coming from.
> Setting the same rectangle on and annotation that I create vs. one that I
> copy do not place it in the same place.
>
> On Wed, Nov 15, 2017 at 8:50 PM, Dale King <da...@gmail.com> wrote:
>
>> First off, in my case the annotations are not widgets, so the if is not
>> necessary. The annotations I am most interested in are rectangles to either
>> highlight or white to block out content visually.
>>
>> But removing the if still did not allow it to work because I think I need
>> to have the annotation take into account the matrix transformations applied
>> at the time of adding the page. The annotations have rectangle relative to
>> the original page, which and not relative to the transformed page. Looks
>> like it will be a bit of work to track the many matrix transformations
>> applied and reversed with restoring graphics state but it is doable.
>>
>> I will try that and see if it works
>>
>> On Wed, Nov 15, 2017 at 2:11 PM, Tilman Hausherr <TH...@t-online.de>
>> wrote:
>>
>>> Please try this and tell if it works as wished. It copies all annotations
>>> except those from Acroform.
>>>
>>> List<PDAnnotation> annotations = page.getAnnotations();
>>> for (PDAnnotation ann : doc.getPage(sourcePage - 1).getAnnotations())
>>> {
>>>      if (ann instanceof PDAnnotationWidget)
>>>      {
>>>           annotations.add(ann);
>>>      }
>>> }
>>>
>>> Tilman
>>>
>>> Am 15.11.2017 um 00:47 schrieb Dale King:
>>>
>>>> I am doing PDF imposition following the SuperImpose example (
>>>> https://svn.apache.org/viewvc/pdfbox/trunk/examples/src/main
>>>> /java/org/apache/pdfbox/examples/pdmodel/SuperimposePage.jav
>>>> a?view=markup)
>>>> and the content is appearing. What doesn't appear on the superimposed
>>>> page
>>>> however are the annotations on the original page.
>>>>
>>>> Is it possible to do superimpostion including the annotations?
>>>>
>>>>
>>> ---------------------------------------------------------------------
>>> To unsubscribe, e-mail: users-unsubscribe@pdfbox.apache.org
>>> For additional commands, e-mail: users-help@pdfbox.apache.org
>>>
>>>
>>
>> --
>> Dale King
>>
>
>


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@pdfbox.apache.org
For additional commands, e-mail: users-help@pdfbox.apache.org


Re: Imposition with annotations

Posted by Dale King <da...@gmail.com>.
Still having no luck trying to figure out translating coordinates for the
copied annotations. I an create a new annotation and add it and it goes
where I want it, but the copied one seems to have some other transform
applied to it and I cannot figure out where that Matrix is coming from.
Setting the same rectangle on and annotation that I create vs. one that I
copy do not place it in the same place.

On Wed, Nov 15, 2017 at 8:50 PM, Dale King <da...@gmail.com> wrote:

> First off, in my case the annotations are not widgets, so the if is not
> necessary. The annotations I am most interested in are rectangles to either
> highlight or white to block out content visually.
>
> But removing the if still did not allow it to work because I think I need
> to have the annotation take into account the matrix transformations applied
> at the time of adding the page. The annotations have rectangle relative to
> the original page, which and not relative to the transformed page. Looks
> like it will be a bit of work to track the many matrix transformations
> applied and reversed with restoring graphics state but it is doable.
>
> I will try that and see if it works
>
> On Wed, Nov 15, 2017 at 2:11 PM, Tilman Hausherr <TH...@t-online.de>
> wrote:
>
>> Please try this and tell if it works as wished. It copies all annotations
>> except those from Acroform.
>>
>> List<PDAnnotation> annotations = page.getAnnotations();
>> for (PDAnnotation ann : doc.getPage(sourcePage - 1).getAnnotations())
>> {
>>     if (ann instanceof PDAnnotationWidget)
>>     {
>>          annotations.add(ann);
>>     }
>> }
>>
>> Tilman
>>
>> Am 15.11.2017 um 00:47 schrieb Dale King:
>>
>>> I am doing PDF imposition following the SuperImpose example (
>>> https://svn.apache.org/viewvc/pdfbox/trunk/examples/src/main
>>> /java/org/apache/pdfbox/examples/pdmodel/SuperimposePage.jav
>>> a?view=markup)
>>> and the content is appearing. What doesn't appear on the superimposed
>>> page
>>> however are the annotations on the original page.
>>>
>>> Is it possible to do superimpostion including the annotations?
>>>
>>>
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: users-unsubscribe@pdfbox.apache.org
>> For additional commands, e-mail: users-help@pdfbox.apache.org
>>
>>
>
>
> --
> Dale King
>



-- 
Dale King

Re: Imposition with annotations

Posted by Dale King <da...@gmail.com>.
First off, in my case the annotations are not widgets, so the if is not
necessary. The annotations I am most interested in are rectangles to either
highlight or white to block out content visually.

But removing the if still did not allow it to work because I think I need
to have the annotation take into account the matrix transformations applied
at the time of adding the page. The annotations have rectangle relative to
the original page, which and not relative to the transformed page. Looks
like it will be a bit of work to track the many matrix transformations
applied and reversed with restoring graphics state but it is doable.

I will try that and see if it works

On Wed, Nov 15, 2017 at 2:11 PM, Tilman Hausherr <TH...@t-online.de>
wrote:

> Please try this and tell if it works as wished. It copies all annotations
> except those from Acroform.
>
> List<PDAnnotation> annotations = page.getAnnotations();
> for (PDAnnotation ann : doc.getPage(sourcePage - 1).getAnnotations())
> {
>     if (ann instanceof PDAnnotationWidget)
>     {
>          annotations.add(ann);
>     }
> }
>
> Tilman
>
> Am 15.11.2017 um 00:47 schrieb Dale King:
>
>> I am doing PDF imposition following the SuperImpose example (
>> https://svn.apache.org/viewvc/pdfbox/trunk/examples/src/main
>> /java/org/apache/pdfbox/examples/pdmodel/SuperimposePage.java?view=markup
>> )
>> and the content is appearing. What doesn't appear on the superimposed page
>> however are the annotations on the original page.
>>
>> Is it possible to do superimpostion including the annotations?
>>
>>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@pdfbox.apache.org
> For additional commands, e-mail: users-help@pdfbox.apache.org
>
>


-- 
Dale King

Re: Imposition with annotations

Posted by Tilman Hausherr <TH...@t-online.de>.
Please try this and tell if it works as wished. It copies all 
annotations except those from Acroform.

List<PDAnnotation> annotations = page.getAnnotations();
for (PDAnnotation ann : doc.getPage(sourcePage - 1).getAnnotations())
{
     if (ann instanceof PDAnnotationWidget)
     {
          annotations.add(ann);
     }
}

Tilman

Am 15.11.2017 um 00:47 schrieb Dale King:
> I am doing PDF imposition following the SuperImpose example (
> https://svn.apache.org/viewvc/pdfbox/trunk/examples/src/main/java/org/apache/pdfbox/examples/pdmodel/SuperimposePage.java?view=markup)
> and the content is appearing. What doesn't appear on the superimposed page
> however are the annotations on the original page.
>
> Is it possible to do superimpostion including the annotations?
>


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@pdfbox.apache.org
For additional commands, e-mail: users-help@pdfbox.apache.org