/** * Gets the page rotation. This value can be 0, 90, 180 or 270. * * @param index * the page number. The first page is 1 * @return the page rotation */ public int getPageRotation(int index) { return getPageRotation(pageRefs.getPageNRelease(index)); }
/** * Gets the page rotation. This value can be 0, 90, 180 or 270. * @param index the page number. The first page is 1 * @return the page rotation */ public int getPageRotation(int index) { return getPageRotation(pageRefs.getPageNRelease(index)); }
/** * Gets the page rotation. This value can be 0, 90, 180 or 270. * @param index the page number. The first page is 1 * @return the page rotation */ public int getPageRotation(int index) { return getPageRotation(pageRefs.getPageNRelease(index)); }
public void addBlankPage(PdfReader reader) { pdfCopy.addPage(reader.getPageSize(1), reader.getPageRotation(1)); numberOfCopiedPages++; }
/** * Gets the rotated page from a page dictionary. * @param page the page dictionary * @return the rotated page */ public Rectangle getPageSizeWithRotation(PdfDictionary page) { Rectangle rect = getPageSize(page); int rotation = getPageRotation(page); while (rotation > 0) { rect = rect.rotate(); rotation -= 90; } return rect; }
/** * Gets the rotated page from a page dictionary. * @param page the page dictionary * @return the rotated page */ public Rectangle getPageSizeWithRotation(PdfDictionary page) { Rectangle rect = getPageSize(page); int rotation = getPageRotation(page); while (rotation > 0) { rect = rect.rotate(); rotation -= 90; } return rect; }
/** * Gets the rotated page from a page dictionary. * * @param page * the page dictionary * @return the rotated page */ public Rectangle getPageSizeWithRotation(PdfDictionary page) { Rectangle rect = getPageSize(page); int rotation = getPageRotation(page); while (rotation > 0) { rect = rect.rotate(); rotation -= 90; } return rect; }
PdfReader reader = new PdfReader(SOURCE); int n = reader.getNumberOfPages(); int rot; PdfDictionary pageDict; for (int i = 1; i <= n; i++) { rot = reader.getPageRotation(i); pageDict = reader.getPageN(i); pageDict.put(PdfName.ROTATE, new PdfNumber(rot + 90)); } PdfStamper stamper = new PdfStamper(reader, new FileOutputStream(RESULT)); stamper.close(); reader.close();
/** * apply the rotation to the given page if necessary * * @param pageNmber */ private void apply(int pageNmber) { if (pages.contains(pageNmber)) { PdfDictionary dictionary = reader.getPageN(pageNmber); dictionary.put(PdfName.ROTATE, new PdfNumber(rotation.addRotation(getRotation(reader.getPageRotation(pageNmber))) .getDegrees())); } } }
void replacePage(PdfReader r, int pageImported, int pageReplaced) { PdfDictionary pageN = this.reader.getPageN(pageReplaced); if (this.pagesToContent.containsKey(pageN)) throw new IllegalStateException("This page cannot be replaced: new content was already added"); PdfImportedPage p = getImportedPage(r, pageImported); PdfDictionary dic2 = this.reader.getPageNRelease(pageReplaced); dic2.remove(PdfName.RESOURCES); dic2.remove(PdfName.CONTENTS); moveRectangle(dic2, r, pageImported, PdfName.MEDIABOX, "media"); moveRectangle(dic2, r, pageImported, PdfName.CROPBOX, "crop"); moveRectangle(dic2, r, pageImported, PdfName.TRIMBOX, "trim"); moveRectangle(dic2, r, pageImported, PdfName.ARTBOX, "art"); moveRectangle(dic2, r, pageImported, PdfName.BLEEDBOX, "bleed"); dic2.put(PdfName.ROTATE, new PdfNumber(r.getPageRotation(pageImported))); PdfContentByte cb = getOverContent(pageReplaced); cb.addTemplate(p, 0, 0); PageStamp ps = (PageStamp)this.pagesToContent.get(pageN); ps.replacePoint = ps.over.getInternalBuffer().size(); }
void replacePage(PdfReader r, int pageImported, int pageReplaced) { PdfDictionary pageN = reader.getPageN(pageReplaced); if (pagesToContent.containsKey(pageN)) throw new IllegalStateException(MessageLocalization.getComposedMessage("this.page.cannot.be.replaced.new.content.was.already.added")); PdfImportedPage p = getImportedPage(r, pageImported); PdfDictionary dic2 = reader.getPageNRelease(pageReplaced); dic2.remove(PdfName.RESOURCES); dic2.remove(PdfName.CONTENTS); moveRectangle(dic2, r, pageImported, PdfName.MEDIABOX, "media"); moveRectangle(dic2, r, pageImported, PdfName.CROPBOX, "crop"); moveRectangle(dic2, r, pageImported, PdfName.TRIMBOX, "trim"); moveRectangle(dic2, r, pageImported, PdfName.ARTBOX, "art"); moveRectangle(dic2, r, pageImported, PdfName.BLEEDBOX, "bleed"); dic2.put(PdfName.ROTATE, new PdfNumber(r.getPageRotation(pageImported))); PdfContentByte cb = getOverContent(pageReplaced); cb.addTemplate(p, 0, 0); PageStamp ps = (PageStamp)pagesToContent.get(pageN); ps.replacePoint = ps.over.getInternalBuffer().size(); }
void replacePage(PdfReader r, int pageImported, int pageReplaced) { PdfDictionary pageN = reader.getPageN(pageReplaced); if (pagesToContent.containsKey(pageN)) throw new IllegalStateException(MessageLocalization.getComposedMessage("this.page.cannot.be.replaced.new.content.was.already.added")); PdfImportedPage p = getImportedPage(r, pageImported); PdfDictionary dic2 = reader.getPageNRelease(pageReplaced); dic2.remove(PdfName.RESOURCES); dic2.remove(PdfName.CONTENTS); moveRectangle(dic2, r, pageImported, PdfName.MEDIABOX, "media"); moveRectangle(dic2, r, pageImported, PdfName.CROPBOX, "crop"); moveRectangle(dic2, r, pageImported, PdfName.TRIMBOX, "trim"); moveRectangle(dic2, r, pageImported, PdfName.ARTBOX, "art"); moveRectangle(dic2, r, pageImported, PdfName.BLEEDBOX, "bleed"); dic2.put(PdfName.ROTATE, new PdfNumber(r.getPageRotation(pageImported))); PdfContentByte cb = getOverContent(pageReplaced); cb.addTemplate(p, 0, 0); PageStamp ps = (PageStamp)pagesToContent.get(pageN); ps.replacePoint = ps.over.getInternalBuffer().size(); }
int rotation = reader.getPageRotation(page); ret[ptr++] = page; if (rotation != 0) {
Rectangle r = PdfReader.getNormalizedRectangle(rect); int page = item.getPage(k).intValue(); int rotation = reader.getPageRotation(page); ret[ptr++] = page; if (rotation != 0) {
this.pageRect.normalize(); this.page = item.getPage(0).intValue(); final int rotation = this.writer.reader.getPageRotation(this.page); final Rectangle pageSize = this.writer.reader.getPageSizeWithRotation(this.page); switch (rotation) {
PdfRectangle rect = (PdfRectangle)annot.get(PdfName.RECT); 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) {
pageRect.normalize(); page = item.getPage(0).intValue(); int rotation = writer.reader.getPageRotation(page); Rectangle pageSize = writer.reader.getPageSizeWithRotation(page); switch (rotation) {
Rectangle r = PdfReader.getNormalizedRectangle(rect); int page = item.getPage(k).intValue(); int rotation = reader.getPageRotation(page); ret[ptr++] = page; if (rotation != 0) {
PdfRectangle rect = (PdfRectangle) annot.get(PdfName.RECT); 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) {
pageRect.normalize(); page = item.getPage(0); int rotation = writer.reader.getPageRotation(page); Rectangle pageSize = writer.reader.getPageSizeWithRotation(page); switch (rotation) {