Am 01.07.2015 um 04:57 schrieb Mark Bolduc:
Thanks, I am brand new to PDFBox,

Note that PDFBox is rather low-level compared to PDFBox. You need to do a lot yourself. It helps to look at the PDF specification.


Does anyone have a method to create a rectangle with rounded corners?

in a PDPageContentStrean use

/**
     * Set the line join style.
* @param lineJoinStyle 0 for miter join, 1 for round join, and 2 for bevel join. * @throws IOException If there is an error while writing to the stream.
     */
    public void setLineJoinStyle(int lineJoinStyle) throws IOException

/**
     * Add a rectangle to the current path.
     *
     * @param x The lower left x coordinate.
     * @param y The lower left y coordinate.
     * @param width The width of the rectangle.
     * @param height The height of the rectangle.
* @throws IOException If there is an error while drawing on the screen.
     */
public void addRect(float x, float y, float width, float height) throws IOException


    /**
     * Stroke the path.
     *
     * @throws IOException If there is an error while stroking the path.
     */
    public void stroke() throws IOException


to understand about content streams, download the source code and look a the examples. Here's one that creates filled boxes:

            PDDocument doc = new PDDocument();

            PDPage page = new PDPage();
            doc.addPage( page );

PDPageContentStream contentStream = new PDPageContentStream(doc, page);
            //first fill the entire background with cyan
            contentStream.setNonStrokingColor( Color.CYAN );
contentStream.fillRect( 0,0, page.findMediaBox().getWidth(), page.findMediaBox().getHeight() );

            //then draw a red box in the lower left hand corner
            contentStream.setNonStrokingColor( Color.RED );
            contentStream.fillRect( 10, 10, 100, 100 );

            contentStream.close();
            doc.save( file );



---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to