![]() ![]() To make these charts, you'll combine iText with JFreeChart, an interesting library developed by David Gilbert and Thomas Morgner. ![]() You take the student population of the Technological University of Foobar and graph the number of students per continent. Suppose you need to make charts showing demographic information. As long as you respect the license, you can use iText in your closed-source or proprietary software.Īnother useful aspect of iText's Graphics2D functionality is that it opens the door to using iText in combination with other libraries with graphical output-for instance, Apache Batik, a library that is able to parse SVG or JFreeChart, a library that will be introduced in the next section. It's not because iText is free that it isn't a "commercial" product. It's not because iText is FOSS that it can only be used in other free products. The main purpose of these two examples is to answer the following question: Can I build iText into my commercial product? Lots of people think open source is the opposite of commercial, but that's a misunderstanding. It's not my intention to make a complete list of products that use iText. ICEbrowser parses and lays out advanced Web content (XML/HTML/CSS/JS) PDF is generated by rendering the parsed documents to the PdfGraphics2D object. If you choose to generate PDF, iText's PdfGraphics2D object is used behind the scenes. JasperReports, a free Java reporting tool from JasperSoft, allows you to deliver content onto the screen to the printer or into PDF, HTML, XLS, CSV, and XML files.Let me pick two examples one free/open source software (FOSS) product and one proprietary product: Numerous applications use iText this way. Ta.getUI().getRootView(ta).paint(g2, alloc) Rectangle alloc = getVisibleEditorRect(ta) 95f) ĪffineTransform at = new AffineTransform() Īt.translate(convertToPixels(20), convertToPixels(20)) Graphics2D g2 = cb.createGraphics(612, 792, mapper, true. This example performs an affine transformation before the content of the JTextPane is painted: /* chapter12/JTextPaneToPdf.java */ The code is a bit more complex than the JTable example. Click on thumbnail to view full-sized image. A simple editor with a JTextPane that is drawn onto a PDF file. It's a simple text editor that allows you to write text in a JTextPane and print it to PDF.įigure 2 shows this application in action. The next example was posted to the iText mailing list by Bill Ensley (), one of the more experienced iText users on the mailing list. ![]() PdfTemplate tp = cb.createTemplate(500, 500) ![]() PdfContentByte cb = writer.getDirectContent() New FileOutputStream("my_jtable_fonts.pdf")) New FileOutputStream("my_jtable_shapes.pdf")) The code to achieve this is amazingly simple: /* chapter12/MyJTable.java */ If you select a row, the background of the row is shown in a different color in the Java applications as well as in the PDF. If you run this example, try changing the content of the JTable the changes are reflected in the PDF. A Swing application with a JTable that is printed to PDF two different ways. ![]()
0 Comments
Leave a Reply. |