pdfbox-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Dale King <dalewk...@gmail.com>
Subject Re: Imposition with annotations
Date Wed, 27 Dec 2017 00:12:35 GMT
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 <THausherr@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 <dalewking@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
>>>>> <mailto:THausherr@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

Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message