Convert PDF to Image (JPEG, PNG, etc)

瀏覽次數:125 次
跳到第一則未讀訊息

ar m

未讀,
2021年3月12日 下午6:28:042021/3/12
收件者:PDFTron WebViewer
Hi,

I want to convert PDF to Image. I am trying to do it in plain javascript without using any server. is it possible? 

I tried using PDFNet.PDFDraw.exportBuffer, but it says PDFNet.PDFDraw.exportBuffer is not a function. 

Any Help would be appreciated.

Regards,

Matt Parizeau

未讀,
2021年3月15日 中午12:31:442021/3/15
收件者:PDFTron WebViewer
Hi,

Yes, you can definitely do this without using a server. It'll probably be easier using the Document APIs instead of PDFNet APIs, and faster too because you don't need to load the "full API". 


Note that from a browser canvas object you can use the toDataURL or toBlob functions to get the image data 

If you want to do it and you don't have a WebViewer instance already you can first create a Document object in memory using CoreControls.createDocument https://www.pdftron.com/documentation/web/guides/lower-level-doc-create-pdf/

That doc object is the exact same as what you get from docViewer.getDocument() so then you can call doc.loadCanvasAsync to get the rendered page.

Let me know if you have any other questions about this.

Matt Parizeau
Software Developer
PDFTron Systems Inc.

ar m

未讀,
2021年3月19日 中午12:22:472021/3/19
收件者:PDFTron WebViewer
Thanks. It was easy!
回覆所有人
回覆作者
轉寄
0 則新訊息