<< Click to Display Table of Contents >> Navigation: Commands > Navigate in PDF |
COMPDF_GotoFirst = 20
Goto the first first page in current PDF data.
COMPDF_GotoPrev = 21
Goto previous page / position
If bit 1 is set in Param =1 it scrolls screen height wise
If bit 2 is set, it will go to previously logged position (same as BACKSPACE key)
If bit 3 is set, the result will be > 0 if there is a logged position
COMPDF_GotoPage = 22
Goto Page Nr in parameter. The first page has number 0.
StrParam can be optionally used. It will be interpreted as
"" = start of page
"y" = certain y coordinate from top of page measured in 72 dpi values
"x,y" = certain X, Y position
"x,y%z" = certain X and Y position and Zoom value
COMPDF_GotoNext = 23
Goto next page. If Param =1 it scrolls one screen height down.
COMPDF_GotoLast = 24
Goto last page. Pass intpar=1 to go to end of last page.
b) Navigate to X, Y position measured in 72 dpi from start of the PDF data
COMPDF_GotoYPos = 27
Move to a certain Y (top offset) position.
COMPDF_GotoXPos = 28
Move to a certain X (left offset) position.
COMPDF_ScrollXY = 29
Scroll horizontally or vertically.
IntParam is a bitfield:
1: scroll horizontally, otherwise vertically
2: scroll by 4/5 of the box size, otherwise 1/5
4: move down, otherwise up.
COMPDF_GotoNamedDest = 270
Goto bookmark.
StrParam is the name of a named destination.
Result=PageNumber or -1 if not found
You can specify an integer parameter:
1: The command will return a string list with the names of all named destinations in the PDF
2: The command will jump to the bookmark (akn outline) with the given text.
procedure TForm1.Gotoabookmark1Click(Sender: TObject);
var i : Integer;
s : String;
begin
s := '';
if (pdf<>nil) and InputQuery('Jump', 'Bookmark' , s) then
begin
i := pdf.command(COMPDF_GotoNamedDest, s, 2); // Try the name of an outline
if i<0 then
begin
i := pdf.command(COMPDF_GotoNamedDest, s, 0); // try a named destination
if i<0 then ShowMessage(s +#10 + 'was not found and outline ore named destination.');
end;
end;
end;
c) Zooming
COMPDF_Zoom100 = 41 ---------> 100 % Zoom
COMPDF_ZoomIn = 42; ---------> + 10%
COMPDF_Zoom = 43; ---------> Zoom to IntPar - if IntPar=0 retrieve zoom!
If StrPar='MP' it will center to mouse position
COMPDF_ZoomOut = 44; ---------> - 10%
COMPDF_ZoomFullWidth = 45;---------> Page Width
COMPDF_ZoomFullPage = 46; ---------> Page Width
COMPDF_ZoomTwoPages = 47; ---------> Toggle 2 Pages Display
COMPDF_ZoomThumbs = 48; ---------> Thumbnail Preview
COMPDF_ZoomGetCurrent = 49; ---------> read current zoom
COMPDF_ZoomSaveRestore = 76;---------> IntPar=1 Saves, IntPar=0 Restores
Controls thumbnail window:
COMPDF_ZoomThumbnails = 77; // Value>=10 sets the thumbnail zoomsize (default 12), -9..9 increases or decreases the zoom value
Example:
How to implement a zoom tool (zoom to rectangle) - see here...
This Delphi code will implement temporarily zooming to 200% when clicking on a certain point :
Must be called before for custom mouse handling:
WPViewPDF1.Command(COMPDF_RefineMouseMode, '0', 1);
We need a variable to store the zoomed mode
var FZoomed : Boolean;
The MouseDown event
procedure TForm1.WPViewMouseDown(Sender: TObject; Button: TMouseButton;
Shift: TShiftState; X, Y: Integer);
begin
if not FZoomed then
begin
WPViewPDF1.command(COMPDF_ZoomSaveRestore, 1); // Save Position
WPViewPDF1.command(COMPDF_Zoom, 'MP', 200);
FZoomed := true;
end;
end;
The MouseUp event
procedure TForm1.WPVIewMouseUp(Sender: TObject; Button: TMouseButton;
Shift: TShiftState; X, Y: Integer);
begin
if FZoomed then
begin
FZoomed := false;
WPViewPDF1.command(COMPDF_ZoomSaveRestore, 0); // Goto saved position
end;
end;
Temporarily zoom in with middle mouse.
// Disable Middle Mouse
WPViewPDF1.Command(COMPDF_RefineMouseMode, '0', 1);
var FZoomed : Boolean;
procedure TForm1.WPViewMouseDown(Sender: TObject; Button: TMouseButton;
Shift: TShiftState; X, Y: Integer);
begin
if not FZoomed and (Button=mbMiddle) then
begin
WPViewPDF1.command(COMPDF_ZoomSaveRestore, 1); // Save Position
WPViewPDF1.command(COMPDF_Zoom, 'MP', 200);
FZoomed := true;
end;
end;
procedure TForm1.WPVIewMouseUp(Sender: TObject; Button: TMouseButton;
Shift: TShiftState; X, Y: Integer);
begin
if FZoomed then
begin
FZoomed := false;
WPViewPDF1.command(COMPDF_ZoomSaveRestore, 0); // Goto saved position
end;
end;