Components All New MacOS Windows Linux iOS
Examples Mac & Win Server Client Guides Statistic FMM Blog Deprecated Old

WebView.PrintToFile

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
MBS( "WebView.PrintToFile"; WebViewerRef; Path )   More

Parameters

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"

Result

Returns OK or error.

Description

Prints the current web view content to PDF file.
You can get/set some parameters on macOS using the WebView.GetPrintParameter/WebView.SetPrintParameter functions and WebView.SetPreferences function.
Especially you can control whether to print background or not.

If needed you can import this PDF file with Files.ReadPDF into a container file.
See also WebView.RenderPDF.

Supported for WebKit 2.x (FileMaker 16 Mac) with version 11.5.

Windows support added for version 13.1 for FileMaker Pro 19.4 or newer.

This function requires a native path. Use Path.FileMakerPathToNativePath to convert a FileMaker path to a native path if required. If you like to have the user choose the path, you can use FileDialog functions.

Examples

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") ]

See also

Release notes

Example Databases

Blog Entries

This function checks for a license.

Created 18th August 2014, last changed 12nd February 2024


WebView.PrintPreview - WebView.Release