/** Gets the page size, taking rotation into account. This * is a <CODE>Rectangle</CODE> with the value of the /MediaBox and the /Rotate key. * @param index the page number. The first page is 1 * @return a <CODE>Rectangle</CODE> */ public Rectangle getPageSizeWithRotation(final int index) { return getPageSizeWithRotation(pageRefs.getPageNRelease(index)); }
/** Gets the page size, taking rotation into account. This * is a <CODE>Rectangle</CODE> with the value of the /MediaBox and the /Rotate key. * @param index the page number. The first page is 1 * @return a <CODE>Rectangle</CODE> */ public Rectangle getPageSizeWithRotation(final int index) { return getPageSizeWithRotation(pageRefs.getPageNRelease(index)); }
private String createWatermark(String path, final ArrayList<File> mFileList) throws IOException, DocumentException { String finalOutputFile = mFileUtils.getUniqueFileName(path.replace(mContext.getString(R.string.pdf_ext), mContext.getString(R.string.watermarked_file)), mFileList); PdfReader reader = new PdfReader(path); PdfStamper stamper = new PdfStamper(reader, new FileOutputStream(finalOutputFile)); Font font = new Font(this.mWatermark.getFontFamily(), this.mWatermark.getTextSize(), this.mWatermark.getFontStyle(), this.mWatermark.getTextColor()); Phrase p = new Phrase(this.mWatermark.getWatermarkText(), font); PdfContentByte over; Rectangle pagesize; float x, y; int n = reader.getNumberOfPages(); for (int i = 1; i <= n; i++) { // get page size and position pagesize = reader.getPageSizeWithRotation(i); x = (pagesize.getLeft() + pagesize.getRight()) / 2; y = (pagesize.getTop() + pagesize.getBottom()) / 2; over = stamper.getUnderContent(i); ColumnText.showTextAligned(over, Element.ALIGN_CENTER, p, x, y, this.mWatermark.getRotationAngle()); } stamper.close(); reader.close(); new DatabaseHelper(mContext).insertRecord(finalOutputFile, mContext.getString(R.string.watermarked)); return finalOutputFile; }
pagesize = reader.getPageSizeWithRotation(i); x = (pagesize.getLeft() + pagesize.getRight()) / 2; y = (pagesize.getTop() + pagesize.getBottom()) / 2;
PdfReader reader = _outputDevice.getReader(uri); PDFAsImage image = new PDFAsImage(uri); Rectangle rect = reader.getPageSizeWithRotation(PDFAsImage.pageNumberFromURI(uri)); image.setInitialWidth(rect.getWidth() * _outputDevice.getDotsPerPoint()); image.setInitialHeight(rect.getHeight() * _outputDevice.getDotsPerPoint());
void applyRotation(PdfDictionary pageN, ByteBuffer out) { if (!cstp.rotateContents) return; Rectangle page = reader.getPageSizeWithRotation(pageN); int rotation = page.getRotation(); switch (rotation) { case 90: out.append(PdfContents.ROTATE90); out.append(page.getTop()); out.append(' ').append('0').append(PdfContents.ROTATEFINAL); break; case 180: out.append(PdfContents.ROTATE180); out.append(page.getRight()); out.append(' '); out.append(page.getTop()); out.append(PdfContents.ROTATEFINAL); break; case 270: out.append(PdfContents.ROTATE270); out.append('0').append(' '); out.append(page.getRight()); out.append(PdfContents.ROTATEFINAL); break; } }
if (rect != null && (rect.left() != 0 || rect.right() != 0 || rect.top() != 0 || rect.bottom() != 0)) { int rotation = reader.getPageRotation(pageN); Rectangle pageSize = reader.getPageSizeWithRotation(pageN); switch (rotation) { case 90:
void applyRotation(PdfDictionary pageN, ByteBuffer out) { if (!rotateContents) return; Rectangle page = reader.getPageSizeWithRotation(pageN); int rotation = page.getRotation(); switch (rotation) { case 90: out.append(PdfContents.ROTATE90); out.append(page.getTop()); out.append(' ').append('0').append(PdfContents.ROTATEFINAL); break; case 180: out.append(PdfContents.ROTATE180); out.append(page.getRight()); out.append(' '); out.append(page.getTop()); out.append(PdfContents.ROTATEFINAL); break; case 270: out.append(PdfContents.ROTATE270); out.append('0').append(' '); out.append(page.getRight()); out.append(PdfContents.ROTATEFINAL); break; } }
void applyRotation(PdfDictionary pageN, ByteBuffer out) { if (!rotateContents) return; Rectangle page = reader.getPageSizeWithRotation(pageN); int rotation = page.getRotation(); switch (rotation) { case 90: out.append(PdfContents.ROTATE90); out.append(page.getTop()); out.append(' ').append('0').append(PdfContents.ROTATEFINAL); break; case 180: out.append(PdfContents.ROTATE180); out.append(page.getRight()); out.append(' '); out.append(page.getTop()); out.append(PdfContents.ROTATEFINAL); break; case 270: out.append(PdfContents.ROTATE270); out.append('0').append(' '); out.append(page.getRight()); out.append(PdfContents.ROTATEFINAL); break; } }
if (rect != null && (rect.left() != 0 || rect.right() != 0 || rect.top() != 0 || rect.bottom() != 0)) { int rotation = reader.getPageRotation(pageN); Rectangle pageSize = reader.getPageSizeWithRotation(pageN); switch (rotation) { case 90:
void applyRotation(PdfDictionary pageN, ByteBuffer out) { if (!cstp.rotateContents) return; Rectangle page = reader.getPageSizeWithRotation(pageN); int rotation = page.getRotation(); switch (rotation) { case 90: out.append(PdfContents.ROTATE90); out.append(page.getTop()); out.append(' ').append('0').append(PdfContents.ROTATEFINAL); break; case 180: out.append(PdfContents.ROTATE180); out.append(page.getRight()); out.append(' '); out.append(page.getTop()); out.append(PdfContents.ROTATEFINAL); break; case 270: out.append(PdfContents.ROTATE270); out.append('0').append(' '); out.append(page.getRight()); out.append(PdfContents.ROTATEFINAL); break; } }
page = item.getPage(0).intValue(); int rotation = writer.reader.getPageRotation(page); Rectangle pageSize = writer.reader.getPageSizeWithRotation(page); switch (rotation) { case 90:
if (rect != null && (rect.left() != 0 || rect.right() != 0 || rect.top() != 0 || rect.bottom() != 0)) { int rotation = reader.getPageRotation(pageN); Rectangle pageSize = reader.getPageSizeWithRotation(pageN); switch (rotation) { case 90:
page = item.getPage(0).intValue(); int rotation = writer.reader.getPageRotation(page); Rectangle pageSize = writer.reader.getPageSizeWithRotation(page); switch (rotation) { case 90:
if (rect != null && (rect.left() != 0 || rect.right() != 0 || rect.top() != 0 || rect.bottom() != 0)) { int rotation = reader.getPageRotation(pageN); Rectangle pageSize = reader.getPageSizeWithRotation(pageN); switch (rotation) { case 90: