How to Draw Symbols When Creating PDF Document with JavaScript

  • Home
  • /
  • Articles
  • /
  • How to Draw Symbols When Creating PDF Document with JavaScript

This example demonstrates how to draw sybmols when creating PDF file in JavaScript with BytescoutPDF.js (Bytescout PDF Generator for JavaScript).

// function that creates BytescoutPDF instance (defined in BytescoutPDF.js script which have to be included into the same page)
// then calls API methods and properties to create PDF document
// and returns created BytescoutPDF object instance
// this CreatePDF() function is called from Sample.html

function CreatePDF() {

    // create BytescoutPDF object instance
    var pdf = new BytescoutPDF();

    // set document properties: Title, subject, keywords, author name and creator name
    pdf.propertiesSet("Sample document title", "Sample subject", "keyword1, keyword 2, keyword3", "Document Author Name", "Document Creator Name");

    // add new page

    // set font size

    // set Symbol symbolic font

	// info: char table of Symbol font
    pdf.textAdd(100, 50, 'u0041');
    pdf.textAdd(200, 50, 'u0022');

    // set ZapfDingbats symbolic font

	// info: char table of ZapfDingbats font
    pdf.textAdd(100, 150, "u2780");
    pdf.textAdd(200, 150, "u2776");

    // return BytescoutPDF object instance
    return pdf;

Generated PDF file with different symbols (click to view full size):

Click to view full size