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 |
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 for WebView2 control. Doesn't work with the Internet Explorer, e.g. with WebView.Create.
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
- Files.ReadPDF
- Folders.UserDesktop
- Folders.UserTemporary
- Path.FileMakerPathToNativePath
- WebView.Create
- WebView.FindByName
- WebView.LoadURL
- WebView.RenderPDF
- WebView.SetPreferences
- WebView.SetPrintParameter
Release notes
- Version 15.1
- Fixed a problem with WebView.PrintToFile not passing paper height correctly.
- Version 13.1
- Implemented WebView.AllCookies and WebView.PrintToFile for Windows.
- Version 11.5
- Fixed bug in WebView.PrintToFile and WebView.Print functions to make it work for WebKit 2.
Example Databases
Blog Entries
- MBS FileMaker Plugin, version 15.1pr1
- Printing a WebViewer in FileMaker
- Neues MBS Plugin 13.1 für Claris FileMaker
- MBS Plugin 13.1 for Claris FileMaker
- MBS FileMaker Plugin, version 13.1pr4
- MBS FileMaker Plugin, version 11.5pr5
- Print WebViewer on macOS in FileMaker
- Custom WebView in FileMaker 16
- MBS FileMaker Plugin 4.0 for OS X/Windows - More than 2200 Functions In One Plugin
- MBS Filemaker Plugin, version 4.0pr4
FileMaker Magazin
This function checks for a license.
Created 18th August 2014, last changed 28th January 2025
