Am 15.12.2018 um 21:32 schrieb Michel Cozzolino:
Ciao Tilman,

while waiting for a "lorem ipsum" pdf (..still waiting...) I've resolved
the problem using findDestinationPage (below is the code).
the strange is that both methods current.action  and current.destination
give null.
By exploring the pdf with PDFDebbugger as per your suggestions online, I
see actionGoto set on bookmarks.
Moreover the PDF has been created as an Arbortext export to pdf.
What do u think, could it be possible the pdf is malformed?  (unfortunately
I don't have the permit to share it as it contains confidential infos)
Many thanks

here is my code (Kotlin):

val file = File("/home/miki/a/cover.pdf")
val document = PDDocument.load(file)

val outline = document.documentCatalog.documentOutline

val current = outline.firstChild.firstChild.nextSibling   // testing
bookmark of para 2.1

                                 println( current.getTitle())


//val gta = current.action as PDActionGoTo        // is null

//val pd = current.destination as PDPageDestination   //is null too


I don't know that language, but is "current.action as PDActionGoTo" a cast that returns null if it fails? Then you would never know if one of the two is not null, but the cast fails.

I looked at findDestinationPage(). It could be that your destination is not a PDPageDestination but a PDNamedDestination. See the source code of findDestinationPage().

However all this means that I the example code should be improved to include named destinations.

Tilman





val pd = current.findDestinationPage(document) //as PDPageDestination


val allpages = document.getDocumentCatalog().pages
var pageNumber = allpages.indexOf(pd)+1


println("Destination page: " + pageNumber )

document.close()



On Tue, 27 Nov 2018 at 16:35, Michel Cozzolino <[email protected]>
wrote:

Ciao Tilman,

as it's a reserved document, I've asked them to get a sort of "lorem
ipsum" pdf built in the very same manner that can be shared with the pdfbox
community.
Still waiting for it. As I get the file I'll share it with you.
Many thanks for your availability.
ciao

Michele


On Sun, 25 Nov 2018 at 11:33, Tilman Hausherr <[email protected]>
wrote:

Hi,
please upload the PDF somewhere. Most attachments are not allowed here.
Tilman

Am 25.11.2018 um 11:14 schrieb Michel Cozzolino:
Hi,
I'm a newbie on PDFBOX. I've to extract bookmarks and relevant
destination pages from customer generated pdfs. All the pdf files have
the very same structure.
Opening such pdf in a pdf reader I see the bookmarks with pages.


image.png

But looking for page-destination in both PageDestination and
ActionGoto modes, results in error. In fact both the following "if"
statements result false:
(Kotlin code)
val document: /PDDocument/= load(file)val outline:/PDDocumentOutline!/
= document.documentCatalog.documentOutline var current: PDOutlineItem? =
outline.firstChild if
(current.destination is PDPageDestination) --> results _false_ if
(current.action is PDActionGoTo) --> results _false_ too
current.title --> results the _correct_ value
what am I doing wrong? Is there other way pdf store bookmark page
destinations?
Is there a way to analyse the structure of the "current" object?
Thanks for help!

Michele




---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to