/** * Outputs a {@code char} directly to the content. * * @param c the {@code char} * @return current canvas. */ public PdfCanvas writeLiteral(char c) { contentStream.getOutputStream().writeInteger((int) c); return this; }
/** * Sets text rendering mode. * * @param textRenderingMode text rendering mode @see PdfCanvasConstants. * @return current canvas. */ public PdfCanvas setTextRenderingMode(int textRenderingMode) { currentGs.setTextRenderingMode(textRenderingMode); contentStream.getOutputStream() .writeInteger(textRenderingMode).writeSpace() .writeBytes(Tr); return this; }
private void write(PdfIndirectReference indirectReference) { if (document != null && !indirectReference.getDocument().equals(document)) { throw new PdfException(PdfException.PdfIndirectObjectBelongsToOtherPdfDocument); } if (indirectReference.isFree()) { Logger logger = LoggerFactory.getLogger(PdfOutputStream.class); logger.error(LogMessageConstant.FLUSHED_OBJECT_CONTAINS_FREE_REFERENCE); write(PdfNull.PDF_NULL); } else if (indirectReference.getRefersTo() == null) { Logger logger = LoggerFactory.getLogger(PdfOutputStream.class); logger.error(LogMessageConstant.FLUSHED_OBJECT_CONTAINS_REFERENCE_WHICH_NOT_REFER_TO_ANY_OBJECT); write(PdfNull.PDF_NULL); } else if (indirectReference.getGenNumber() == 0) { writeInteger(indirectReference.getObjNumber()). writeBytes(endIndirectWithZeroGenNr); } else { writeInteger(indirectReference.getObjNumber()). writeSpace(). writeInteger(indirectReference.getGenNumber()). writeBytes(endIndirect); } }
/** * Sets the line cap style, the shape to be used at the ends of open subpaths * when they are stroked. * * @param lineCapStyle * @return current canvas. * @see PdfCanvasConstants.LineCapStyle for possible values. */ public PdfCanvas setLineCapStyle(int lineCapStyle) { if (currentGs.getLineCapStyle() == lineCapStyle) return this; currentGs.setLineCapStyle(lineCapStyle); contentStream.getOutputStream() .writeInteger(lineCapStyle).writeSpace() .writeBytes(J); return this; }
/** * Sets the line join style, the shape to be used at the corners of paths * when they are stroked. * * @param lineJoinStyle * @return current canvas. * @see PdfCanvasConstants.LineJoinStyle for possible values. */ public PdfCanvas setLineJoinStyle(int lineJoinStyle) { if (currentGs.getLineJoinStyle() == lineJoinStyle) return this; currentGs.setLineJoinStyle(lineJoinStyle); contentStream.getOutputStream() .writeInteger(lineJoinStyle).writeSpace() .writeBytes(j); return this; }
private void write(PdfNumber pdfNumber) { if (pdfNumber.hasContent()) { writeBytes(pdfNumber.getInternalContent()); } else if (pdfNumber.isDoubleNumber()) { writeDouble(pdfNumber.getValue()); } else { writeInteger(pdfNumber.intValue()); } }
/** * Writes object to body of PDF document. * * @param pdfObj object to write. * @throws IOException */ protected void writeToBody(PdfObject pdfObj) throws IOException { if (crypto != null) { crypto.setHashKeyForNextObject(pdfObj.getIndirectReference().getObjNumber(), pdfObj.getIndirectReference().getGenNumber()); } writeInteger(pdfObj.getIndirectReference().getObjNumber()). writeSpace(). writeInteger(pdfObj.getIndirectReference().getGenNumber()).writeBytes(obj); write(pdfObj); writeBytes(endobj); }
int first = (int) sections.get(k); int len = (int) sections.get(k + 1); writer.writeInteger(first).writeSpace().writeInteger(len).writeByte((byte) '\n'); for (int i = first; i < first + len; i++) { PdfIndirectReference reference = xrefTable.get(i);
/** * Adds object to the object stream. * * @param object object to add. */ public void addObject(PdfObject object) { if (size.intValue() == MAX_OBJ_STREAM_SIZE) { throw new PdfException(PdfException.PdfObjectStreamReachMaxSize); } PdfOutputStream outputStream = getOutputStream(); indexStream.writeInteger(object.getIndirectReference().getObjNumber()). writeSpace(). writeLong(outputStream.getCurrentPos()). writeSpace(); outputStream.write(object); object.getIndirectReference().setObjStreamNumber(getIndirectReference().getObjNumber()); object.getIndirectReference().setIndex(size.intValue()); outputStream.writeSpace(); size.increment(); getAsNumber(PdfName.First).setValue(indexStream.getCurrentPos()); }