Java Code Examples for com.lowagie.text.Rectangle#getRotation()
The following examples show how to use
com.lowagie.text.Rectangle#getRotation() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: PdfCopy.java From itext2 with GNU Lesser General Public License v3.0 | 6 votes |
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; } }
Example 2
Source File: PdfStamperImp.java From gcs with Mozilla Public License 2.0 | 5 votes |
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; } }
Example 3
Source File: PdfCopy.java From gcs with Mozilla Public License 2.0 | 5 votes |
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; } }
Example 4
Source File: PdfStamperImp.java From itext2 with GNU Lesser General Public License v3.0 | 5 votes |
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; } }
Example 5
Source File: PdfAnnotationsImp.java From gcs with Mozilla Public License 2.0 | 4 votes |
public PdfArray rotateAnnotations(PdfWriter writer, Rectangle pageSize) { PdfArray array = new PdfArray(); int rotation = pageSize.getRotation() % 360; int currentPage = writer.getCurrentPageNumber(); for (int k = 0; k < annotations.size(); ++k) { PdfAnnotation dic = (PdfAnnotation) annotations.get(k); int page = dic.getPlaceInPage(); if (page > currentPage) { delayedAnnotations.add(dic); continue; } if (dic.isForm()) { if (!dic.isUsed()) { HashMap templates = dic.getTemplates(); if (templates != null) { acroForm.addFieldTemplates(templates); } } PdfFormField field = (PdfFormField) dic; if (field.getParent() == null) { acroForm.addDocumentField(field.getIndirectReference()); } } if (dic.isAnnotation()) { array.add(dic.getIndirectReference()); if (!dic.isUsed()) { PdfRectangle rect = (PdfRectangle) dic.get(PdfName.RECT); if (rect != null) { switch (rotation) { case 90: dic.put(PdfName.RECT, new PdfRectangle(pageSize.getTop() - rect.bottom(), rect.left(), pageSize.getTop() - rect.top(), rect.right())); break; case 180: dic.put(PdfName.RECT, new PdfRectangle(pageSize.getRight() - rect.left(), pageSize.getTop() - rect.bottom(), pageSize.getRight() - rect.right(), pageSize.getTop() - rect.top())); break; case 270: dic.put(PdfName.RECT, new PdfRectangle(rect.bottom(), pageSize.getRight() - rect.left(), rect.top(), pageSize.getRight() - rect.right())); break; } } } } if (!dic.isUsed()) { dic.setUsed(); try { writer.addToBody(dic, dic.getIndirectReference()); } catch (IOException e) { throw new ExceptionConverter(e); } } } return array; }
Example 6
Source File: PdfAnnotationsImp.java From itext2 with GNU Lesser General Public License v3.0 | 4 votes |
public PdfArray rotateAnnotations(PdfWriter writer, Rectangle pageSize) { PdfArray array = new PdfArray(); int rotation = pageSize.getRotation() % 360; int currentPage = writer.getCurrentPageNumber(); for (int k = 0; k < annotations.size(); ++k) { PdfAnnotation dic = (PdfAnnotation)annotations.get(k); int page = dic.getPlaceInPage(); if (page > currentPage) { delayedAnnotations.add(dic); continue; } if (dic.isForm()) { if (!dic.isUsed()) { HashMap templates = dic.getTemplates(); if (templates != null) acroForm.addFieldTemplates(templates); } PdfFormField field = (PdfFormField)dic; if (field.getParent() == null) acroForm.addDocumentField(field.getIndirectReference()); } if (dic.isAnnotation()) { array.add(dic.getIndirectReference()); if (!dic.isUsed()) { PdfRectangle rect = (PdfRectangle)dic.get(PdfName.RECT); if (rect != null) { switch (rotation) { case 90: dic.put(PdfName.RECT, new PdfRectangle( pageSize.getTop() - rect.bottom(), rect.left(), pageSize.getTop() - rect.top(), rect.right())); break; case 180: dic.put(PdfName.RECT, new PdfRectangle( pageSize.getRight() - rect.left(), pageSize.getTop() - rect.bottom(), pageSize.getRight() - rect.right(), pageSize.getTop() - rect.top())); break; case 270: dic.put(PdfName.RECT, new PdfRectangle( rect.bottom(), pageSize.getRight() - rect.left(), rect.top(), pageSize.getRight() - rect.right())); break; } } } } if (!dic.isUsed()) { dic.setUsed(); try { writer.addToBody(dic, dic.getIndirectReference()); } catch (IOException e) { throw new ExceptionConverter(e); } } } return array; }
Example 7
Source File: PdfContents.java From MesquiteCore with GNU Lesser General Public License v3.0 | 4 votes |
/** * Constructs a <CODE>PdfContents</CODE>-object, containing text and general graphics. * * @param under the direct content that is under all others * @param content the graphics in a page * @param text the text in a page * @param secondContent the direct content that is over all others * @throws BadPdfFormatException on error */ PdfContents(PdfContentByte under, PdfContentByte content, PdfContentByte text, PdfContentByte secondContent, Rectangle page) throws BadPdfFormatException { super(); try { OutputStream out = null; streamBytes = new ByteArrayOutputStream(); if (Document.compress) { compressed = true; out = new DeflaterOutputStream(streamBytes); } else out = streamBytes; int rotation = page.getRotation(); switch (rotation) { case 90: out.write(ROTATE90); out.write(DocWriter.getISOBytes(ByteBuffer.formatDouble(page.top()))); out.write(' '); out.write('0'); out.write(ROTATEFINAL); break; case 180: out.write(ROTATE180); out.write(DocWriter.getISOBytes(ByteBuffer.formatDouble(page.right()))); out.write(' '); out.write(DocWriter.getISOBytes(ByteBuffer.formatDouble(page.top()))); out.write(ROTATEFINAL); break; case 270: out.write(ROTATE270); out.write('0'); out.write(' '); out.write(DocWriter.getISOBytes(ByteBuffer.formatDouble(page.right()))); out.write(ROTATEFINAL); break; } if (under.size() > 0) { out.write(SAVESTATE); under.getInternalBuffer().writeTo(out); out.write(RESTORESTATE); } if (content.size() > 0) { out.write(SAVESTATE); content.getInternalBuffer().writeTo(out); out.write(RESTORESTATE); } if (text != null) { out.write(SAVESTATE); text.getInternalBuffer().writeTo(out); out.write(RESTORESTATE); } if (secondContent.size() > 0) { secondContent.getInternalBuffer().writeTo(out); } out.close(); } catch (Exception e) { throw new BadPdfFormatException(e.getMessage()); } put(PdfName.LENGTH, new PdfNumber(streamBytes.size())); if (compressed) put(PdfName.FILTER, PdfName.FLATEDECODE); }