You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@pdfbox.apache.org by Olivier Cailloux <ol...@gmail.com> on 2017/07/30 19:58:52 UTC
Avoid losing data on PDF read / write
I built a simple GUI for writing outlines to PDF files. The GUI only
permits to edit simple outlines: trees of bookmarks that each point to a
page in the document. (So, for example, other kind of actions triggered
by bookmarks is not supported.)
Now I would like to know, when I read a PDF file, if the outline it
contains has more information than I am able to store and display and
write back. (If so, I’d like to at least warn the user that overwriting
her file with my software after editing the outline might cause
information loss.) In particular, I’d like to be able to read back PDF
files whose outline have been written with my very software, as this is
safe.
Thus, my question is: can I ensure that a given PDDocumentOutline
contains only a simple outline (as defined above), and no other information?
Currently, given a PDDocument current and PDDocumentOutline pdOutline, I
get an Iterable<PDOutlineItem> children = pdOutline.children(), then for
each PDOutlineItem child I use child.findDestinationPage(current) (where
current is the document I am processing). If findDestinationPage returns
null I know I am facing a non-simple outline. This goes on recursively.
Assuming this procedure never returns null on any findDestinationPage
call, can I deduce that the document outline is simple (as defined above)?
Olivier
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@pdfbox.apache.org
For additional commands, e-mail: users-help@pdfbox.apache.org
Re: Avoid losing data on PDF read / write
Posted by Olivier Cailloux <ol...@gmail.com>.
Thank you for your answer. Actually I was hoping to be able to get along
without having to delve into the specs. This would probably require a
huge time.
The raw dictionary seems like a good hint. I am thinking it is perhaps
easy, once I get it, for me to look for some specific kinds of things in
order to find out if some actions (or other features) in that
PDDocumentOutline come in supplement to the simple destination page I
care about? I suppose (or I hope) that the "kinds of things" I need to
hunt for are not so numerous. This, even though I have no doubt that
supporting fully the whole range of features available for outlines in
PDF would be very difficult. As I am only looking for a binary, yes/no
answer, maybe the solution is simple. (But maybe I’m overly optimistic.)
If it’s not easy to summarize it for me, then never mind. I understand.
Olivier
Le 01/08/2017 à 22:50, Tilman Hausherr a écrit :
> I recommend a deep look at the PDF specification. Sadly there are so
> many features everywhere. An outline may have Dest or A, but also more
> elements. And the actions are also complex... You can get the raw
> dictionary with getCOSObject().
>
> Tilman
>
> Am 30.07.2017 um 21:58 schrieb Olivier Cailloux:
>> I built a simple GUI for writing outlines to PDF files. The GUI only
>> permits to edit simple outlines: trees of bookmarks that each point
>> to a page in the document. (So, for example, other kind of actions
>> triggered by bookmarks is not supported.)
>>
>> Now I would like to know, when I read a PDF file, if the outline it
>> contains has more information than I am able to store and display and
>> write back. (If so, I’d like to at least warn the user that
>> overwriting her file with my software after editing the outline might
>> cause information loss.) In particular, I’d like to be able to read
>> back PDF files whose outline have been written with my very software,
>> as this is safe.
>>
>> Thus, my question is: can I ensure that a given PDDocumentOutline
>> contains only a simple outline (as defined above), and no other
>> information?
>>
>> Currently, given a PDDocument current and PDDocumentOutline
>> pdOutline, I get an Iterable<PDOutlineItem> children =
>> pdOutline.children(), then for each PDOutlineItem child I use
>> child.findDestinationPage(current) (where current is the document I
>> am processing). If findDestinationPage returns null I know I am
>> facing a non-simple outline. This goes on recursively.
>>
>> Assuming this procedure never returns null on any findDestinationPage
>> call, can I deduce that the document outline is simple (as defined
>> above)?
>>
>> Olivier
>>
>>
>>
>>
>> ---------------------------------------------------------------------
>> 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
>
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@pdfbox.apache.org
For additional commands, e-mail: users-help@pdfbox.apache.org
Re: Avoid losing data on PDF read / write
Posted by Tilman Hausherr <TH...@t-online.de>.
I recommend a deep look at the PDF specification. Sadly there are so
many features everywhere. An outline may have Dest or A, but also more
elements. And the actions are also complex... You can get the raw
dictionary with getCOSObject().
Tilman
Am 30.07.2017 um 21:58 schrieb Olivier Cailloux:
> I built a simple GUI for writing outlines to PDF files. The GUI only
> permits to edit simple outlines: trees of bookmarks that each point to
> a page in the document. (So, for example, other kind of actions
> triggered by bookmarks is not supported.)
>
> Now I would like to know, when I read a PDF file, if the outline it
> contains has more information than I am able to store and display and
> write back. (If so, I’d like to at least warn the user that
> overwriting her file with my software after editing the outline might
> cause information loss.) In particular, I’d like to be able to read
> back PDF files whose outline have been written with my very software,
> as this is safe.
>
> Thus, my question is: can I ensure that a given PDDocumentOutline
> contains only a simple outline (as defined above), and no other
> information?
>
> Currently, given a PDDocument current and PDDocumentOutline pdOutline,
> I get an Iterable<PDOutlineItem> children = pdOutline.children(), then
> for each PDOutlineItem child I use child.findDestinationPage(current)
> (where current is the document I am processing). If
> findDestinationPage returns null I know I am facing a non-simple
> outline. This goes on recursively.
>
> Assuming this procedure never returns null on any findDestinationPage
> call, can I deduce that the document outline is simple (as defined
> above)?
>
> Olivier
>
>
>
>
> ---------------------------------------------------------------------
> 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