Preview.LoadFile
----------------

Loads a PDF document from file path.

| Component | Version | macOS | Windows | Linux | Server | iOS SDK |
|---|---|---|---|---|---|---|
| [Preview](component_Preview.md) | [13.3](newinversion133.md) | ✅ Yes | ✅ Yes | ❌ No | ❌ No | ❌ No |

MBS( "Preview.LoadFile"; PreviewRef; Path ) 

**MBS**( **"Preview.LoadFile"** /\* Loads a PDF document from file path. \*/  
**$PreviewRef**; /\* The reference ID for this preview control. e.g. $ref \*/   
**$Path**) /\* Native file path to the PDF file. e.g. "C:\\test\\test.pdf" \*/ 

### Parameters

| Parameter | Description | Example |
|---|---|---|
| PreviewRef | The reference ID for this preview control. | $ref |
| Path | Native file path to the PDF file. | "C:\\test\\test.pdf" |

### Result

Returns OK or error.

### Description

Loads a PDF document from file path.  
If the file path is invalid, the preview will show a file not found error message.  
  
On macOS, this uses QuickLook preview, so you can show many common file types, including the following:  
  
- iWork documents
- Microsoft Office documents
- Rich text format, or RTF, documents
- PDF files
- Images
- Text files with a uniform type identifier that conforms to the public.text type. To learn more, see Uniform type identifiers.
- Comma-separated values, or CSV, files
- 3D models in the USDZ format with both standalone and AR views for viewing the model

The list of supported common file types may change between operating system releases. In addition, you can enable previews for your own file types by implementing your own preview extension. Showing Word files may require to install Pages, Excel files require to install Numbers and Powerpoint files require to install Keynote application.  
  
This function requires a native path. Use [Path.FileMakerPathToNativePath](PathFileMakerPathToNativePath.md) 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](component_FileDialog.md) functions.  
### Examples

Load file:

 Set Variable \[ $r ; Value: MBS ( "Preview.LoadFile"; $$preview ; PDF Viewer::PDF Path ) \]   
If \[ MBS ("IsError") \]   
 Show Custom Dialog \[ "Failed to load file" ; $r \]   
End If  
### See also

- [IsError](IsError.md)
- [Path.FileMakerPathToNativePath](PathFileMakerPathToNativePath.md)
- [Preview.CreateWithControl](PreviewCreateWithControl.md)
- [Preview.Unload](PreviewUnload.md)

### Example Databases

- [PDF Viewer](https://www.mbsplugins.eu/MBS-FileMaker-Plugin-Examples/PDF%20Viewer.shtml#3ScriptAnchor_)

### Blog Entries

- [MBS Plugin Advent calendar: 18 - Preview](https://www.mbsplugins.de/archive/2023-12-18/MBS_Plugin_Advent_calendar_18_/monkeybreadsoftware_blog_filemaker)
- [New in MBS FileMaker Plugin 13.3](https://www.mbsplugins.de/archive/2023-07-25/New_in_MBS_FileMaker_Plugin_13/monkeybreadsoftware_blog_filemaker)

This function checks for a license.

Created 12nd June 2023 , last changed 16th July 2023

  
[Preview.LoadContainer](PreviewLoadContainer.md) - [Preview.Release](PreviewRelease.md)

[HTML Version](PreviewLoadFile.shtml)