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>
Sample 1
/*
* Create a PDF24 document and set parameters
*/
var doc = new PDF24Doc();
doc.setCharset("UTF-8");
doc.setHeadline("The is the document headline");
doc.setHeadlineUrl("http://www.pdf24.org");
doc.setBaseUrl("http://www.pdf24.org");
doc.setFilename("test");
doc.setPageSize(210, 297);
doc.setEmailTo("stefanz@pdf24.org");
doc.setEmailFrom("stefanz@pdf24.org");
doc.setEmailSubject("Here is your created PDF file");
doc.setEmailBody("The created PDF file is attached to this email. Regards www.pdf24.org!");
doc.setEmailBodyType("text");
/*
* Create one or more elements
*/
var element = new PDF24Element();
element.setTitle("This is a title");
element.setUrl("http://www.pdf24.org");
element.setAuthor("Stefan Ziegler");
element.setDateTime("2010-04-15 8:00");
element.setBody("This is the content of the element");
/*
* Add the element
*/
doc.addElement(element);
/*
* Create the PDF file
*/
doc.create();
Sample 2
/*
* 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
*/
doc.addElement({
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
*/
doc.create();