A Unity library to render PDF files inside your Unity scene.
This Unity library is built on top of:
This project is developed and maintained in my spare time. If it has saved you time or helped you build something cool, please consider buying me a coffee to say thanks!
Your support keeps me caffeinated and motivated to work on new features and bug fixes.
- Place your PDF file(s) inside the Unity
StreamingAssetsfolder. - In your scene, create a GameObject for each PDF file you want to display.
- Attach the
PdfViewerUIcomponent to the GameObject.
- RawImage: assign a
RawImageUI element where the PDF pages will be rendered. - PDF File Name: set the name of your PDF file (e.g.
document.pdf) when calling theLoadPDF()method (it will take the correct path from the StreamingAssets folder automatically).
- Navigation buttons: assign
NextandPreviousButtoncomponents to allow page navigation. - Page indicator: assign a
TextMeshProUGUItext component. It will automatically display the format:currentPage / totalPagesas the user browses the PDF.
- Create a
Canvaswith aRawImage. - Create an empty
GameObjectnamedPdfViewer. - Attach
PdfViewerUItoPdfViewer. - Drag the
RawImagefrom the Canvas into the Raw Image field of the component. - Set PDF File Name to
document.pdf. - (Optional) Add navigation buttons and link them to the component fields
- If you want to call the available public methods in code:
pdfViewerUI = GetComponent<PDFViewerUI>();
pdfViewerUI.LoadPDF(pdfFileName);
// Then you can use:
pdfViewerUI.NextPage();
pdfViewerUI.PreviousPage();
pdfViewerUI.GoToPage(3); // Go to page 3Press play → the PDF is loaded and displayed in the UI.
- Open your project and navigate to
Window→Package Manager. - Click on the
+button (top-left corner) and selectInstall package from git URL.... - Enter the following URL and confirm with the
Installbutton:
https://github.com/kdpkke/UnityPDFViewer.git?path=etc/UnityPackage
This project is licensed under the MIT License – see the LICENSE file for details.