com.cete.dynamicpdf.pageelements
Class PageNumberingLabel


Example: The following example shows how to use page numbering in a document.

  import com.cete.dynamicpdf.*;
  import com.cete.dynamicpdf.pageelements.*;
 
  public class MyClass{
       public static void main(String args[]){
 
           // Create a PDF Document
           Document document = new Document();
 
           // Create a document template and add it to the document
           Template documentTemplate = new Template();
           document.setTemplate(documentTemplate);
 
           // Place a page numbering label in the document template
           documentTemplate.getElements().add( new PageNumberingLabel(
           "%%PR%%%%SP%% of %%ST%%", 0, 680, 512, 12, Font.getHelvetica(),
           12, TextAlign.CENTER));
 
           // Begin the first section
           document.getSections().begin( NumberingStyle.ROMAN_LOWERCASE );
 
           // Add three pages
           document.getPages().add(new Page()); //Page 1
           document.getPages().add(new Page()); //Page 2
           document.getPages().add(new Page()); //Page 3
 
           // Begin the second section
           document.getSections().begin(NumberingStyle.NUMERIC);
 
           // Add four pages
           document.getPages().add(new Page()); //Page 4
           document.getPages().add(new Page()); //page 5
           document.getPages().add(new Page()); //page 6
           document.getPages().add(new Page()); //page 7
 
           // Begin the third section specifying a section prefix
           document.getSections().begin( NumberingStyle.ROMAN_LOWERCASE,
           "Appendix A - " );
 
           // Add two pages
           document.getPages().add(new Page()); //page 8
           document.getPages().add(new Page()); //page 9
 
           // Save the PDF
           document.draw("[Physicalpath]/MyDocument.pdf" );
       }
 }