How to generate a pdf of the graph generated by Treant JS

Asked

Viewed 63 times

0

In my system I have an organization chart generated based on Treant JS and I would like to export as PDF, but exploring through the plug-in page I did not find anything related, anyone knows any way this be done?

Image of the organization chart: inserir a descrição da imagem aqui

1 answer

0


I managed to do using a plug-in called html2canvas, he is much like the html2pdf only you can make bigger images, following example

//HTML
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<script src="http://html2canvas.hertzen.com/dist/html2canvas.js"></script>

<div id="print">
    <h1>Exemple text</h1>
    <p>Sed ut perspiciatis unde omnis iste natus error sit voluptatem accusantium doloremque laudantium, totam rem aperiam, eaque ipsa quae ab </p>
</div>
<div id="printDiv"></div>
<button id="takePrint">Take a print</button>


//JS Code
$("#takePrint").on('click',function(){
    html2canvas(document.querySelector("#print")).then(canvas => {
        document.body.appendChild(canvas);
    });
})

Browser other questions tagged

You are not signed in. Login or sign up in order to post.