The sample below shows how to set page size during PDF generation in JavaScript with BytescoutPDF.js (Bytescout PDF Generator for JavaScript).
You can select one of 12 predefined page sizes for PDF file you create.
// 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"); // set page size. // select one of predefined page sizes: // BytescoutPDF.A0 // BytescoutPDF.A1 // BytescoutPDF.A2 // BytescoutPDF.A3 // BytescoutPDF.A4 // BytescoutPDF.A5 // BytescoutPDF.A6 // BytescoutPDF.A7 // BytescoutPDF.Letter // BytescoutPDF.Legal // BytescoutPDF.Executive // BytescoutPDF.JisB5 pdf.pageSetSize(BytescoutPDF.Letter); // add new page pdf.pageAdd(); pdf.textAdd(50, 50, '"Letter" page size', 0); // return BytescoutPDF object instance return pdf; }
Generated PDF file with predefined page size (click to view full size):