1 May 2018

Generate a PDF Report from Forge Viewer

Here is a quick way to generate a PDF report of the LMV canvas through the browser.
It uses the [jsPDF](https://parall.ax/products/jspdf) library.

DEMO  https://wallabyway.github.io/forge-pdf-report/

Result:  Floor1-report.PDF


Update (2020):

If you are having problems capturing the PDF, on mobile (IOS or Android), try using the following method instead:


How to use:


1. Add this to your `index.html` ...

<script src="https://unpkg.com/jspdf/dist/jspdf.min.js"></script>

2. Take a screenshot of LMV canvas using `getScreenShotBuffer()`, like this ...

 img => createPDF(img)); 


3. Then add the PNG into a new PDF using jsPDF, like this...


function createPDF(imgData) {
    var doc = new jsPDF()
    doc.text(35, 25, 'ForgeViewer PDF report');
    doc.addImage(imgData, 'JPEG', 10, 40, 180, 80);

All done !

You can find a complete example on GitHub here: https://github.com/wallabyway/forge-pdf-report

Feel free to add any issues you find to the Github issues repo.

Follow me on Twitter @micbeale

Related Article