Components | All | New | MacOS | Windows | Linux | iOS | ||||
Examples | Mac & Win | Server | Client | Guides | Statistic | FMM | Blog | Deprecated | Old |
Prints the current web view content to PDF file.
Component | Version | macOS | Windows | Linux | Server | iOS SDK |
WebView | 4.0 | ✅ Yes | ✅ Yes | ❌ No | ❌ No | ❌ No |
Parameter | Description | Example |
---|---|---|
WebViewerRef | Either the Web Viewer Object Name or the Web Viewer ID as returned by "WebView.FindByName" function. | |
Path | Native file path where to save PDF. | "/tmp/test.pdf" |
Returns OK or error.
Create PDF and import it:
Set Variable [ $path ; Value: MBS( "Folders.UserTemporary" ) ]
Set Variable [ $path ; Value: MBS( "Path.AddPathComponent"; $path; "website.pdf" ) ]
Set Variable [ $r ; Value: MBS( "WebView.PrintToFile"; $$web; $path ) ]
Set Field [ Own WebView::Container ; MBS( "Files.ReadPDF"; $path) ]
Print via WebKit 1.x web viewer:
# Create WebViewer Copy in file WebViewer Print
# Create web view in version 1 for WebKit
Set Variable [ $$web ; Value: MBS("WebView.Create"; 0; 40; 80; 970; 440; 1) ]
# Load som eURL
Set Variable [ $r ; Value: MBS( "WebView.LoadURL"; $$web; "http://www.mbsplugins.de") ]
# wait for website to load
Loop
Exit Loop If [ MBS( "WebView.IsLoading"; $$web ) ≠ 1 ]
Pause/Resume Script [ Duration (seconds): ,1 ]
End Loop
# set print parameters
Set Variable [ $r ; Value: MBS("WebView.SetPrintParameter"; "shouldPrintBackgrounds"; 0) ]
Set Variable [ $r ; Value: MBS("WebView.SetPrintParameter"; "leftMargin"; 30) ]
Set Variable [ $r ; Value: MBS("WebView.SetPrintParameter"; "topMargin"; 30) ]
Set Variable [ $r ; Value: MBS("WebView.SetPrintParameter"; "rightMargin"; 30) ]
Set Variable [ $r ; Value: MBS("WebView.SetPrintParameter"; "bottomMargin"; 30) ]
# get a file path
Set Variable [ $Path ; Value: MBS( "Path.AddPathComponent"; MBS( "Folders.UserDesktop" ); "test.pdf") ]
# print to PDF
Set Variable [ $r ; Value: MBS("WebView.PrintToFile"; $$web; $Path) ]
Print on Windows:
Set Variable [ $$test ; Value: MBS( "WebView.PrintToFile"; "web"; "C:\\Users\\Christian\\Desktop\\test.pdf") ]
This function checks for a license.
Created 18th August 2014, last changed 12nd February 2024