/** * Draw a polygon on the page using the current stroking color. * @param x x coordinate of each points * @param y y coordinate of each points * @throws IOException If there is an error while drawing on the screen. * @throws IllegalStateException If the method was called within a text block. * @deprecated Use {@link #moveTo} and {@link #lineTo} methods instead. */ @Deprecated public void drawPolygon(float[] x, float[] y) throws IOException { if (inTextMode) { throw new IllegalStateException("Error: drawPolygon is not allowed within a text block."); } addPolygon(x, y); stroke(); }
/** * Draw a line on the page using the current stroking color and the current line width. * * @param xStart The start x coordinate. * @param yStart The start y coordinate. * @param xEnd The end x coordinate. * @param yEnd The end y coordinate. * @throws IOException If there is an error while drawing on the screen. * @throws IllegalStateException If the method was called within a text block. * @deprecated Use {@link #moveTo moveto(xStart,yStart)} followed by * {@link #lineTo lineTo(xEnd,yEnd)} followed by {@link #stroke stroke()}. */ @Deprecated public void drawLine(float xStart, float yStart, float xEnd, float yEnd) throws IOException { if (inTextMode) { throw new IllegalStateException("Error: drawLine is not allowed within a text block."); } moveTo(xStart, yStart); lineTo(xEnd, yEnd); stroke(); }
public void stroke() { try { cs.stroke(); } catch (IOException e) { logAndThrow("stroke", e); } }
public void stroke() { try { cs.stroke(); } catch (IOException e) { logAndThrow("stroke", e); } }
/** * Draw a polygon on the page using the current stroking color. * @param x x coordinate of each points * @param y y coordinate of each points * @throws IOException If there is an error while drawing on the screen. * @throws IllegalStateException If the method was called within a text block. * @deprecated Use {@link #moveTo} and {@link #lineTo} methods instead. */ @Deprecated public void drawPolygon(float[] x, float[] y) throws IOException { if (inTextMode) { throw new IllegalStateException("Error: drawPolygon is not allowed within a text block."); } addPolygon(x, y); stroke(); }
private void drawLine( PDPageContentStream content, float xstart, float ystart, float xend, float yend ){ content.moveTo(xstart, ystart); // moves "pencil" to a position content.lineTo(xend, yend); // creates an invisible line to another position content.stroke(); // makes the line visible }
/** * Draw a polygon on the page using the current stroking color. * @param x x coordinate of each points * @param y y coordinate of each points * @throws IOException If there is an error while drawing on the screen. * @throws IllegalStateException If the method was called within a text block. * @deprecated Use {@link #moveTo} and {@link #lineTo} methods instead. */ @Deprecated public void drawPolygon(float[] x, float[] y) throws IOException { if (isInTextMode()) { throw new IllegalStateException("Error: drawPolygon is not allowed within a text block."); } addPolygon(x, y); stroke(); }
/** * Draw a line on the page using the current stroking color and the current line width. * * @param xStart The start x coordinate. * @param yStart The start y coordinate. * @param xEnd The end x coordinate. * @param yEnd The end y coordinate. * @throws IOException If there is an error while drawing on the screen. * @throws IllegalStateException If the method was called within a text block. * @deprecated Use {@link #moveTo moveto(xStart,yStart)} followed by * {@link #lineTo lineTo(xEnd,yEnd)} followed by {@link #stroke stroke()}. */ @Deprecated public void drawLine(float xStart, float yStart, float xEnd, float yEnd) throws IOException { if (inTextMode) { throw new IllegalStateException("Error: drawLine is not allowed within a text block."); } moveTo(xStart, yStart); lineTo(xEnd, yEnd); stroke(); }
/** * Draw a line on the page using the current stroking color and the current line width. * * @param xStart The start x coordinate. * @param yStart The start y coordinate. * @param xEnd The end x coordinate. * @param yEnd The end y coordinate. * @throws IOException If there is an error while drawing on the screen. * @throws IllegalStateException If the method was called within a text block. * @deprecated Use {@link #moveTo moveto(xStart,yStart)} followed by * {@link #lineTo lineTo(xEnd,yEnd)} followed by {@link #stroke stroke()}. */ @Deprecated public void drawLine(float xStart, float yStart, float xEnd, float yEnd) throws IOException { if (isInTextMode()) { throw new IllegalStateException("Error: drawLine is not allowed within a text block."); } moveTo(xStart, yStart); lineTo(xEnd, yEnd); stroke(); }
void drawRect(PDPageContentStream content, Color color, Rectangle rect, boolean fill) { content.addRect(rect.x, rect.y, rect.width, rect.height); if (fill) { content.setNonStrokingColor(color); content.fill(); } else { content.setStrokingColor(color); content.stroke(); } }
private void drawLine(float xStart, float yStart, float xEnd, float yEnd, LineStyle border) throws IOException { PDStreamUtils.setLineStyles(tableContentStream, border); tableContentStream.moveTo(xStart, yStart); tableContentStream.lineTo(xEnd, yEnd); tableContentStream.stroke(); tableContentStream.closePath(); }
stream.moveTo(textX, y); stream.lineTo(textX + titleWidth, y); stream.stroke(); } catch (final IOException e) { throw new IllegalStateException("Unable to underline text", e);
@Override public void commit(PDPageContentStream stream) throws IOException { stream.setStrokingColor(style.color()); stream.setLineWidth(toFloat(style.width())); stream.moveTo(toFloat(x1), toFloat(y1)); stream.lineTo(toFloat(x2), toFloat(y2)); stream.stroke(); } }
PDDocument doc = new PDDocument(); PDPage pdpage = new PDPage(); doc.addPage(pdpage); PDPageContentStream stream = new PDPageContentStream(doc, pdpage, false, false); // move stuff a bit up and right stream.concatenate2CTM(AffineTransform.getTranslateInstance(100, 400)); stream.setStrokingColorSpace(PDDeviceRGB.INSTANCE); stream.setStrokingColor(Color.red); stream.setLineWidth(10f); stream.moveTo(1, 1); stream.addBezier32(111, 075, 200, 200); stream.addBezier32(352, 124, 80, 80); stream.addBezier32(432, 333, 300, 333); stream.stroke(); stream.close(); doc.save(filename); doc.close();
contentStream.stroke();