本文整理汇总了Java中com.lowagie.text.Rectangle.getRotation方法的典型用法代码示例。如果您正苦于以下问题:Java Rectangle.getRotation方法的具体用法?Java Rectangle.getRotation怎么用?Java Rectangle.getRotation使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.lowagie.text.Rectangle
的用法示例。
在下文中一共展示了Rectangle.getRotation方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: startPage
import com.lowagie.text.Rectangle; //导入方法依赖的package包/类
/**
* Any work to start off printing a page of the document
* m_currentPage will contain the page being printed, and
* m_currentTemplatePage will contain the template page number to base this
* new page on.
* @throws FormPrintException Thrown if there is any form processing problems
*/
protected void startPage() throws FormPrintException {
log.debug("startPage: Page=" + getCurrentPage());
Rectangle r = m_templateReader.getPageSize(getCurrentTemplatePage());
log.debug( "Page Size : t="+r.getTop()+",l="+r.getLeft()+",b="+r.getBottom()+",r="+r.getRight()+", rot="+r.getRotation() );
r = m_templateReader.getPageSizeWithRotation(getCurrentTemplatePage());
log.debug( "Page Size w/Rot: t="+r.getTop()+",l="+r.getLeft()+",b="+r.getBottom()+",r="+r.getRight()+", rot="+r.getRotation() );
// Get rotation quadrent 0..3
int q = (m_templateReader.getPageSizeWithRotation(getCurrentTemplatePage()).getRotation() % 360)/90;
float tX = (q==2?r.getTop():0)+(q==3?r.getRight():0);
float tY = (q==1?r.getTop():0)+(q==2?r.getRight():0);
float sX=1f, sY=1f;
double angle = -r.getRotation()*(Math.PI/180f);
double transformA = sX * Math.cos(angle);
double transformB = sY * Math.sin(angle);
double transformC = -sX * Math.sin(angle);
double transformD = sY * Math.cos(angle);
double transformE = tX;
double transformF = tY;
m_generatedDoc.setPageSize(m_templateReader.getPageSizeWithRotation(getCurrentTemplatePage()) );
//m_generatedDoc.setPageSize(m_templateReader.getPageSize(getCurrentTemplatePage()) );
/**
* try {
* m_generatedDoc.newPage();
* } catch (DocumentException e) {
* log.error("Error Creating New Page - " + e.getMessage() ,e);
* throw new EngineProcessingException("Error Creating New Page - " + e.getMessage());
* }
**/
m_generatedDoc.newPage();
PdfImportedPage page = m_writer.getImportedPage(m_templateReader, getCurrentTemplatePage() );
PdfContentByte cb = m_writer.getDirectContent();
//cb.addTemplate(page, 1f, 0, 0, 1f, 0, 0);
cb.addTemplate(page, (float)transformA, (float)transformB, (float)transformC,
(float)transformD, (float)transformE, (float)transformF);
log.debug("Matrix = [A=" + transformA +", B=" + transformB +", C=" + transformC +
", D=" + transformD +", E=" + transformE +", F=" + transformF +" ]");
}
示例2: applyRotation
import com.lowagie.text.Rectangle; //导入方法依赖的package包/类
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;
}
}
示例3: rotateAnnotations
import com.lowagie.text.Rectangle; //导入方法依赖的package包/类
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;
}
示例4: applyRotation
import com.lowagie.text.Rectangle; //导入方法依赖的package包/类
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;
}
}