Like! JsPDF-powerful HTML5-based PDF generation tool

Source: Internet
Author: User

JsPDF isHTML5Client solution, used to generate PDF documents for various purposes. The method is simple. You only need to introduce the jsPDF library and then call the built-in method. Browser compatibility: IE 10, Firefox 3 +, Chrome, Safari 3 +, and Opera will be compatible with versions earlier than IE 10 in the future. For versions earlier than IE10, Downloadify will be used for file download.

Articles you may be interested in
  • We recommend 10 JavaScript development frameworks with rich UI components.
  • JQuery Wheel Menu: Beautiful Path-style rotation Menu
  • SlimerJS-Web developers can write JavaScript-controlled browsers
  • Chance-powerful JavaScript random number generation class library
  • Carefully selected 12 excellent jQuery Ajax paging plug-ins and tutorials

 

 

Example

1. Text

var doc = new jsPDF();doc.text(20, 20, 'This is the default font.');doc.setFont("courier");doc.setFontType("normal");doc.text(20, 30, 'This is courier normal.');doc.setFont("times");doc.setFontType("italic");doc.text(20, 40, 'This is times italic.');doc.setFont("helvetica");doc.setFontType("bold");doc.text(20, 50, 'This is helvetica bold.');doc.setFont("courier");doc.setFontType("bolditalic");doc.text(20, 60, 'This is courier bolditalic.');

2. Images

// You'll need to make your image into a Data URL// Use http://dataurl.net/#dataurlmakervar imgData = 'data:image/jpeg;base64,/9j/4AAQSkZJRgABAQEASABIAAD/4ge....../2Q==';var doc = new jsPDF();doc.setFontSize(40);doc.text(35, 25, "Octonyan loves jsPDF");doc.addImage(imgData, 'JPEG', 15, 40, 180, 180);

3. HTML

var doc = new jsPDF();// We'll make our own renderer to skip this editorvar specialElementHandlers = {'#editor': function(element, renderer){return true;}};// All units are in the set measurement for the document// This can be changed to "pt" (points), "mm" (Default), "cm", "in"doc.fromHTML($('#render_me').get(0), 15, 15, {'width': 170, 'elementHandlers': specialElementHandlers});

 

Articles you may be interested in
  • Manifesto-HTML5 Offline Application cache verification tool
  • Popline: a very special floating HTML5 text editor Toolbar
  • Bootstrap 3.0 was officially released to better support mobile development
  • JQuery Flat Shadow-easy to achieve beautiful long Shadow effect
  • Superhero: resources for building large JavaScript applications

 

Link to this article: likes! JsPDF-powerful HTML5-based PDF generation tool

Source: Dream sky ◆ focus on front-end development technology ◆ share web design resources

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.