This page provides an example of how to open PDF with Adobe [L1 ] Acrobat or Acrobat Reader using the optcl package. For more information see DeveloperFAQ.pdf [L2 ], IACOverview.pdf [L3 ] and IACReference.pdf [L4 ].
Alexander Schöpe
package require optcl
proc Acroview { pdf {preview 1} } {
global acrobat
set w .acroview
if {![winfo exists $w]} {
toplevel $w
wm resizable $w 1 1
wm title $w "Adobe Acrobat Plugin"
wm protocol $w WM_DELETE_WINDOW [list catch [list wm withdraw $w]]
wm geometry $w +100+50
grid columnconfigure $w 0 -weight 1
grid rowconfigure $w 0 -weight 1
grid [ttk::label $w.i -text "Loading Adobe PDF Plugin..."] -row 0 -column 0 -sticky wnes
update idletasks
update
set acrobat [optcl::new -start -window $w.acropdf AcroPDF.PDF]
destroy $w.i
grid $w.acropdf -row 0 -column 0 -sticky wnes
grid [frame $w.f] -row 1 -column 0 -sticky wnes
grid columnconfigure $w.f 0 -weight 9
grid columnconfigure $w.f 3 -weight 1
grid [button $w.f.c -text [msgcat::mc Cancel] -command [list catch [list wm withdraw $w]]] -row 0 -column 1
grid [button $w.f.p -text [msgcat::mc Print] -command [list $acrobat printWithDialog]] -row 0 -column 2
update idletasks
$w.acropdf configure -height [set h [expr {[winfo screenheight .] - [winfo reqheight $w.f] - 150}]] -width [expr {int($h * 0.75)}]
}
wm withdraw $w
if {[optcl::isobject $acrobat]} {
$acrobat LoadFile $pdf
$acrobat setCurrentPage 1
$acrobat setLayoutMode OneColumn
$acrobat setShowToolbar 0
$acrobat setView Fit
}
if {$preview} {
wm deiconify $w
} else {
if {[optcl::isobject $acrobat]} {
$acrobat printWithDialog
}
wm withdraw $w
}
}
Properties:
- Src - Gets or sets the URL for the document.
Methods:
- GetVersions - Deprecated
- GoBackwardStack - Goes to the previous view on the view stack, if the previous view exists.
- GoForwardStack - Goes to the next view on the view stack, if the next view exists.
- GotoFirstPage - Goes to the first page in the document, maintaining the current location within the page and zoom level.
- GotoLastPage - Goes to the last page in the document, maintaining the current location within the page and zoom level.
- GotoNextPage - Goes to the next page in the document, if it exists. Maintains the current location within the page and zoom level.
- GotoPreviousPage - Goes to the previous page in the document, if it exists. Maintains the current location within the page and zoom level.
- LoadFile - Opens and displays the specified document within the browser.
- Print - Prints the document according to the options selected in a user dialog box.
- PrintAll - Prints the entire document without displaying a user dialog box.
- PrintAllFit - Prints the entire document without displaying a user dialog box, and the pages are shrunk, if necessary, to fit into the imageable area of a page in the printer.
- PrintPages - Prints the specified pages without displaying a user dialog box.
- PrintPagesFit - Prints the specified pages without displaying a user dialog box.
- PrintWithDialog - Prints the document according to the options selected in a user dialog box.
- SetCurrentHighlight - Highlights the text selection within the specified bounding rectangle on the current page.
- SetCurrentPage - Goes to the specified page in the document.
- SetLayoutMode - Sets the layout mode for a page view according to the specified string.
- SetNamedDest - Changes the page view to the named destination in the specified string.
- SetPageMode - Sets the page mode according to the specified string.
- SetShowScrollbars - Determines whether scrollbars will appear in the document view.
- SetShowToolbar - Determines whether a toolbar will appear in the viewer.
- SetView - Sets the view of a page according to the specified string.
- SetViewRect - Sets the view rectangle according to the specified coordinates.
- SetViewScroll - Sets the view of a page according to the specified string.
- SetZoom - Sets the magnification according to the specified value.
- SetZoomScroll - Sets the magnification according to the specified value, and scrolls the page view both horizontally and vertically according to the specified amounts.
See also