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