PDF24 Javascript PDF API

Khái quát

PDF24.org provides a free PDF generation service to create PDF files. This Javascript API is an interface to this service.

The API has been developed for blogs, foren, wiki systems and other article-based internet software to create PDF files in an easy way. Developer of blogs, foren and wiki systems can use this API to provide a PDF button.

API Location

The API is located at https://doc2pdf.pdf24.org/js/api.js.

Class References

There are two main Javascript classes which have to be used to create a PDF files. The class PDF24Doc provides the functionality to manage general document content such as document title or document url and provides methods to add elements to the document.
The class PDF24Element represents a content element inside a PDF24Doc document. A content element is a container holding some data such as a title and a html body.

The following table illustrates that:
PDF24Element 1
PDF24Element 2
PDF24Element 3

Class PDF24Doc


The charset of the document. Default is ISO-8859-1. Curently supported values are ISO-8859-1 and UTF-8.
The headline of the document.
The headline url of the headline.
The baseUrl of the document. This url is important if you use relative links in body content of elements. This url is used to resolve relative links to find images and other content.
The filename of the created PDF file e.g. myFileName.
The size of each page in the document. The size is encoded as WIDTHxHEIGHT whereas WIDTH is the width of each page in mm and HEIGHT is the height of each page in mm. The default width is 210mm and the default height is 297mm which represents an ISO A4 page.


Creates a document object with no parameters. Use the setXX methods to set parameters later.
Creates a document object and initialized the document parameters with the parameters given in params


Adds the element element to the PDF document.
setParam(paramKey, paramValue)
Sets a document parameter with the key paramKey and the value paramValue.
Returns the document parameter with the key paramKey.
Sets the charset parameter of the document to charset. The default charset is ISO-8859-1.
Sets the headline parameter of the document to headline.
Sets the headlineUrl parameter of the document to headlineUrl.
Sets the baseUrl parameter of the document to baseUrl.
Sets the filename parameter of the document to filename.
setPageSize(width, height)
Sets the pageSize parameter of the document to width, height.
This method packs all given parameters into a formular and submits it in a popup window to the PDF24.org PDF creation service. The service checks the parameters and creates the PDF file. Status methods are printed to the popup window so that the user can see PDF creation status.

Class PDF24Element


The title of the element.
The url of the element. The title and the url are used to form a link.
The author of the elements content.
A timestamp (Any string that represents a timestamp, e.g. date and time or only date or time)
The content of the element. Can be plain or html formated text.


Creates an element with no parameters. Use the setXX methods to set parameters later.


Sets the title parameter of the element to title.
Sets the url parameter of the element to url. The title and the url together form a link.
Sets the author parameter of the element to author.
Sets the dateTime parameter of the element to dateTime.
Sets the body parameter of the element to body. body can be plain or html formatted text.

Code Samples

Include the Javscript PDF API in you document by adding the following line to your webpage:

<script type="text/javascript" src="http://doc2pdf.pdf24.org/js/api.js"></script>
* Create a document with parameters
var doc = new PDF24Doc({
	charset : "UTF-8",
	headline : "This ist the headline",
	headlineUrl : "http://www.pdf24.org",
	baseUrl : "http://www.pdf24.org",
	filename : "test",
	pageSize : "210x297"
	emailTo : "stefanz@pdf24.org",
	emailFrom : "stefanz@pdf24.org",
	emailSubject: "Here is your created PDF files",
	emailBody: "The created PDF file is attached to this email. Regards www.pdf24.org!"
	emailBodyType: "text"

* Add an element without using PDF24Element
	title : "This is a title",
	url : "http://www.pdf24.org",
	author : "Stefan Ziegler",
	dateTime : "2010-04-15 8:00",
	body : "THis is the content of the element"

* Create the PDF file
Quảng cáo
Word sang PDF / Dễ dàng tạo file PDF!
Tài liệu sang file PDF
Chuyển đồi tài liệu sang file PDF trong 3 bước
Hãy thể hiện khả năng của bạn!
Thiết kế Công cụ tạo file PDF của riêng bạn
Tải hình ảnh và tạo công cụ tạo file PDF của riêng bạn!
Bộ công cụ PLUGIN file PDF
Miễn phí 100% Plugin | 100% phần mềm gián điệp | 100% phần mềm bảo mật!
PDF Plguin Wordpress PDF Plugin Webmaster PDF Plugin phpBB PDF Plugin Blogger PDF Plugin