You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@pdfbox.apache.org by ho...@tlcc.com on 2016/12/01 20:00:04 UTC
question on getting location of bookmark
I want to find the x,y position of a bookmark in the pdf to be able to
insert an image at that location.
I can get the bookmark with the code below and looping through to find the
one I need with getTitle....
PDOutlineItem current = outline.getFirstChild();
But, how would I use PDOutlineItem to get the page/location to pass as the
x,y coordinates in contentStream.drawImage(img, 100, 100);
thanks,
Howard
Re: question on getting location of bookmark
Posted by Tilman Hausherr <TH...@t-online.de>.
Am 01.12.2016 um 22:28 schrieb howardg@tlcc.com:
> Sorry for not getting this but I don't understand how I would insert an
> image without getting the left coordinate?
Choose a coordinate yourself.
The problem is that you expected that a bookmark would always point to a
specific location. It ain't so. See in page 366 "Table 151 Destination
syntax" of the PDF 32000 Specification.
https://www.adobe.com/content/dam/Adobe/en/devnet/acrobat/pdfs/PDF32000_2008.pdf
Tilman
>
>
> Howard
>
>
> From: Tilman Hausherr <TH...@t-online.de>
> To: users@pdfbox.apache.org
> Date: 12/01/2016 04:24 PM
> Subject: Re: question on getting location of bookmark
>
>
>
> Am 01.12.2016 um 22:08 schrieb howardg@tlcc.com:
>> thanks, I changed my code as shown below. However I can't cast the
>> destination to the PDPageXYZDestination and it appears that it is a
>> PDPageFitWidthDestination class. This class does not have the getLeft()
>> and the page number returns -1????
> That is the /FitH destination:
>
> "Display the page designated by page, with the vertical coordinate top
> positioned at the top edge of the window and the contents of the page
> magnified just enough to fit the entire width of the page within the
> window. A null value for top specifies that the current value of that
> parameter shall be retained unchanged."
>
> Re the page number -1:
>
> /**
> * This will get the page number for this destination. A page
> destination can either reference a
> * page (for a local destination) or a page number (when doing a
> remote destination to another
> * PDF). If this object is referencing by page number then this
> method will return that number,
> * otherwise -1 will be returned.
> *
> * @return The zero-based page number for this destination.
> */
> public int getPageNumber()
>
>
> That you don't get a page number is because numbers are only for
> external destinations. If you want a local page, use getPage(). This
> will return a PDPage object. To get its number, go
> PDDocument.getPages().indexOf(PDPage).
>
> Tilman
>
>
>>
>> PDDocumentOutline outline = pdfDoc
>> .getDocumentCatalog().getDocumentOutline();
>> if (outline != null) {
>> debugMsg2("found outline");
>> PDOutlineItem current =
>> outline.getFirstChild();
>> while (current != null) {
>> debugMsg2
>> (current.getTitle());
>> if ("Image"
>> .equalsIgnoreCase(current.getTitle())) {
>> PDActionGoTo
>> action = (PDActionGoTo) current.getAction();
>> if (action !=
> null
>> ) {
>> PDPageFitWidthDestination dest = (PDPageFitWidthDestination)
>> action.getDestination();
>> if
> (dest
>> != null) {
>> //
>> debugMsg2("left: " + dest.getLeft());
>>
>> debugMsg2("top: " + dest.getTop());
>>
>> debugMsg2("page: " + dest.getPageNumber());
>> } else
> {
>> debugMsg2("dest is null");
>> }
>> } else {
>> debugMsg2(
>> "action is null");
>> }
>> current =
>> current.getNextSibling();
>> }
>>
>> }
>>
>> } else {
>> debugMsg2("This document does
> not
>> contain any bookmarks");
>> }
>>
>>
>> Howard
>> Howard Greenberg, CPA, CISA
>> IBM Certified Application Developer/Instructor - IBM Notes and Domino
>> The Learning Continuum Company, Ltd.
>> 888-241-8522 or 561-953-0096
>> http://www.tlcc.com
>> mailto:howardg@tlcc.com
>>
>>
>>
>> From: Tilman Hausherr <TH...@t-online.de>
>> To: users@pdfbox.apache.org
>> Date: 12/01/2016 03:49 PM
>> Subject: Re: question on getting location of bookmark
>>
>>
>>
>> Am 01.12.2016 um 21:38 schrieb howardg@tlcc.com:
>>> thanks, I am missing something... My code uses getDestination() and
>>> recasts as PDPageXYZDestination. However, the dest is null. I must be
>>> missing something?
>> There's anther possibilty, that there is an /A entry, i.e. an action.
>> Call getAction(). There are 13 different types of actions, but I'd
>> expect PDActionGoTo. On that one you can again call getDestination().
>>
>> Tilman
>>
>>
>>> PDDocumentOutline outline = pdfDoc
>>> .getDocumentCatalog().getDocumentOutline();
>>> if( outline != null ){
>>> debugMsg2("found outline");
>>> PDOutlineItem current =
>>> outline.getFirstChild();
>>> while( current != null ) {
>>> debugMsg2( current.getTitle()
>> );
>>> if ("Image"
>>> .equalsIgnoreCase(current.getTitle())){
>>> PDPageXYZDestination
>> dest
>>> = (PDPageXYZDestination) current.getDestination();
>>> if (dest!=null){
>>> debugMsg2("left: "
>>> + dest.getLeft());
>>> debugMsg2("top:
>> "
>>> + dest.getTop());
>>> debugMsg2("page: "
>>> + dest.getPageNumber());
>>> } else {
>>> debugMsg2("dest
>> is
>>> null");
>>> }
>>> }
>>> current =
>>> current.getNextSibling();
>>> }
>>>
>>>
>>> } else {
>>> debugMsg2( "This document does not
>> contain
>>> any bookmarks" );
>>> }
>>>
>>>
>>> Howard
>>> Howard Greenberg, CPA, CISA
>>> IBM Certified Application Developer/Instructor - IBM Notes and Domino
>>> The Learning Continuum Company, Ltd.
>>> 888-241-8522 or 561-953-0096
>>> http://www.tlcc.com
>>> mailto:howardg@tlcc.com
>>>
>>>
>>>
>>> From: Tilman Hausherr <TH...@t-online.de>
>>> To: users@pdfbox.apache.org
>>> Date: 12/01/2016 03:15 PM
>>> Subject: Re: question on getting location of bookmark
>>>
>>>
>>>
>>> Am 01.12.2016 um 21:12 schrieb howardg@tlcc.com:
>>>> thanks, can you elaborate? The API doc for getDestination shows that
>>>> returns PDDestination and I don't see any methods that return the
>>>> coordinates?
>>> There are 7 derived classes. That's why I mentioned that there are
>>> several types. For example, PDPageXYZDestination has a getLeft() and
>>> getTop() method. But not all of the derived classes have coordinates
>>> like that.
>>>
>>> Tilman
>>>
>>>> Howard
>>>> Howard Greenberg, CPA, CISA
>>>> IBM Certified Application Developer/Instructor - IBM Notes and Domino
>>>> The Learning Continuum Company, Ltd.
>>>> 888-241-8522 or 561-953-0096
>>>> http://www.tlcc.com
>>>> mailto:howardg@tlcc.com
>>>>
>>>>
>>>>
>>>> From: Tilman Hausherr <TH...@t-online.de>
>>>> To: users@pdfbox.apache.org
>>>> Date: 12/01/2016 03:03 PM
>>>> Subject: Re: question on getting location of bookmark
>>>>
>>>>
>>>>
>>>> Am 01.12.2016 um 21:00 schrieb howardg@tlcc.com:
>>>>> I want to find the x,y position of a bookmark in the pdf to be able
> to
>>>>> insert an image at that location.
>>>>>
>>>>> I can get the bookmark with the code below and looping through to
> find
>>>> the
>>>>> one I need with getTitle....
>>>>> PDOutlineItem current = outline.getFirstChild();
>>>>>
>>>>> But, how would I use PDOutlineItem to get the page/location to pass
> as
>>>> the
>>>>> x,y coordinates in contentStream.drawImage(img, 100, 100);
>>>> call getDestnation(). There are several types, and some of them have
>>>> coordinates.
>>>>
>>>> ---------------------------------------------------------------------
>>>> 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
>>
>>
>>
>>
>
> ---------------------------------------------------------------------
> 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: question on getting location of bookmark
Posted by ho...@tlcc.com.
Sorry for not getting this but I don't understand how I would insert an
image without getting the left coordinate?
Howard
From: Tilman Hausherr <TH...@t-online.de>
To: users@pdfbox.apache.org
Date: 12/01/2016 04:24 PM
Subject: Re: question on getting location of bookmark
Am 01.12.2016 um 22:08 schrieb howardg@tlcc.com:
> thanks, I changed my code as shown below. However I can't cast the
> destination to the PDPageXYZDestination and it appears that it is a
> PDPageFitWidthDestination class. This class does not have the getLeft()
> and the page number returns -1????
That is the /FitH destination:
"Display the page designated by page, with the vertical coordinate top
positioned at the top edge of the window and the contents of the page
magnified just enough to fit the entire width of the page within the
window. A null value for top specifies that the current value of that
parameter shall be retained unchanged."
Re the page number -1:
/**
* This will get the page number for this destination. A page
destination can either reference a
* page (for a local destination) or a page number (when doing a
remote destination to another
* PDF). If this object is referencing by page number then this
method will return that number,
* otherwise -1 will be returned.
*
* @return The zero-based page number for this destination.
*/
public int getPageNumber()
That you don't get a page number is because numbers are only for
external destinations. If you want a local page, use getPage(). This
will return a PDPage object. To get its number, go
PDDocument.getPages().indexOf(PDPage).
Tilman
>
>
> PDDocumentOutline outline = pdfDoc
> .getDocumentCatalog().getDocumentOutline();
> if (outline != null) {
> debugMsg2("found outline");
> PDOutlineItem current =
> outline.getFirstChild();
> while (current != null) {
> debugMsg2
> (current.getTitle());
> if ("Image"
> .equalsIgnoreCase(current.getTitle())) {
> PDActionGoTo
> action = (PDActionGoTo) current.getAction();
> if (action !=
null
> ) {
> PDPageFitWidthDestination dest = (PDPageFitWidthDestination)
> action.getDestination();
> if
(dest
> != null) {
> //
> debugMsg2("left: " + dest.getLeft());
>
> debugMsg2("top: " + dest.getTop());
>
> debugMsg2("page: " + dest.getPageNumber());
> } else
{
>
> debugMsg2("dest is null");
> }
> } else {
> debugMsg2(
> "action is null");
> }
> current =
> current.getNextSibling();
> }
>
> }
>
> } else {
> debugMsg2("This document does
not
> contain any bookmarks");
> }
>
>
> Howard
> Howard Greenberg, CPA, CISA
> IBM Certified Application Developer/Instructor - IBM Notes and Domino
> The Learning Continuum Company, Ltd.
> 888-241-8522 or 561-953-0096
> http://www.tlcc.com
> mailto:howardg@tlcc.com
>
>
>
> From: Tilman Hausherr <TH...@t-online.de>
> To: users@pdfbox.apache.org
> Date: 12/01/2016 03:49 PM
> Subject: Re: question on getting location of bookmark
>
>
>
> Am 01.12.2016 um 21:38 schrieb howardg@tlcc.com:
>> thanks, I am missing something... My code uses getDestination() and
>> recasts as PDPageXYZDestination. However, the dest is null. I must be
>> missing something?
> There's anther possibilty, that there is an /A entry, i.e. an action.
> Call getAction(). There are 13 different types of actions, but I'd
> expect PDActionGoTo. On that one you can again call getDestination().
>
> Tilman
>
>
>> PDDocumentOutline outline = pdfDoc
>> .getDocumentCatalog().getDocumentOutline();
>> if( outline != null ){
>> debugMsg2("found outline");
>> PDOutlineItem current =
>> outline.getFirstChild();
>> while( current != null ) {
>> debugMsg2( current.getTitle()
> );
>> if ("Image"
>> .equalsIgnoreCase(current.getTitle())){
>> PDPageXYZDestination
> dest
>> = (PDPageXYZDestination) current.getDestination();
>> if (dest!=null){
>> debugMsg2("left: "
>> + dest.getLeft());
>> debugMsg2("top:
> "
>> + dest.getTop());
>> debugMsg2("page: "
>> + dest.getPageNumber());
>> } else {
>> debugMsg2("dest
> is
>> null");
>> }
>> }
>> current =
>> current.getNextSibling();
>> }
>>
>>
>> } else {
>> debugMsg2( "This document does not
> contain
>> any bookmarks" );
>> }
>>
>>
>> Howard
>> Howard Greenberg, CPA, CISA
>> IBM Certified Application Developer/Instructor - IBM Notes and Domino
>> The Learning Continuum Company, Ltd.
>> 888-241-8522 or 561-953-0096
>> http://www.tlcc.com
>> mailto:howardg@tlcc.com
>>
>>
>>
>> From: Tilman Hausherr <TH...@t-online.de>
>> To: users@pdfbox.apache.org
>> Date: 12/01/2016 03:15 PM
>> Subject: Re: question on getting location of bookmark
>>
>>
>>
>> Am 01.12.2016 um 21:12 schrieb howardg@tlcc.com:
>>> thanks, can you elaborate? The API doc for getDestination shows that
>>> returns PDDestination and I don't see any methods that return the
>>> coordinates?
>> There are 7 derived classes. That's why I mentioned that there are
>> several types. For example, PDPageXYZDestination has a getLeft() and
>> getTop() method. But not all of the derived classes have coordinates
>> like that.
>>
>> Tilman
>>
>>>
>>> Howard
>>> Howard Greenberg, CPA, CISA
>>> IBM Certified Application Developer/Instructor - IBM Notes and Domino
>>> The Learning Continuum Company, Ltd.
>>> 888-241-8522 or 561-953-0096
>>> http://www.tlcc.com
>>> mailto:howardg@tlcc.com
>>>
>>>
>>>
>>> From: Tilman Hausherr <TH...@t-online.de>
>>> To: users@pdfbox.apache.org
>>> Date: 12/01/2016 03:03 PM
>>> Subject: Re: question on getting location of bookmark
>>>
>>>
>>>
>>> Am 01.12.2016 um 21:00 schrieb howardg@tlcc.com:
>>>> I want to find the x,y position of a bookmark in the pdf to be able
to
>>>> insert an image at that location.
>>>>
>>>> I can get the bookmark with the code below and looping through to
find
>>> the
>>>> one I need with getTitle....
>>>> PDOutlineItem current = outline.getFirstChild();
>>>>
>>>> But, how would I use PDOutlineItem to get the page/location to pass
as
>>> the
>>>> x,y coordinates in contentStream.drawImage(img, 100, 100);
>>> call getDestnation(). There are several types, and some of them have
>>> coordinates.
>>>
>>> ---------------------------------------------------------------------
>>> 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
>
>
>
>
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@pdfbox.apache.org
For additional commands, e-mail: users-help@pdfbox.apache.org
Re: question on getting location of bookmark
Posted by Tilman Hausherr <TH...@t-online.de>.
Am 01.12.2016 um 22:08 schrieb howardg@tlcc.com:
> thanks, I changed my code as shown below. However I can't cast the
> destination to the PDPageXYZDestination and it appears that it is a
> PDPageFitWidthDestination class. This class does not have the getLeft()
> and the page number returns -1????
That is the /FitH destination:
"Display the page designated by page, with the vertical coordinate top
positioned at the top edge of the window and the contents of the page
magnified just enough to fit the entire width of the page within the
window. A null value for top specifies that the current value of that
parameter shall be retained unchanged."
Re the page number -1:
/**
* This will get the page number for this destination. A page
destination can either reference a
* page (for a local destination) or a page number (when doing a
remote destination to another
* PDF). If this object is referencing by page number then this
method will return that number,
* otherwise -1 will be returned.
*
* @return The zero-based page number for this destination.
*/
public int getPageNumber()
That you don't get a page number is because numbers are only for
external destinations. If you want a local page, use getPage(). This
will return a PDPage object. To get its number, go
PDDocument.getPages().indexOf(PDPage).
Tilman
>
>
> PDDocumentOutline outline = pdfDoc
> .getDocumentCatalog().getDocumentOutline();
> if (outline != null) {
> debugMsg2("found outline");
> PDOutlineItem current =
> outline.getFirstChild();
> while (current != null) {
> debugMsg2
> (current.getTitle());
> if ("Image"
> .equalsIgnoreCase(current.getTitle())) {
> PDActionGoTo
> action = (PDActionGoTo) current.getAction();
> if (action != null
> ) {
> PDPageFitWidthDestination dest = (PDPageFitWidthDestination)
> action.getDestination();
> if (dest
> != null) {
> //
> debugMsg2("left: " + dest.getLeft());
>
> debugMsg2("top: " + dest.getTop());
>
> debugMsg2("page: " + dest.getPageNumber());
> } else {
>
> debugMsg2("dest is null");
> }
> } else {
> debugMsg2(
> "action is null");
> }
> current =
> current.getNextSibling();
> }
>
> }
>
> } else {
> debugMsg2("This document does not
> contain any bookmarks");
> }
>
>
> Howard
> Howard Greenberg, CPA, CISA
> IBM Certified Application Developer/Instructor - IBM Notes and Domino
> The Learning Continuum Company, Ltd.
> 888-241-8522 or 561-953-0096
> http://www.tlcc.com
> mailto:howardg@tlcc.com
>
>
>
> From: Tilman Hausherr <TH...@t-online.de>
> To: users@pdfbox.apache.org
> Date: 12/01/2016 03:49 PM
> Subject: Re: question on getting location of bookmark
>
>
>
> Am 01.12.2016 um 21:38 schrieb howardg@tlcc.com:
>> thanks, I am missing something... My code uses getDestination() and
>> recasts as PDPageXYZDestination. However, the dest is null. I must be
>> missing something?
> There's anther possibilty, that there is an /A entry, i.e. an action.
> Call getAction(). There are 13 different types of actions, but I'd
> expect PDActionGoTo. On that one you can again call getDestination().
>
> Tilman
>
>
>> PDDocumentOutline outline = pdfDoc
>> .getDocumentCatalog().getDocumentOutline();
>> if( outline != null ){
>> debugMsg2("found outline");
>> PDOutlineItem current =
>> outline.getFirstChild();
>> while( current != null ) {
>> debugMsg2( current.getTitle()
> );
>> if ("Image"
>> .equalsIgnoreCase(current.getTitle())){
>> PDPageXYZDestination
> dest
>> = (PDPageXYZDestination) current.getDestination();
>> if (dest!=null){
>> debugMsg2("left: "
>> + dest.getLeft());
>> debugMsg2("top:
> "
>> + dest.getTop());
>> debugMsg2("page: "
>> + dest.getPageNumber());
>> } else {
>> debugMsg2("dest
> is
>> null");
>> }
>> }
>> current =
>> current.getNextSibling();
>> }
>>
>>
>> } else {
>> debugMsg2( "This document does not
> contain
>> any bookmarks" );
>> }
>>
>>
>> Howard
>> Howard Greenberg, CPA, CISA
>> IBM Certified Application Developer/Instructor - IBM Notes and Domino
>> The Learning Continuum Company, Ltd.
>> 888-241-8522 or 561-953-0096
>> http://www.tlcc.com
>> mailto:howardg@tlcc.com
>>
>>
>>
>> From: Tilman Hausherr <TH...@t-online.de>
>> To: users@pdfbox.apache.org
>> Date: 12/01/2016 03:15 PM
>> Subject: Re: question on getting location of bookmark
>>
>>
>>
>> Am 01.12.2016 um 21:12 schrieb howardg@tlcc.com:
>>> thanks, can you elaborate? The API doc for getDestination shows that
>>> returns PDDestination and I don't see any methods that return the
>>> coordinates?
>> There are 7 derived classes. That's why I mentioned that there are
>> several types. For example, PDPageXYZDestination has a getLeft() and
>> getTop() method. But not all of the derived classes have coordinates
>> like that.
>>
>> Tilman
>>
>>>
>>> Howard
>>> Howard Greenberg, CPA, CISA
>>> IBM Certified Application Developer/Instructor - IBM Notes and Domino
>>> The Learning Continuum Company, Ltd.
>>> 888-241-8522 or 561-953-0096
>>> http://www.tlcc.com
>>> mailto:howardg@tlcc.com
>>>
>>>
>>>
>>> From: Tilman Hausherr <TH...@t-online.de>
>>> To: users@pdfbox.apache.org
>>> Date: 12/01/2016 03:03 PM
>>> Subject: Re: question on getting location of bookmark
>>>
>>>
>>>
>>> Am 01.12.2016 um 21:00 schrieb howardg@tlcc.com:
>>>> I want to find the x,y position of a bookmark in the pdf to be able to
>>>> insert an image at that location.
>>>>
>>>> I can get the bookmark with the code below and looping through to find
>>> the
>>>> one I need with getTitle....
>>>> PDOutlineItem current = outline.getFirstChild();
>>>>
>>>> But, how would I use PDOutlineItem to get the page/location to pass as
>>> the
>>>> x,y coordinates in contentStream.drawImage(img, 100, 100);
>>> call getDestnation(). There are several types, and some of them have
>>> coordinates.
>>>
>>> ---------------------------------------------------------------------
>>> 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
>
>
>
>
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@pdfbox.apache.org
For additional commands, e-mail: users-help@pdfbox.apache.org
Re: question on getting location of bookmark
Posted by ho...@tlcc.com.
thanks, I changed my code as shown below. However I can't cast the
destination to the PDPageXYZDestination and it appears that it is a
PDPageFitWidthDestination class. This class does not have the getLeft()
and the page number returns -1????
PDDocumentOutline outline = pdfDoc
.getDocumentCatalog().getDocumentOutline();
if (outline != null) {
debugMsg2("found outline");
PDOutlineItem current =
outline.getFirstChild();
while (current != null) {
debugMsg2
(current.getTitle());
if ("Image"
.equalsIgnoreCase(current.getTitle())) {
PDActionGoTo
action = (PDActionGoTo) current.getAction();
if (action != null
) {
PDPageFitWidthDestination dest = (PDPageFitWidthDestination)
action.getDestination();
if (dest
!= null) {
//
debugMsg2("left: " + dest.getLeft());
debugMsg2("top: " + dest.getTop());
debugMsg2("page: " + dest.getPageNumber());
} else {
debugMsg2("dest is null");
}
} else {
debugMsg2(
"action is null");
}
current =
current.getNextSibling();
}
}
} else {
debugMsg2("This document does not
contain any bookmarks");
}
Howard
Howard Greenberg, CPA, CISA
IBM Certified Application Developer/Instructor - IBM Notes and Domino
The Learning Continuum Company, Ltd.
888-241-8522 or 561-953-0096
http://www.tlcc.com
mailto:howardg@tlcc.com
From: Tilman Hausherr <TH...@t-online.de>
To: users@pdfbox.apache.org
Date: 12/01/2016 03:49 PM
Subject: Re: question on getting location of bookmark
Am 01.12.2016 um 21:38 schrieb howardg@tlcc.com:
> thanks, I am missing something... My code uses getDestination() and
> recasts as PDPageXYZDestination. However, the dest is null. I must be
> missing something?
There's anther possibilty, that there is an /A entry, i.e. an action.
Call getAction(). There are 13 different types of actions, but I'd
expect PDActionGoTo. On that one you can again call getDestination().
Tilman
>
> PDDocumentOutline outline = pdfDoc
> .getDocumentCatalog().getDocumentOutline();
> if( outline != null ){
> debugMsg2("found outline");
> PDOutlineItem current =
> outline.getFirstChild();
> while( current != null ) {
> debugMsg2( current.getTitle()
);
> if ("Image"
> .equalsIgnoreCase(current.getTitle())){
> PDPageXYZDestination
dest
> = (PDPageXYZDestination) current.getDestination();
> if (dest!=null){
> debugMsg2("left: "
> + dest.getLeft());
> debugMsg2("top:
"
> + dest.getTop());
> debugMsg2("page: "
> + dest.getPageNumber());
> } else {
> debugMsg2("dest
is
> null");
> }
> }
> current =
> current.getNextSibling();
> }
>
>
> } else {
> debugMsg2( "This document does not
contain
> any bookmarks" );
> }
>
>
> Howard
> Howard Greenberg, CPA, CISA
> IBM Certified Application Developer/Instructor - IBM Notes and Domino
> The Learning Continuum Company, Ltd.
> 888-241-8522 or 561-953-0096
> http://www.tlcc.com
> mailto:howardg@tlcc.com
>
>
>
> From: Tilman Hausherr <TH...@t-online.de>
> To: users@pdfbox.apache.org
> Date: 12/01/2016 03:15 PM
> Subject: Re: question on getting location of bookmark
>
>
>
> Am 01.12.2016 um 21:12 schrieb howardg@tlcc.com:
>> thanks, can you elaborate? The API doc for getDestination shows that
>> returns PDDestination and I don't see any methods that return the
>> coordinates?
> There are 7 derived classes. That's why I mentioned that there are
> several types. For example, PDPageXYZDestination has a getLeft() and
> getTop() method. But not all of the derived classes have coordinates
> like that.
>
> Tilman
>
>>
>>
>> Howard
>> Howard Greenberg, CPA, CISA
>> IBM Certified Application Developer/Instructor - IBM Notes and Domino
>> The Learning Continuum Company, Ltd.
>> 888-241-8522 or 561-953-0096
>> http://www.tlcc.com
>> mailto:howardg@tlcc.com
>>
>>
>>
>> From: Tilman Hausherr <TH...@t-online.de>
>> To: users@pdfbox.apache.org
>> Date: 12/01/2016 03:03 PM
>> Subject: Re: question on getting location of bookmark
>>
>>
>>
>> Am 01.12.2016 um 21:00 schrieb howardg@tlcc.com:
>>> I want to find the x,y position of a bookmark in the pdf to be able to
>>> insert an image at that location.
>>>
>>> I can get the bookmark with the code below and looping through to find
>> the
>>> one I need with getTitle....
>>> PDOutlineItem current = outline.getFirstChild();
>>>
>>> But, how would I use PDOutlineItem to get the page/location to pass as
>> the
>>> x,y coordinates in contentStream.drawImage(img, 100, 100);
>> call getDestnation(). There are several types, and some of them have
>> coordinates.
>>
>> ---------------------------------------------------------------------
>> 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: question on getting location of bookmark
Posted by Tilman Hausherr <TH...@t-online.de>.
Am 01.12.2016 um 21:38 schrieb howardg@tlcc.com:
> thanks, I am missing something... My code uses getDestination() and
> recasts as PDPageXYZDestination. However, the dest is null. I must be
> missing something?
There's anther possibilty, that there is an /A entry, i.e. an action.
Call getAction(). There are 13 different types of actions, but I'd
expect PDActionGoTo. On that one you can again call getDestination().
Tilman
>
> PDDocumentOutline outline = pdfDoc
> .getDocumentCatalog().getDocumentOutline();
> if( outline != null ){
> debugMsg2("found outline");
> PDOutlineItem current =
> outline.getFirstChild();
> while( current != null ) {
> debugMsg2( current.getTitle() );
> if ("Image"
> .equalsIgnoreCase(current.getTitle())){
> PDPageXYZDestination dest
> = (PDPageXYZDestination) current.getDestination();
> if (dest!=null){
> debugMsg2("left: "
> + dest.getLeft());
> debugMsg2("top: "
> + dest.getTop());
> debugMsg2("page: "
> + dest.getPageNumber());
> } else {
> debugMsg2("dest is
> null");
> }
> }
> current =
> current.getNextSibling();
> }
>
>
> } else {
> debugMsg2( "This document does not contain
> any bookmarks" );
> }
>
>
> Howard
> Howard Greenberg, CPA, CISA
> IBM Certified Application Developer/Instructor - IBM Notes and Domino
> The Learning Continuum Company, Ltd.
> 888-241-8522 or 561-953-0096
> http://www.tlcc.com
> mailto:howardg@tlcc.com
>
>
>
> From: Tilman Hausherr <TH...@t-online.de>
> To: users@pdfbox.apache.org
> Date: 12/01/2016 03:15 PM
> Subject: Re: question on getting location of bookmark
>
>
>
> Am 01.12.2016 um 21:12 schrieb howardg@tlcc.com:
>> thanks, can you elaborate? The API doc for getDestination shows that
>> returns PDDestination and I don't see any methods that return the
>> coordinates?
> There are 7 derived classes. That's why I mentioned that there are
> several types. For example, PDPageXYZDestination has a getLeft() and
> getTop() method. But not all of the derived classes have coordinates
> like that.
>
> Tilman
>
>>
>>
>> Howard
>> Howard Greenberg, CPA, CISA
>> IBM Certified Application Developer/Instructor - IBM Notes and Domino
>> The Learning Continuum Company, Ltd.
>> 888-241-8522 or 561-953-0096
>> http://www.tlcc.com
>> mailto:howardg@tlcc.com
>>
>>
>>
>> From: Tilman Hausherr <TH...@t-online.de>
>> To: users@pdfbox.apache.org
>> Date: 12/01/2016 03:03 PM
>> Subject: Re: question on getting location of bookmark
>>
>>
>>
>> Am 01.12.2016 um 21:00 schrieb howardg@tlcc.com:
>>> I want to find the x,y position of a bookmark in the pdf to be able to
>>> insert an image at that location.
>>>
>>> I can get the bookmark with the code below and looping through to find
>> the
>>> one I need with getTitle....
>>> PDOutlineItem current = outline.getFirstChild();
>>>
>>> But, how would I use PDOutlineItem to get the page/location to pass as
>> the
>>> x,y coordinates in contentStream.drawImage(img, 100, 100);
>> call getDestnation(). There are several types, and some of them have
>> coordinates.
>>
>> ---------------------------------------------------------------------
>> 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: question on getting location of bookmark
Posted by ho...@tlcc.com.
thanks, I am missing something... My code uses getDestination() and
recasts as PDPageXYZDestination. However, the dest is null. I must be
missing something?
PDDocumentOutline outline = pdfDoc
.getDocumentCatalog().getDocumentOutline();
if( outline != null ){
debugMsg2("found outline");
PDOutlineItem current =
outline.getFirstChild();
while( current != null ) {
debugMsg2( current.getTitle() );
if ("Image"
.equalsIgnoreCase(current.getTitle())){
PDPageXYZDestination dest
= (PDPageXYZDestination) current.getDestination();
if (dest!=null){
debugMsg2("left: "
+ dest.getLeft());
debugMsg2("top: "
+ dest.getTop());
debugMsg2("page: "
+ dest.getPageNumber());
} else {
debugMsg2("dest is
null");
}
}
current =
current.getNextSibling();
}
} else {
debugMsg2( "This document does not contain
any bookmarks" );
}
Howard
Howard Greenberg, CPA, CISA
IBM Certified Application Developer/Instructor - IBM Notes and Domino
The Learning Continuum Company, Ltd.
888-241-8522 or 561-953-0096
http://www.tlcc.com
mailto:howardg@tlcc.com
From: Tilman Hausherr <TH...@t-online.de>
To: users@pdfbox.apache.org
Date: 12/01/2016 03:15 PM
Subject: Re: question on getting location of bookmark
Am 01.12.2016 um 21:12 schrieb howardg@tlcc.com:
> thanks, can you elaborate? The API doc for getDestination shows that
> returns PDDestination and I don't see any methods that return the
> coordinates?
There are 7 derived classes. That's why I mentioned that there are
several types. For example, PDPageXYZDestination has a getLeft() and
getTop() method. But not all of the derived classes have coordinates
like that.
Tilman
>
>
>
> Howard
> Howard Greenberg, CPA, CISA
> IBM Certified Application Developer/Instructor - IBM Notes and Domino
> The Learning Continuum Company, Ltd.
> 888-241-8522 or 561-953-0096
> http://www.tlcc.com
> mailto:howardg@tlcc.com
>
>
>
> From: Tilman Hausherr <TH...@t-online.de>
> To: users@pdfbox.apache.org
> Date: 12/01/2016 03:03 PM
> Subject: Re: question on getting location of bookmark
>
>
>
> Am 01.12.2016 um 21:00 schrieb howardg@tlcc.com:
>> I want to find the x,y position of a bookmark in the pdf to be able to
>> insert an image at that location.
>>
>> I can get the bookmark with the code below and looping through to find
> the
>> one I need with getTitle....
>> PDOutlineItem current = outline.getFirstChild();
>>
>> But, how would I use PDOutlineItem to get the page/location to pass as
> the
>> x,y coordinates in contentStream.drawImage(img, 100, 100);
> call getDestnation(). There are several types, and some of them have
> coordinates.
>
> ---------------------------------------------------------------------
> 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: question on getting location of bookmark
Posted by Tilman Hausherr <TH...@t-online.de>.
Am 01.12.2016 um 21:12 schrieb howardg@tlcc.com:
> thanks, can you elaborate? The API doc for getDestination shows that
> returns PDDestination and I don't see any methods that return the
> coordinates?
There are 7 derived classes. That's why I mentioned that there are
several types. For example, PDPageXYZDestination has a getLeft() and
getTop() method. But not all of the derived classes have coordinates
like that.
Tilman
>
>
>
> Howard
> Howard Greenberg, CPA, CISA
> IBM Certified Application Developer/Instructor - IBM Notes and Domino
> The Learning Continuum Company, Ltd.
> 888-241-8522 or 561-953-0096
> http://www.tlcc.com
> mailto:howardg@tlcc.com
>
>
>
> From: Tilman Hausherr <TH...@t-online.de>
> To: users@pdfbox.apache.org
> Date: 12/01/2016 03:03 PM
> Subject: Re: question on getting location of bookmark
>
>
>
> Am 01.12.2016 um 21:00 schrieb howardg@tlcc.com:
>> I want to find the x,y position of a bookmark in the pdf to be able to
>> insert an image at that location.
>>
>> I can get the bookmark with the code below and looping through to find
> the
>> one I need with getTitle....
>> PDOutlineItem current = outline.getFirstChild();
>>
>> But, how would I use PDOutlineItem to get the page/location to pass as
> the
>> x,y coordinates in contentStream.drawImage(img, 100, 100);
> call getDestnation(). There are several types, and some of them have
> coordinates.
>
> ---------------------------------------------------------------------
> 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: question on getting location of bookmark
Posted by ho...@tlcc.com.
thanks, can you elaborate? The API doc for getDestination shows that
returns PDDestination and I don't see any methods that return the
coordinates?
Howard
Howard Greenberg, CPA, CISA
IBM Certified Application Developer/Instructor - IBM Notes and Domino
The Learning Continuum Company, Ltd.
888-241-8522 or 561-953-0096
http://www.tlcc.com
mailto:howardg@tlcc.com
From: Tilman Hausherr <TH...@t-online.de>
To: users@pdfbox.apache.org
Date: 12/01/2016 03:03 PM
Subject: Re: question on getting location of bookmark
Am 01.12.2016 um 21:00 schrieb howardg@tlcc.com:
> I want to find the x,y position of a bookmark in the pdf to be able to
> insert an image at that location.
>
> I can get the bookmark with the code below and looping through to find
the
> one I need with getTitle....
> PDOutlineItem current = outline.getFirstChild();
>
> But, how would I use PDOutlineItem to get the page/location to pass as
the
> x,y coordinates in contentStream.drawImage(img, 100, 100);
call getDestnation(). There are several types, and some of them have
coordinates.
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@pdfbox.apache.org
For additional commands, e-mail: users-help@pdfbox.apache.org
Re: question on getting location of bookmark
Posted by Tilman Hausherr <TH...@t-online.de>.
Am 01.12.2016 um 21:00 schrieb howardg@tlcc.com:
> I want to find the x,y position of a bookmark in the pdf to be able to
> insert an image at that location.
>
> I can get the bookmark with the code below and looping through to find the
> one I need with getTitle....
> PDOutlineItem current = outline.getFirstChild();
>
> But, how would I use PDOutlineItem to get the page/location to pass as the
> x,y coordinates in contentStream.drawImage(img, 100, 100);
call getDestnation(). There are several types, and some of them have
coordinates.
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@pdfbox.apache.org
For additional commands, e-mail: users-help@pdfbox.apache.org