How to Create PDF With Javascript
- 1). Create the PDF object. The PDF object provides you with the functions and properties to create and edit your PDF file. The following code creates the object:
pdf = new pdf$('', 0, 0); - 2). Set the font size. The font size determines the text size when you add content to the PDF file. The following code sets the font:
pdf.setFontSize(18); - 3). Add text to the PDF object. You can add several lines of text to the PDF file. After you have added all the text necessary for the PDF, write it to the file. The following code adds a simple line of text to the PDF object:
pdf.addText('This is PDF text for a file'); - 4). Write the content of the PDF to an actual file. The following code writes the content to a PDF file:
pdf.writeToFile('c:\myFile.pdf');
Source...