Java Operations PDF file

Source: Internet
Author: User

In recent days, the project needs to generate a PDF report, the online search of Java generated PDF file, there are probably two kinds, one is to use Jacob call Excel Save as PDF file, another is

With the Third-party Open Source Library Itext.jar directly generated PDF files, both of which I have tried, combined with the needs of the project, feel or use Itext to generate PDF reports more free. Here is the sample code that records

Itext how to simply generate PDF files and tables.


                        String path = Uatsresources.getapppath () +uats.getitem () + "/test-report.pdf";
			Com.lowagie.text.Document Document = new Com.lowagie.text.Document ();
			Pdfwriter.getinstance (document, new FileOutputStream (path));
			
			Document.open ();
	                Basefont style = Basefont.createfont ("Stsongstd-light", "Unigb-ucs2-h", false);
	        
			Font chinese = new Font (style, 8, font.bold,color.black);
			pdfptable table = new Pdfptable (10);
			Table.addcell (New Pdfpcell ("number", Chinese));
			Table.addcell (New Pdfpcell ("Application Name", Chinese));
			Table.addcell (New Pdfpcell ("File type", Chinese));
			Table.addcell (New Pdfpcell ("Application Version", Chinese));
			Table.addcell (New Pdfpcell ("Installation", Chinese));
			Table.addcell (New Pdfpcell ("Application Startup", Chinese));
			Table.addcell (New Pdfpcell ("Application Exit", Chinese));
			Table.addcell (New Pdfpcell ("Application Run", Chinese)); Table.addcell (New Pdfpcell Phrase ("Uninstall condition", CHInese)));
			Table.addcell (New Pdfpcell ("Test Type", Chinese));
			Table.addcell (New Pdfpcell ("Security check", Chinese));
			Table.addcell (New Pdfpcell ("Start Time", Chinese));
			Table.addcell (New Pdfpcell ("CPU footprint", Chinese));
			Table.addcell (New Pdfpcell ("Memory footprint", Chinese));
			Table.addcell (New Pdfpcell ("Test Time", Chinese));
			Table.addcell (New Pdfpcell Phrase ("Tester", Chinese));
			Document.add (table);
			 Document.close ();


Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.