Java Code Examples for com.lowagie.text.Image#scalePercent()
The following examples show how to use
com.lowagie.text.Image#scalePercent() .
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: PdfRequestAndGraphDetailReport.java From javamelody with Apache License 2.0 | 6 votes |
private void writeGraph() throws IOException, DocumentException { final JRobin jrobin = collector.getJRobin(graphName); if (jrobin != null) { final byte[] img = jrobin.graph(range, 960, 400); final Image image = Image.getInstance(img); image.scalePercent(50); final PdfPTable table = new PdfPTable(1); table.setHorizontalAlignment(Element.ALIGN_CENTER); table.setWidthPercentage(100); table.getDefaultCell().setBorder(0); table.addCell("\n"); table.addCell(image); table.getDefaultCell().setHorizontalAlignment(Element.ALIGN_RIGHT); table.addCell(new Phrase(getString("graph_units"), cellFont)); addToDocument(table); } else { // just in case request is null and collector.getJRobin(graphName) is null, we must write something in the document addToDocument(new Phrase("\n", cellFont)); } }
Example 2
Source File: PdfJavaInformationsReport.java From javamelody with Apache License 2.0 | 6 votes |
private void writeMemoryInformations(MemoryInformations memoryInformations) throws BadElementException, IOException { addCell(memoryInformations.getMemoryDetails().replace(" Mo", ' ' + getString("Mo"))); final long usedPermGen = memoryInformations.getUsedPermGen(); if (usedPermGen > 0) { // perm gen est à 0 sous jrockit final long maxPermGen = memoryInformations.getMaxPermGen(); addCell(getString("Memoire_Perm_Gen") + ':'); if (maxPermGen > 0) { final Phrase permGenPhrase = new Phrase( integerFormat.format(usedPermGen / 1024 / 1024) + ' ' + getString("Mo") + DIVIDE + integerFormat.format(maxPermGen / 1024 / 1024) + ' ' + getString("Mo") + BAR_SEPARATOR, cellFont); final Image permGenImage = Image.getInstance( Bar.toBarWithAlert(memoryInformations.getUsedPermGenPercentage()), null); permGenImage.scalePercent(50); permGenPhrase.add(new Chunk(permGenImage, 0, 0)); currentTable.addCell(permGenPhrase); } else { addCell(integerFormat.format(usedPermGen / 1024 / 1024) + ' ' + getString("Mo")); } } }
Example 3
Source File: ScalingTest.java From itext2 with GNU Lesser General Public License v3.0 | 5 votes |
/** * Scaling an image. */ @Test public void main() throws Exception { // step 1: creation of a document-object Document document = new Document(); // step 2: // we create a writer that listens to the document // and directs a PDF-stream to a file PdfWriter.getInstance(document, PdfTestBase.getOutputStream("scaling.pdf")); // step 3: we open the document document.open(); // step 4: we add content Image jpg1 = Image.getInstance(PdfTestBase.RESOURCES_DIR + "otsoe.jpg"); jpg1.scaleAbsolute(160, 120); document.add(new Paragraph("scaleAbsolute(160, 120)")); document.add(jpg1); Image jpg2 = Image.getInstance(PdfTestBase.RESOURCES_DIR + "otsoe.jpg"); jpg2.scalePercent(50); document.add(new Paragraph("scalePercent(50)")); document.add(jpg2); Image jpg3 = Image.getInstance(PdfTestBase.RESOURCES_DIR + "otsoe.jpg"); jpg3.scaleAbsolute(320, 120); document.add(new Paragraph("scaleAbsolute(320, 120)")); document.add(jpg3); Image jpg4 = Image.getInstance(PdfTestBase.RESOURCES_DIR + "otsoe.jpg"); jpg4.scalePercent(100, 50); document.add(new Paragraph("scalePercent(100, 50)")); document.add(jpg4); // step 5: we close the document document.close(); }
Example 4
Source File: ExamplePDF417Test.java From itext2 with GNU Lesser General Public License v3.0 | 5 votes |
/** * Example Barcode PDF417. */ @Test public void main() throws Exception { BarcodePDF417 pdf417 = new BarcodePDF417(); String text = "It was the best of times, it was the worst of times, " + "it was the age of wisdom, it was the age of foolishness, " + "it was the epoch of belief, it was the epoch of incredulity, " + "it was the season of Light, it was the season of Darkness, " + "it was the spring of hope, it was the winter of despair, " + "we had everything before us, we had nothing before us, " + "we were all going direct to Heaven, we were all going direct " + "the other way - in short, the period was so far like the present " + "period, that some of its noisiest authorities insisted on its " + "being received, for good or for evil, in the superlative degree " + "of comparison only."; pdf417.setText(text); Document document = new Document(PageSize.A4, 50, 50, 50, 50); PdfWriter.getInstance(document, PdfTestBase.getOutputStream( "pdf417.pdf")); document.open(); Image img = pdf417.getImage(); img.scalePercent(50, 50 * pdf417.getYHeight()); document.add(img); document.close(); }
Example 5
Source File: PdfJavaInformationsReport.java From javamelody with Apache License 2.0 | 5 votes |
private void writeServerInfo(String serverInfo) throws BadElementException, IOException { addCell(getString("Serveur") + ':'); final Phrase serverInfoPhrase = new Phrase("", cellFont); final String applicationServerIconName = HtmlJavaInformationsReport .getApplicationServerIconName(serverInfo); if (applicationServerIconName != null) { final Image applicationServerImage = PdfDocumentFactory .getImage("servers/" + applicationServerIconName); applicationServerImage.scalePercent(40); serverInfoPhrase.add(new Chunk(applicationServerImage, 0, 0)); serverInfoPhrase.add(new Chunk(" ")); } serverInfoPhrase.add(new Chunk(serverInfo)); currentTable.addCell(serverInfoPhrase); }
Example 6
Source File: PdfJavaInformationsReport.java From javamelody with Apache License 2.0 | 5 votes |
private void writeFileDescriptorCounts(JavaInformations javaInformations) throws BadElementException, IOException { final long unixOpenFileDescriptorCount = javaInformations.getUnixOpenFileDescriptorCount(); final long unixMaxFileDescriptorCount = javaInformations.getUnixMaxFileDescriptorCount(); addCell(getString("nb_fichiers") + ':'); final Phrase fileDescriptorCountPhrase = new Phrase( integerFormat.format(unixOpenFileDescriptorCount) + DIVIDE + integerFormat.format(unixMaxFileDescriptorCount) + BAR_SEPARATOR, cellFont); final Image fileDescriptorCountImage = Image.getInstance( Bar.toBarWithAlert(javaInformations.getUnixOpenFileDescriptorPercentage()), null); fileDescriptorCountImage.scalePercent(50); fileDescriptorCountPhrase.add(new Chunk(fileDescriptorCountImage, 0, 0)); currentTable.addCell(fileDescriptorCountPhrase); }
Example 7
Source File: PdfJavaInformationsReport.java From javamelody with Apache License 2.0 | 5 votes |
private void writeTomcatInformations(List<TomcatInformations> tomcatInformationsList) throws BadElementException, IOException { for (final TomcatInformations tomcatInformations : tomcatInformationsList) { if (tomcatInformations.getRequestCount() <= 0) { continue; } addCell("Tomcat " + tomcatInformations.getName() + ':'); // rq: on n'affiche pas pour l'instant getCurrentThreadCount final int currentThreadsBusy = tomcatInformations.getCurrentThreadsBusy(); final String equal = " = "; final Phrase phrase = new Phrase(getString("busyThreads") + equal + integerFormat.format(currentThreadsBusy) + DIVIDE + integerFormat.format(tomcatInformations.getMaxThreads()) + BAR_SEPARATOR, cellFont); final Image threadsImage = Image.getInstance(Bar.toBarWithAlert( 100d * currentThreadsBusy / tomcatInformations.getMaxThreads()), null); threadsImage.scalePercent(50); phrase.add(new Chunk(threadsImage, 0, 0)); phrase.add(new Chunk('\n' + getString("bytesReceived") + equal + integerFormat.format(tomcatInformations.getBytesReceived()) + '\n' + getString("bytesSent") + equal + integerFormat.format(tomcatInformations.getBytesSent()) + '\n' + getString("requestCount") + equal + integerFormat.format(tomcatInformations.getRequestCount()) + '\n' + getString("errorCount") + equal + integerFormat.format(tomcatInformations.getErrorCount()) + '\n' + getString("processingTime") + equal + integerFormat.format(tomcatInformations.getProcessingTime()) + '\n' + getString("maxProcessingTime") + equal + integerFormat.format(tomcatInformations.getMaxTime()))); currentTable.addCell(phrase); } }
Example 8
Source File: PdfCounterReport.java From javamelody with Apache License 2.0 | 5 votes |
private void writeRequestGraph(CounterRequest request) throws BadElementException, IOException { final JRobin jrobin = collector.getJRobin(request.getId()); if (jrobin == null) { addCell(""); } else { final byte[] img = jrobin.graph(range, 100, 50); final Image image = Image.getInstance(img); image.scalePercent(50); addCell(image); } }
Example 9
Source File: PdfJobInformationsReport.java From javamelody with Apache License 2.0 | 5 votes |
private void writeJobTimes(JobInformations jobInformations, CounterRequest counterRequest) throws BadElementException, IOException { final long elapsedTime = jobInformations.getElapsedTime(); if (elapsedTime >= 0) { final Phrase elapsedTimePhrase = new Phrase(durationFormat.format(elapsedTime), cellFont); final Image memoryImage = Image .getInstance(Bar.toBar(100d * elapsedTime / counterRequest.getMean()), null); memoryImage.scalePercent(47); elapsedTimePhrase.add(new Chunk("\n")); elapsedTimePhrase.add(new Chunk(memoryImage, 0, 0)); addCell(elapsedTimePhrase); } else { addCell(""); } if (jobInformations.getPreviousFireTime() != null) { addCell(fireTimeFormat.format(jobInformations.getPreviousFireTime())); } else { addCell(""); } if (jobInformations.getNextFireTime() != null) { addCell(fireTimeFormat.format(jobInformations.getNextFireTime())); } else { addCell(""); } // on n'affiche pas la période si >= 1 jour car ce formateur ne saurait pas l'afficher if (jobInformations.getRepeatInterval() > 0 && jobInformations.getRepeatInterval() < ONE_DAY_MILLIS) { addCell(durationFormat.format(new Date(jobInformations.getRepeatInterval()))); } else if (jobInformations.getCronExpression() != null) { addCell(jobInformations.getCronExpression()); } else { addCell(""); } }
Example 10
Source File: PdfPCell.java From gcs with Mozilla Public License 2.0 | 4 votes |
/** * Returns the height of the cell. * @return the height of the cell * @since 3.0.0 */ public float getMaxHeight() { boolean pivoted = (getRotation() == 90 || getRotation() == 270); Image img = getImage(); if (img != null) { img.scalePercent(100); float refWidth = pivoted ? img.getScaledHeight() : img.getScaledWidth(); float scale = (getRight() - getEffectivePaddingRight() - getEffectivePaddingLeft() - getLeft()) / refWidth; img.scalePercent(scale * 100); float refHeight = pivoted ? img.getScaledWidth() : img.getScaledHeight(); setBottom(getTop() - getEffectivePaddingTop() - getEffectivePaddingBottom() - refHeight); } else { if (pivoted && hasFixedHeight()) setBottom(getTop() - getFixedHeight()); else { ColumnText ct = ColumnText.duplicate(getColumn()); float right, top, left, bottom; if (pivoted) { right = PdfPRow.RIGHT_LIMIT; top = getRight() - getEffectivePaddingRight(); left = 0; bottom = getLeft() + getEffectivePaddingLeft(); } else { right = isNoWrap() ? PdfPRow.RIGHT_LIMIT : getRight() - getEffectivePaddingRight(); top = getTop() - getEffectivePaddingTop(); left = getLeft() + getEffectivePaddingLeft(); bottom = hasFixedHeight() ? top + getEffectivePaddingBottom() - getFixedHeight() : PdfPRow.BOTTOM_LIMIT; } PdfPRow.setColumn(ct, left, bottom, right, top); try { ct.go(true); } catch (DocumentException e) { throw new ExceptionConverter(e); } if (pivoted) setBottom(getTop() - getEffectivePaddingTop() - getEffectivePaddingBottom() - ct.getFilledWidth()); else { float yLine = ct.getYLine(); if (isUseDescender()) yLine += ct.getDescender(); setBottom(yLine - getEffectivePaddingBottom()); } } } float height = getHeight(); if (height < getFixedHeight()) height = getFixedHeight(); else if (height < getMinimumHeight()) height = getMinimumHeight(); return height; }
Example 11
Source File: PdfPCell.java From itext2 with GNU Lesser General Public License v3.0 | 4 votes |
/** * Returns the height of the cell. * @return the height of the cell * @since 3.0.0 */ public float getMaxHeight() { boolean pivoted = (getRotation() == 90 || getRotation() == 270); Image img = getImage(); if (img != null) { img.scalePercent(100); float refWidth = pivoted ? img.getScaledHeight() : img.getScaledWidth(); float scale = (getRight() - getEffectivePaddingRight() - getEffectivePaddingLeft() - getLeft()) / refWidth; img.scalePercent(scale * 100); float refHeight = pivoted ? img.getScaledWidth() : img.getScaledHeight(); setBottom(getTop() - getEffectivePaddingTop() - getEffectivePaddingBottom() - refHeight); } else { if ((pivoted && hasFixedHeight()) || getColumn() == null) setBottom(getTop() - getFixedHeight()); else { ColumnText ct = ColumnText.duplicate(getColumn()); float right, top, left, bottom; if (pivoted) { right = PdfPRow.RIGHT_LIMIT; top = getRight() - getEffectivePaddingRight(); left = 0; bottom = getLeft() + getEffectivePaddingLeft(); } else { right = isNoWrap() ? PdfPRow.RIGHT_LIMIT : getRight() - getEffectivePaddingRight(); top = getTop() - getEffectivePaddingTop(); left = getLeft() + getEffectivePaddingLeft(); bottom = hasFixedHeight() ? getTop() + getEffectivePaddingBottom() - getFixedHeight() : PdfPRow.BOTTOM_LIMIT; } PdfPRow.setColumn(ct, left, bottom, right, top); try { ct.go(true); } catch (DocumentException e) { throw new ExceptionConverter(e); } if (pivoted) setBottom(getTop() - getEffectivePaddingTop() - getEffectivePaddingBottom() - ct.getFilledWidth()); else { float yLine = ct.getYLine(); if (isUseDescender()) yLine += ct.getDescender(); setBottom(yLine - getEffectivePaddingBottom()); } } } float height = getHeight(); if (hasFixedHeight()) height = getFixedHeight(); else if (height < getMinimumHeight()) height = getMinimumHeight(); return height; }
Example 12
Source File: TemplateImagesTest.java From itext2 with GNU Lesser General Public License v3.0 | 4 votes |
/** * PdfTemplates can be wrapped in an Image. */ @Test public void main() throws Exception { // step 1: creation of a document-object Rectangle rect = new Rectangle(PageSize.A4); rect.setBackgroundColor(new Color(238, 221, 88)); Document document = new Document(rect, 50, 50, 50, 50); // step 2: we create a writer that listens to the document PdfWriter writer = PdfWriter.getInstance(document, PdfTestBase.getOutputStream("templateImages.pdf")); // step 3: we open the document document.open(); // step 4: PdfTemplate template = writer.getDirectContent().createTemplate(20, 20); BaseFont bf = BaseFont.createFont(BaseFont.HELVETICA, BaseFont.WINANSI, BaseFont.NOT_EMBEDDED); String text = "Vertical"; float size = 16; float width = bf.getWidthPoint(text, size); template.beginText(); template.setRGBColorFillF(1, 1, 1); template.setFontAndSize(bf, size); template.setTextMatrix(0, 2); template.showText(text); template.endText(); template.setWidth(width); template.setHeight(size + 2); template.sanityCheck(); Image img = Image.getInstance(template); img.setRotationDegrees(90); Chunk ck = new Chunk(img, 0, 0); PdfPTable table = new PdfPTable(3); table.setWidthPercentage(100); table.getDefaultCell().setHorizontalAlignment(Element.ALIGN_CENTER); table.getDefaultCell().setVerticalAlignment(Element.ALIGN_MIDDLE); PdfPCell cell = new PdfPCell(img); cell.setPadding(4); cell.setBackgroundColor(new Color(0, 0, 255)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); table.addCell("I see a template on my right"); table.addCell(cell); table.addCell("I see a template on my left"); table.addCell(cell); table.addCell("I see a template everywhere"); table.addCell(cell); table.addCell("I see a template on my right"); table.addCell(cell); table.addCell("I see a template on my left"); Paragraph p1 = new Paragraph("This is a template "); p1.add(ck); p1.add(" just here."); p1.setLeading(img.getScaledHeight() * 1.1f); document.add(p1); document.add(table); Paragraph p2 = new Paragraph("More templates "); p2.setLeading(img.getScaledHeight() * 1.1f); p2.setAlignment(Element.ALIGN_JUSTIFIED); img.scalePercent(70); for (int k = 0; k < 20; ++k) p2.add(ck); document.add(p2); // step 5: we close the document document.close(); }
Example 13
Source File: ImageChunksTest.java From itext2 with GNU Lesser General Public License v3.0 | 4 votes |
/** * Images wrapped in a Chunk. */ @Test public void main() throws Exception { // step 1: creation of a document-object Document document = new Document(); // step 2: // we create a writer that listens to the document // and directs a PDF-stream to a file PdfWriter.getInstance(document, PdfTestBase.getOutputStream("imageChunks.pdf")); // step 3: we open the document document.open(); // step 4: we create a table and add it to the document Image img = Image.getInstance(PdfTestBase.RESOURCES_DIR + "pngnow.png"); img.scalePercent(70); Chunk ck = new Chunk(img, 0, -5); PdfPTable table = new PdfPTable(3); PdfPCell cell = new PdfPCell(); cell.addElement(new Chunk(img, 5, -5)); cell.setBackgroundColor(new Color(0xC0, 0xC0, 0xC0)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); table.addCell("I see an image\non my right"); table.addCell(cell); table.addCell("I see an image\non my left"); table.addCell(cell); table.addCell("I see images\neverywhere"); table.addCell(cell); table.addCell("I see an image\non my right"); table.addCell(cell); table.addCell("I see an image\non my left"); Phrase p1 = new Phrase("This is an image "); p1.add(ck); p1.add(" just here."); document.add(p1); document.add(p1); document.add(p1); document.add(p1); document.add(p1); document.add(p1); document.add(p1); document.add(table); // step 5: we close the document document.close(); }
Example 14
Source File: PdfJavaInformationsReport.java From javamelody with Apache License 2.0 | 4 votes |
private void writeSummary(JavaInformations javaInformations) throws BadElementException, IOException { addCell(getString("Host") + ':'); currentTable.addCell(new Phrase(javaInformations.getHost(), boldCellFont)); addCell(getString("memoire_utilisee") + ':'); final MemoryInformations memoryInformations = javaInformations.getMemoryInformations(); final long usedMemory = memoryInformations.getUsedMemory(); final long maxMemory = memoryInformations.getMaxMemory(); final Phrase memoryPhrase = new Phrase(integerFormat.format(usedMemory / 1024 / 1024) + ' ' + getString("Mo") + DIVIDE + integerFormat.format(maxMemory / 1024 / 1024) + ' ' + getString("Mo") + BAR_SEPARATOR, cellFont); final Image memoryImage = Image.getInstance( Bar.toBarWithAlert(memoryInformations.getUsedMemoryPercentage()), null); memoryImage.scalePercent(50); memoryPhrase.add(new Chunk(memoryImage, 0, 0)); currentTable.addCell(memoryPhrase); if (javaInformations.getSessionCount() >= 0) { addCell(getString("nb_sessions_http") + ':'); addCell(integerFormat.format(javaInformations.getSessionCount())); } addCell(getString("nb_threads_actifs") + "\n(" + getString("Requetes_http_en_cours") + "):"); addCell(integerFormat.format(javaInformations.getActiveThreadCount())); if (!noDatabase) { addCell(getString("nb_connexions_actives") + ':'); addCell(integerFormat.format(javaInformations.getActiveConnectionCount())); addCell(getString("nb_connexions_utilisees") + "\n(" + getString("ouvertes") + "):"); final int usedConnectionCount = javaInformations.getUsedConnectionCount(); final int maxConnectionCount = javaInformations.getMaxConnectionCount(); if (maxConnectionCount <= 0) { addCell(integerFormat.format(usedConnectionCount)); } else { final Phrase usedConnectionCountPhrase = new Phrase( integerFormat.format(usedConnectionCount) + DIVIDE + integerFormat.format(maxConnectionCount) + BAR_SEPARATOR, cellFont); final Image usedConnectionCountImage = Image.getInstance( Bar.toBarWithAlert(javaInformations.getUsedConnectionPercentage()), null); usedConnectionCountImage.scalePercent(50); usedConnectionCountPhrase.add(new Chunk(usedConnectionCountImage, 0, 0)); currentTable.addCell(usedConnectionCountPhrase); } } if (javaInformations.getSystemLoadAverage() >= 0) { addCell(getString("Charge_systeme") + ':'); addCell(decimalFormat.format(javaInformations.getSystemLoadAverage())); } if (javaInformations.getSystemCpuLoad() >= 0) { addCell(getString("systemCpuLoad") + ':'); final Phrase systemCpuLoadPhrase = new Phrase( decimalFormat.format(javaInformations.getSystemCpuLoad()) + BAR_SEPARATOR, cellFont); final Image systemCpuLoadImage = Image .getInstance(Bar.toBarWithAlert(javaInformations.getSystemCpuLoad()), null); systemCpuLoadImage.scalePercent(50); systemCpuLoadPhrase.add(new Chunk(systemCpuLoadImage, 0, 0)); currentTable.addCell(systemCpuLoadPhrase); } }
Example 15
Source File: PdfJavaInformationsReport.java From javamelody with Apache License 2.0 | 4 votes |
private void writeDetails(JavaInformations javaInformations) throws BadElementException, IOException { addCell(getString("OS") + ':'); final Phrase osPhrase = new Phrase("", cellFont); final String osIconName = HtmlJavaInformationsReport .getOSIconName(javaInformations.getOS()); final String separator = " "; if (osIconName != null) { final Image osImage = PdfDocumentFactory.getImage("servers/" + osIconName); osImage.scalePercent(40); osPhrase.add(new Chunk(osImage, 0, 0)); osPhrase.add(new Chunk(separator)); } osPhrase.add(new Chunk(javaInformations.getOS() + " (" + javaInformations.getAvailableProcessors() + ' ' + getString("coeurs") + ')')); currentTable.addCell(osPhrase); addCell(getString("Java") + ':'); addCell(javaInformations.getJavaVersion()); addCell(getString("JVM") + ':'); final Phrase jvmVersionPhrase = new Phrase(javaInformations.getJvmVersion(), cellFont); if (javaInformations.getJvmVersion().contains("Client")) { jvmVersionPhrase.add(new Chunk(separator)); final Image alertImage = PdfDocumentFactory.getImage("alert.png"); alertImage.scalePercent(50); jvmVersionPhrase.add(new Chunk(alertImage, 0, -2)); } currentTable.addCell(jvmVersionPhrase); addCell(getString("PID") + ':'); addCell(javaInformations.getPID()); if (javaInformations.getUnixOpenFileDescriptorCount() >= 0) { writeFileDescriptorCounts(javaInformations); } final String serverInfo = javaInformations.getServerInfo(); if (serverInfo != null) { writeServerInfo(serverInfo); addCell(getString("Contexte_webapp") + ':'); addCell(javaInformations.getContextPath()); } addCell(getString("Demarrage") + ':'); addCell(I18N.createDateAndTimeFormat().format(javaInformations.getStartDate())); addCell(getString("Arguments_JVM") + ':'); addCell(javaInformations.getJvmArguments()); if (javaInformations.getSessionCount() >= 0) { addCell(getString("httpSessionsMeanAge") + ':'); addCell(integerFormat.format(javaInformations.getSessionMeanAgeInMinutes())); } writeTomcatInformations(javaInformations.getTomcatInformationsList()); addCell(getString("Gestion_memoire") + ':'); writeMemoryInformations(javaInformations.getMemoryInformations()); // on considère que l'espace libre sur le disque dur est celui sur la partition du répertoire temporaire addCell(getString("Free_disk_space") + ':'); addCell(integerFormat.format(javaInformations.getFreeDiskSpaceInTemp() / 1024 / 1024) + ' ' + getString("Mo")); addCell(getString("Usable_disk_space") + ':'); addCell(integerFormat.format(javaInformations.getUsableDiskSpaceInTemp() / 1024 / 1024) + ' ' + getString("Mo")); writeDatabaseVersionAndDataSourceDetails(javaInformations); addCell(""); addCell(""); }
Example 16
Source File: PdfPRow.java From MesquiteCore with GNU Lesser General Public License v3.0 | 4 votes |
/** * Calculates the heights of each cell in the row. * @return the maximum height of the row. */ public float calculateHeights() { maxHeight = 0; for (int k = 0; k < cells.length; ++k) { PdfPCell cell = cells[k]; if (cell == null) continue; Image img = cell.getImage(); if (img != null) { img.scalePercent(100); float scale = (cell.right() - cell.getEffectivePaddingRight() - cell.getEffectivePaddingLeft() - cell.left()) / img.scaledWidth(); img.scalePercent(scale * 100); cell .setBottom(cell.top() - cell.getEffectivePaddingTop() - cell.getEffectivePaddingBottom() - img.scaledHeight()); } else { float rightLimit = cell.isNoWrap() ? 20000 : cell.right() - cell.getEffectivePaddingRight(); float bry = (cell.getFixedHeight() > 0) ? cell.top() - cell.getEffectivePaddingTop() + cell.getEffectivePaddingBottom() - cell.getFixedHeight() : BOTTOM_LIMIT; ColumnText ct = ColumnText.duplicate(cell.getColumn()); ct.setSimpleColumn( cell.left() + cell.getEffectivePaddingLeft(), bry, rightLimit, cell.top() - cell.getEffectivePaddingTop()); try { ct.go(true); } catch (DocumentException e) { throw new ExceptionConverter(e); } float yLine = ct.getYLine(); if (cell.isUseDescender()) yLine += ct.getDescender(); cell.setBottom(yLine - cell.getEffectivePaddingBottom()); } float height = cell.getFixedHeight(); if (height <= 0) height = cell.height(); if (height < cell.getFixedHeight()) height = cell.getFixedHeight(); else if (height < cell.getMinimumHeight()) height = cell.getMinimumHeight(); if (height > maxHeight) maxHeight = height; } calculated = true; return maxHeight; }