Topics
All
MacOS
(Only)
Windows
(Only)
Linux
(Only, Not)
iOS
(Only, Not)
Components
Crossplatform Mac & Win
Server
Client
Old
Deprecated
Guides
Examples
Videos
New in version:
9.3
9.4
9.5
10.0
10.1
10.2
10.3
10.4
10.5
10.6
Statistic
FMM
Blog
WebView.PrintToFile
Prints the current web view content to PDF file.
| Component | Version | macOS | Windows | Linux | Server | FileMaker iOS SDK |
| WebView | 4.0 | Yes | No | 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.
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.
Not supported for WebKit 2.x (FileMaker 16 Mac). We tried it, but as of macOS 10.12.4 we only get damaged files, crashes or white pages. Works in FileMaker 16 or later, when using a Web Viewer created using 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.UserDesktop" ) ]
Set Variable [ $path ; Value: MBS( "Path.AddPathComponent"; $path; "test.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.mbs-plugins.com") ]
# 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) ]
See also
- Files.ReadPDF
- Folders.UserDesktop
- Path.AddPathComponent
- Path.FileMakerPathToNativePath
- WebView.Create
- WebView.FindByName
- WebView.GetPrintParameter
- WebView.IsLoading
- WebView.LoadURL
- WebView.RenderPDF
Example Databases
Blog Entries
- 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
Created 18th August 2014, last changed 5th November 2020
WebView.PrintPreview - WebView.Release
Feedback: Report problem or ask question.
Links
MBS Xojo tutorial videos