本文整理汇总了Java中com.lowagie.text.Rectangle.getHeight方法的典型用法代码示例。如果您正苦于以下问题:Java Rectangle.getHeight方法的具体用法?Java Rectangle.getHeight怎么用?Java Rectangle.getHeight使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.lowagie.text.Rectangle
的用法示例。
在下文中一共展示了Rectangle.getHeight方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: setPageSize
import com.lowagie.text.Rectangle; //导入方法依赖的package包/类
/**
* Set the page size to use. This method will use guessFormat to try to guess the correct
* page format. If no format could be guessed, the sizes from the pageSize are used and
* the landscape setting is determined by comparing width and height;
*
* @param pageSize The pageSize to use
*/
public void setPageSize(Rectangle pageSize) {
if(!guessFormat(pageSize, false)) {
this.pageWidth = (int) (pageSize.getWidth() * RtfElement.TWIPS_FACTOR);
this.pageHeight = (int) (pageSize.getHeight() * RtfElement.TWIPS_FACTOR);
this.landscape = pageWidth > pageHeight;
}
}
示例2: onEndPage
import com.lowagie.text.Rectangle; //导入方法依赖的package包/类
public void onEndPage(PdfWriter writer, Document document){
try {
Rectangle page = document.getPageSize();
PdfContentByte cb = writer.getDirectContent();
BaseFont bf = BaseFont.createFont(BaseFont.TIMES_ROMAN, BaseFont.CP1252, BaseFont.NOT_EMBEDDED);
int pageNum = document.getPageNumber();
float width = page.getWidth();
float height = page.getHeight();
//add patient name header for every page but the first.
if (pageNum > 1){
cb.beginText();
cb.setFontAndSize(bf, 8);
cb.showTextAligned(PdfContentByte.ALIGN_RIGHT, handler.getPatientName(), 575, height - 30, 0);
cb.endText();
}
//add footer for every page
cb.beginText();
cb.setFontAndSize(bf, 8);
cb.showTextAligned(PdfContentByte.ALIGN_CENTER, "-"+pageNum+"-", width/2, 30, 0);
cb.endText();
// add promotext as footer if it is enabled
if ( OscarProperties.getInstance().getProperty("FORMS_PROMOTEXT") != null){
cb.beginText();
cb.setFontAndSize(BaseFont.createFont(BaseFont.HELVETICA,BaseFont.CP1252,BaseFont.NOT_EMBEDDED), 6);
cb.showTextAligned(PdfContentByte.ALIGN_CENTER, OscarProperties.getInstance().getProperty("FORMS_PROMOTEXT"), width/2, 19, 0);
cb.endText();
}
// throw any exceptions
} catch (Exception e) {
throw new ExceptionConverter(e);
}
}
示例3: main
import com.lowagie.text.Rectangle; //导入方法依赖的package包/类
/**
* Reads the pages of an existing PDF file and puts 2 pages from the
* existing doc into one of the new doc.
*/
@Test
public void main() throws Exception {
// we create a reader for a certain document
PdfReader reader = new PdfReader(PdfTestBase.RESOURCES_DIR + "ChapterSection.pdf");
// we retrieve the total number of pages
int n = reader.getNumberOfPages();
// we retrieve the size of the first page
Rectangle psize = reader.getPageSize(1);
float width = psize.getHeight();
float height = psize.getWidth();
// step 1: creation of a document-object
Document document = new Document(new Rectangle(width, height));
// step 2: we create a writer that listens to the document
PdfWriter writer = PdfWriter.getInstance(document, PdfTestBase.getOutputStream("2on1.pdf"));
// step 3: we open the document
document.open();
// step 4: we add content
PdfContentByte cb = writer.getDirectContent();
int i = 0;
int p = 0;
while (i < n) {
document.newPage();
p++;
i++;
PdfImportedPage page1 = writer.getImportedPage(reader, i);
cb.addTemplate(page1, .5f, 0, 0, .5f, 60, 120);
if (i < n) {
i++;
PdfImportedPage page2 = writer.getImportedPage(reader, i);
cb.addTemplate(page2, .5f, 0, 0, .5f, width / 2 + 60, 120);
}
BaseFont bf = BaseFont.createFont(BaseFont.HELVETICA, BaseFont.CP1252, BaseFont.NOT_EMBEDDED);
cb.beginText();
cb.setFontAndSize(bf, 14);
cb.showTextAligned(PdfContentByte.ALIGN_CENTER, "page " + p + " of " + ((n / 2) + (n % 2 > 0 ? 1 : 0)),
width / 2, 40, 0);
cb.endText();
}
// step 5: we close the document
document.close();
}
示例4: printPdf
import com.lowagie.text.Rectangle; //导入方法依赖的package包/类
public void printPdf(LoggedInInfo loggedInInfo) throws IOException, DocumentException{
EctConsultationFormRequestUtil reqForm = new EctConsultationFormRequestUtil();
reqForm.estRequestFromId(loggedInInfo, (String) request.getAttribute("reqId"));
// init req form info
reqForm.specAddr = request.getParameter("address");
if (reqForm.specAddr == null){reqForm.specAddr = new String(); }
reqForm.specPhone = request.getParameter("phone");
if (reqForm.specPhone == null){ reqForm.specPhone = ""; }
reqForm.specFax = request.getParameter("fax");
if (reqForm.specFax == null){ reqForm.specFax = ""; }
//Create new file to save form to
String path = OscarProperties.getInstance().getProperty("DOCUMENT_DIR");
String fileName = path + "ConsultationRequestForm-"+UtilDateUtilities.getToday("yyyy-MM-dd.hh.mm.ss")+".pdf";
FileOutputStream out = new FileOutputStream(fileName);
//Create the document we are going to write to
document = new Document();
// writer = PdfWriter.getInstance(document,out);
writer = PdfWriterFactory.newInstance(document, out, FontSettings.HELVETICA_6PT);
//Use the template located at '/oscar/oscarEncounter/oscarConsultationRequest/props'
reader = new PdfReader("/oscar/oscarEncounter/oscarConsultationRequest/props/consultationFormRequest.pdf");
Rectangle pSize = reader.getPageSize(1);
height = pSize.getHeight();
document.setPageSize(pSize);
document.addTitle("Consultation Form Request");
document.addCreator("OSCAR");
document.open();
//Create the font we are going to print to
bf = BaseFont.createFont(BaseFont.HELVETICA, BaseFont.CP1252, BaseFont.NOT_EMBEDDED);
cb = writer.getDirectContent();
ct = new ColumnText(cb);
cb.setColorStroke(new Color(0,0,0));
// start writing the pdf document
PdfImportedPage page1 = writer.getImportedPage(reader, 1);
cb.addTemplate(page1, 1, 0, 0, 1, 0, 0);
// addFooter();
setAppointmentInfo(reqForm);
// add the dynamically positioned text elements
float dynamicHeight = 0;
dynamicHeight = addDynamicPositionedText("Reason For Consultation: ", reqForm.reasonForConsultation, dynamicHeight, reqForm);
dynamicHeight = addDynamicPositionedText("Pertinent Clinical Information: ", reqForm.clinicalInformation, dynamicHeight, reqForm);
dynamicHeight = addDynamicPositionedText("Significant Concurrent Problems: ", reqForm.concurrentProblems, dynamicHeight, reqForm);
dynamicHeight = addDynamicPositionedText("Current Medications: ", reqForm.currentMedications, dynamicHeight, reqForm);
dynamicHeight = addDynamicPositionedText("Allergies: ", reqForm.allergies, dynamicHeight, reqForm);
document.close();
reader.close();
writer.close();
out.close();
// combine the recently created pdf with any pdfs that were added to the consultation request form
combinePDFs(loggedInInfo, fileName);
}
示例5: rectEquals
import com.lowagie.text.Rectangle; //导入方法依赖的package包/类
/**
* This method compares to Rectangles. They are considered equal if width and height are the same
*
* @param rect1 The first Rectangle to compare
* @param rect2 The second Rectangle to compare
* @return <code>True</code> if the Rectangles equal, <code>false</code> otherwise
*/
private boolean rectEquals(Rectangle rect1, Rectangle rect2) {
return (rect1.getWidth() == rect2.getWidth()) && (rect1.getHeight() == rect2.getHeight());
}