Generate PDF files from Java applications dynamically
Many applications demand dynamic generation of PDF documents. Such applications range from banks generating customer statements for e-mail delivery to readers buying specific book chapters and receiving them in PDF format.
Get familiar with iText
iText is a freely available Java library from Lowagie.com. The iText library is powerful and supports the generation of HTML, RTF, and XML documents, in addition to generating PDF's. You can choose from a variety of fonts to be used in the document. Also, the structure of iText allows you to generate any of the above-mentioned types of documents with the same code.
The iText library contains classes to generate PDF text in various fonts, generate tables in PDF document, add watermarks to pages, and so on. There are many more features available with iText. It would not be possible to demonstrate all of them in a single article. We will cover the basics required for PDF generation.
How to configure with Eclipse:
Downloading and configuring iText in Eclipse
Being a pure Java library, iText comes in the form of a JAR file which you download from Lowagie.com. Once you have downloaded the library (let's say, at path C:\temp), the following steps will configure the iText library in an Eclipse environment:
Create a new Java project in Eclipse named iText.
Right-click on the iText project in Package Explorer view and select Properties
Click Java Build Path. On the Libraries tab, click Add External Jar's.
Browse to the C:\temp directory and select the itext-1.3.jar in this directory.
Click OK.
iText is now configured, and Eclipse is ready to create Java applications to generate dynamic PDF documents.
By - Ramesh
Selecting the Best Java Collection Class for Your Application
• All Vector methods are synchronized as are Stack methods
• Array List fast operations are getting the size of the list, getting the object at a specified position in the list, and setting the object at a specified position in the list.
• Linked List can quickly insert or remove objects in the middle of the list whereas Array List takes time proportionate to the number of objects in the list after the position to which objects being added or removed. Use Array List unless you are inserting or deleting a lot from the middle of a list.
• If you rarely iterate an Array List object while it is being modified, then using a lock is a good solution. However, if iterating over a Array List while modifying it is common, then locking may make waiting time unacceptably high.
• With CopyOnWrite ArrayList all operations that change the contents of a CopyOnWriteArrayList collection cause the underlying array to be replaced with a copy of itself before the contents of the array are changed. Any active iterators will continue to see the unmodified array, so there is no need for locks.
• HashSet is faster than TreeSet, so only use the TreeSet preferentially when you need elements to remain in sorted order.
• HashSet is faster than LinkedHashSet so only use the LinkedHashSet preferentially when you need elements to remain in insertion order.
• ConcurrentSkipListSet keeps it's elements in sorted order and is thread-safe and usually preferable to a synchronized wrapped set.
• With CopyOnWriteArraySet all operations that change the contents of a CopyOnWriteArraySet collection cause the underlying array to be replaced with a copy of itself before the contents of the array are changed. Any active iterators will continue to see the unmodified array, so there is no need for locks.
• PriorityQueue add and remove methods take time that is proportionate to the number of objects in the queue. Queues based on the PriorityQueue class do not block. PriorityBlockingQueue is similar in performance but does block.
• DelayQueue is a specialized blocking queue that consults the objects it contains as to when they can be removed from the queue.
• A SynchronousQueue object is always empty; the put method blocks unless another thread is waiting for the object's take method to return.
• If you are not interested in how objects will be organized in a collection, then the only other consideration is performance. In that case, use the ArrayList class. It is fast and makes efficient use of memory.
By - Amaresh
Please find more topics under JASe Archive!!!
Monday, August 31, 2009
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment