Return to Snippet

Revision: 72666
at October 12, 2017 22:27 by markt22


Initial Code
/**
 * @param args the command line arguments
 * @throws java.io.IOException
 */
public static void main(String[] args) throws IOException {
    PDDocument document = new PDDocument();
    PDPage page = new PDPage(PDRectangle.A4);
 
    document.addPage(page);
 
    PDPageContentStream contentStream = new PDPageContentStream(document, page);
    
    contentStream.setNonStrokingColor(Color.RED);
    contentStream.addRect(100, 100, 100, 100);
    contentStream.fill();
    
    contentStream.close();
 
    document.save("");
    document.close();
}

Initial URL

                                

Initial Description
Creates a new document with one page and draws a rectangle on it.

Initial Title
PDFBox: Draw rectangle on page

Initial Tags

                                

Initial Language
Java