Frequently Asked Question:
Create multiple pages and set font size and family in VBScript
How do I create more than one page using VBScript?
How do I set the font size and font family?
Multiple documents in memory permitted.
You can have more than one document in memory and can swap between them using the ID returned from calls such functions as NewDocument and SelectedDocument. You can also count all documents in memory using the DocumentCount function and then retrieve each documents ID or filename using GetDocumentID or GetDocumentFileName. All of the document management related functions can be seen in the document management section in the function reference.
// We always start with a 1 blank page in memory
// The document and page are selected by default
// So we do not need to create a NewDocument() here.
int doc1 = QP.SelectedDocument();
QP.DrawText(10,10, "Document 1, Page1");
// Add a new page to the current document
int newpage = QP.NewPage();
// Select the page as the active page.
QP.SelectPage(newpage);
QP.DrawText(10,10, "Document 1, Page2");
// Create a 2nd document in memory.
doc2 = QP.NewDocument();
// Select it. doc1 is still in memory.
QP.SelectDocument(doc2);
QP.DrawText(10,10, "Document 2, Page1");
// Save to disk.
QP.SaveToFile("Document2.pdf");
// Reselect document 1
QP.SelectDocument(doc1);
// Save it to disk now.
QP.SaveToFile("Document1.pdf");
// Delete document 1 from memory.
QP.RemoveDocument(doc1);
// Delete document 2 from memory.
QP.RemoveDocument(doc2);
There are various functions for adding fonts:
- AddStandardFont
- AddSubsettedFont
- AddTrueTypeFont
- AddTrueTypeFontFromFile
- AddType1Font
fontid = QP.AddStandardFont(4); // Helvetica
QP.SelectFont(fontid);
QP.SetTextSize(10);
QP.DrawText(50, 50, "Helvetiva 10pt");