Generating PDF files with JavaScript

后端 未结 6 1251
悲哀的现实
悲哀的现实 2020-11-22 05:45

I’m trying to convert XML data into PDF files from a web page and I was hoping I could do this entirely within JavaScript. I need to be able to draw text, images and simple

6条回答
  •  不要未来只要你来
    2020-11-22 06:49

    I've just written a library called jsPDF which generates PDFs using Javascript alone. It's still very young, and I'll be adding features and bug fixes soon. Also got a few ideas for workarounds in browsers that do not support Data URIs. It's licensed under a liberal MIT license.

    I came across this question before I started writing it and thought I'd come back and let you know :)

    Generate PDFs in Javascript

    Example create a "Hello World" PDF file.

    // Default export is a4 paper, portrait, using milimeters for units
    var doc = new jsPDF()
    
    doc.text('Hello world!', 10, 10)
    doc.save('a4.pdf')

提交回复
热议问题