public class PdfGotoAction extends PdfAction
PdfWriter writer1 = PdfWriter.fileWriter( new File("PdfGotoAction_example.pdf")); PdfDocument doc1 = new PdfDocument(writer1); // Create two PDF pages PdfPage page1 = new PdfPage(); PdfPage page2 = (PdfPage) page1.clone(); // Render some text on the pages page1.writeText("Click here to go to page 2", 200, 100); page2.writeText("This is page 2"); // Create a link annotation over a word rendered on page 1 PdfLinkAnnot la = new PdfLinkAnnot(new PdfRect(223, 100, 23, 12), Color.BLUE); // Create a go-to action for navigation into page 2 PdfGotoAction gta = new PdfGotoAction(2); // Add the go-to action to the link annotation la.addAction(gta); // Add the link annotation to page 1 page1.addAnnotation(la); doc1.add(page1); doc1.add(page2); doc1.setOpenAfterSave(true); doc1.write(); writer1.dispose();
PdfAction.PdfEvent
GOTO, JAVASCRIPT, LAUNCH, NAMED, NAMED_FIND, NAMED_FIRSTPAGE, NAMED_LASTPAGE, NAMED_NEXTPAGE, NAMED_OPEN, NAMED_PREVPAGE, NAMED_PRINT, NAMED_SEARCH, REMOTE_GOTO, URI
Constructor and Description |
---|
PdfGotoAction(int pageNo)
Constructs a go-to action that changes the current view on the
viewer application to specfied page.
|
PdfGotoAction(int pageNo,
double left,
double top,
double zoom)
Constructs a go-to action that changes the current view on the
viewer application to position specfied by
left
and top on specified page. |
PdfGotoAction(int pageNo,
double x,
double y,
double width,
double height)
Constructs a go-to action that changes the current view on the
viewer application to specified rectangular area on a specified
page.
|
PdfGotoAction(int pageNo,
double pos,
int fit)
Constructs a go-to action that changes the current view on the
viewer application to position specfied by
pos
on specified page. |
PdfGotoAction(int pageNo,
int fit)
Constructs a go-to action that changes the current view on the
viewer application to specfied page and displays the page as
specified by
fit . |
PdfGotoAction(int pageNo,
PdfRect rect)
Constructs a go-to action that changes the current view on the
viewer application to specified rectangle on specified
page.
|
Modifier and Type | Method and Description |
---|---|
int |
getDestinationType()
Returns destination type of the go-to action.
|
int |
getFit() |
double |
getLeft() |
int |
getPageNo() |
double |
getPos() |
PdfRect |
getRect() |
double |
getTop() |
double |
getZoom() |
void |
setDestination(double left,
double top,
double zoom) |
void |
setDestination(double x,
double y,
double width,
double height) |
void |
setDestination(double pos,
int fit) |
void |
setDestination(int fit) |
void |
setDestination(PdfRect rect) |
void |
setPageNo(int pageNo) |
getActionType
public PdfGotoAction(int pageNo)
pageNo
- number of the pagepublic PdfGotoAction(int pageNo, double left, double top, double zoom)
left
and top
on specified page.pageNo
- number of the pageleft
- x-coordinate of the top-left corner of the window on
the pagetop
- y-coordinate of the top-left corner of the window on
the pagezoom
- magnification (zoom) factor to be applied when
displaying the pagepublic PdfGotoAction(int pageNo, double x, double y, double width, double height)
pageNo
- number of the pagex
- x-coordinate of the top-left corner of the
rectangular areay
- y-coordinate of the top-left corner of the
rectangular areawidth
- width of the rectangular areaheight
- height of the rectangular areapublic PdfGotoAction(int pageNo, double pos, int fit) throws PdfException
pos
on specified page.pageNo
- number of the destination pagepos
- coordinates of top-left corner of the window on the
pagefit
- constant
for specifying
magnification (zoom) factor of the pagePdfException
- if an illegal argument is supplied.public PdfGotoAction(int pageNo, int fit) throws PdfException
fit
.pageNo
- number of the destination pagefit
- either PdfBookmark.FITB
or
PdfDestination.FIT
PdfException
- if an illegal argument is supplied.public PdfGotoAction(int pageNo, PdfRect rect)
pageNo
- number of the destination pagerect
- rectangle on the pagepublic void setDestination(double left, double top, double zoom)
public void setDestination(double x, double y, double width, double height)
public void setDestination(double pos, int fit) throws PdfException
PdfException
public void setDestination(int fit) throws PdfException
PdfException
public void setDestination(PdfRect rect)
public int getPageNo()
public void setPageNo(int pageNo)
public int getFit()
public double getLeft()
public double getPos()
public double getTop()
public double getZoom()
public PdfRect getRect()
public int getDestinationType()