tutorial · 2026-05-25
Open a File Dialog to Pick a PDF in Unreal Engine 5
Wire up an editor file dialog, resolve the chosen path, and load the document straight into an in-world viewer.
The problem: a hard-coded path is not a workflow
If you are building editor tooling or a documentation utility in UE5, sooner or later you need a person to choose which PDF gets shown. Typing an absolute path into a property field works for a one-off test, but it breaks the moment the file moves or someone else opens the project. What you want is the native Unreal Engine open file dialog so a user can browse to a PDF, plus a reliable way to turn whatever they pick into something a viewer can load.
Simple PDF Viewer ships exactly those pieces: an editor-side file dialog, helpers that resolve content and project-relative paths to absolute paths, and a function that loads a chosen path into a specific viewer actor. This tutorial wires the three together so one click goes from browse to rendered on a mesh. The file dialog is an editor utility, so this flow is for editor tools and authoring steps, not packaged player-facing builds.
Step 1: open the file dialog and capture the path
The plugin's Blueprint function library exposes 'OpenPDFFileDialog', an editor function that pops the native file browser and returns the path the user selected. Because it lives in the editor module, call it from an Editor Utility Widget or any editor-only graph rather than from gameplay code that ships in a build.
1. Create an Editor Utility Widget (right-click in the Content Browser, Editor Utilities, Editor Utility Widget) and add a button to its canvas.
2. In the widget's Event Graph, on the button's 'On Clicked' event, add the 'Open PDF File Dialog' node from the Simple PDF Viewer Blueprint library. When the user confirms, the node returns the path they chose.
3. Promote the returned path to a variable or feed it straight into the next step, but branch on whether the string is empty first so a cancelled dialog does not trigger a load.
Step 2: resolve content and project-relative paths
A native dialog typically returns an absolute path, which is exactly what the loader wants. But your tool may also store paths relative to the project or the content folder, for example when you keep sample documents inside the project so they travel with source control. For those cases Simple PDF Viewer provides helpers that resolve a relative path to a full absolute path.
Use 'GetContentRelativePath' when your stored path is anchored to the project's Content directory, and 'GetProjectRelativePath' when it is anchored to the project root. Both return an absolute path you can pass straight to the loader. The rule is simple: a path the user just picked is already absolute, so use it as-is; a saved or configured relative path goes through the matching helper first. Resolving it in one place avoids hand-concatenating strings and the classic 'works on my machine' breakage when a teammate's project lives elsewhere.
Step 3: load the chosen file into a viewer
With a valid absolute path in hand, load it into a viewer. Simple PDF Viewer renders pages by rasterising them to a UTexture2D and displaying that texture on an in-world mesh, so the target is an 'APDFViewerActor' (display name 'PDF Viewer') placed in your level, or any actor carrying a 'UPDFRenderComponent'.
1. Place a 'PDF Viewer' actor in the level, or add a 'PDF Renderer' component to an existing actor, and set its DisplayWidth and RenderQuality so the page reads clearly.
2. From your editor utility, call 'LoadPDFIntoViewer', passing the absolute path and a reference to the target viewer actor. This routes the document into that specific viewer rather than every viewer in the level.
3. Bind the viewer's events: 'OnPDFLoaded' reports the page count, 'OnPDFLoadFailed' returns an error message if the file cannot be read, and 'OnPageChanged' fires as you navigate. Wire 'NextPage', 'PreviousPage', and 'GoToPage' so the user can page through what they loaded.
If the document is encrypted, the load call accepts an optional password parameter. Page geometry queries such as 'GetCurrentPageSize' and 'GetCurrentPageAspectRatio' let the viewer auto-orient the display mesh to match the document.
Where this fits, and what to keep in mind
This dialog-driven flow is ideal for editor tooling: a build step that previews a brochure, a utility where a designer points a kiosk viewer at a new spec sheet, or a documentation widget that lets you eyeball a PDF without leaving Unreal. For a runtime, player-facing experience, configure the viewer actor's PDF File Path ahead of time (absolute, or via the relative-path helpers) and let it auto-load on play instead.
Two grounding notes. Simple PDF Viewer is Windows-only, with rendering backed by the bundled PDFium library, so this workflow targets Win64. And because it rasterises pages to textures (render resolution configurable up to 4096), it is an image-based viewer rather than a text-selectable reader; that is exactly what you want for showing a document on a surface, but do not expect form-filling or text extraction.
Next step: drop the demo level (L_Demo) into your project to see a working viewer, then graft the three steps above onto an Editor Utility Widget so picking and previewing a PDF becomes one button in your pipeline.
The three building blocks
| Function | What it returns / does | When to use it |
|---|---|---|
| OpenPDFFileDialog | Opens the native dialog, returns the selected file path (editor) | Let a user browse and pick a PDF from an editor tool |
| GetContentRelativePath | Resolves a Content-relative path to an absolute path | Loading a document stored inside the project Content folder |
| GetProjectRelativePath | Resolves a project-relative path to an absolute path | Loading a document stored relative to the project root |
| LoadPDFIntoViewer | Loads a path into a specific viewer actor | Send the chosen file to one target PDF Viewer |
The Blueprint library functions that turn a user's click into a rendered PDF. The file dialog is an editor utility.
FAQ
How do I open a file dialog to pick a PDF in Unreal Engine?
Use Simple PDF Viewer's 'OpenPDFFileDialog' Blueprint node from an editor context such as an Editor Utility Widget. It pops the native open file dialog and returns the path the user selected, which you then pass to 'LoadPDFIntoViewer'. Because it is an editor utility, use it in editor tools rather than packaged player builds.
Can I use the file dialog in a shipped, player-facing build?
OpenPDFFileDialog is part of the editor module, so it is intended for editor tooling and authoring steps. For runtime, configure the viewer actor's PDF File Path in advance (absolute, or via the content/project-relative path helpers) and let it auto-load on play.
My PDF path is relative. How do I turn it into something the loader accepts?
Run it through the matching helper: 'GetContentRelativePath' for paths anchored to the Content folder, or 'GetProjectRelativePath' for paths anchored to the project root. Both return an absolute path you can hand straight to LoadPDFIntoViewer.
What happens after the PDF loads?
Bind the viewer's events: 'OnPDFLoaded' gives you the page count, 'OnPDFLoadFailed' returns an error message if the file cannot be read, and 'OnPageChanged' fires during navigation. Drive paging with NextPage, PreviousPage, and GoToPage.
Does it support encrypted PDFs?
Yes. The load call accepts an optional password parameter, so an editor tool can prompt the user for a password and pass it through when opening a protected document.
Simple PDF Viewer
Display PDFs inside Unreal — render pages to textures on meshes and actors with page navigation, a Blueprint API for loading and querying documents, and editor utilities to preview and auto-build the display material. Powered by PDFium; no telemetry.