May 1, 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]( library.


Result:  Floor1-report.PDF

How to use:


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

<script src=""></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);'report-floor1.pdf')

All done !

You can find a complete example on GitHub here:

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

Follow me on Twitter @micbeale

Related Posts

July 11, 2019

New Autodesk Forge Viewer 7.0 is Now Available

Autodesk Forge is our collection of Application Program Interfaces (APIs), documentation, sample code, and a community of cust

Read More

July 10, 2019

Look for exact property value and more

When using the search() function of the Viewer, you can only look for strings that at least partially match a given value.

Read More

July 9, 2019

Webpack and three.js in forge applications

In the newer versions of forge viewers( v6 and above) three.js is included in the forge viwer js file itself.

Read More