详细请点击:http://www.verydemo.com/demo_c134_i23261.html
package lession3; import java.awt.Color; import java.io.FileOutputStream; import com.lowagie.text.Chunk; import com.lowagie.text.Document; import com.lowagie.text.Font; import com.lowagie.text.FontFactory; import com.lowagie.text.pdf.PdfWriter; public class FirstMain { public static void main(String[] args) throws Exception { Document doc = new Document(); PdfWriter.getInstance(doc , new FileOutputStream("f:\\target.pdf")); doc.open(); //定义一个块 Chunk chunk = new Chunk("Cat"); //设置块的背景色 chunk.setBackground(Color.blue); //字体 Font font = FontFactory.getFont(FontFactory.TIMES_BOLD); font.setColor(Color.white); chunk.setFont(font); //增加块到文档 doc.add(chunk); chunk = new Chunk("DOG"); doc.add(chunk); doc.close(); } }
package lession3; import java.io.FileOutputStream; import com.lowagie.text.Chunk; import com.lowagie.text.Document; import com.lowagie.text.Phrase; import com.lowagie.text.pdf.PdfWriter; public class FirstMain { public static void main(String[] args) throws Exception { Document doc = new Document(); PdfWriter.getInstance(doc , new FileOutputStream("f:\\target.pdf")); doc.open(); //建块 Chunk chunk1 = new Chunk("Cat"); Chunk chunk2 = new Chunk("DOG"); //建短语 Phrase phrase = new Phrase(); phrase.add(chunk1); phrase.add(chunk2); phrase.add("Hello world"); doc.add(phrase); //新建一行 doc.add(Chunk.NEWLINE); doc.add(new Chunk("new line")); doc.close(); } }
package lession3; import java.io.FileOutputStream; import com.lowagie.text.Chunk; import com.lowagie.text.Document; import com.lowagie.text.Element; import com.lowagie.text.Paragraph; import com.lowagie.text.Phrase; import com.lowagie.text.pdf.PdfWriter; public class FirstMain { public static void main(String[] args) throws Exception { Document doc = new Document(); PdfWriter.getInstance(doc , new FileOutputStream("f:\\target.pdf")); doc.open(); //建块 Chunk chunk1 = new Chunk("Cat"); Chunk chunk2 = new Chunk("DOG"); //建短语 Phrase phrase = new Phrase(); phrase.add(chunk1); phrase.add(chunk2); phrase.add("Hello world"); //建段落 Paragraph paragraph = new Paragraph(); paragraph.add(phrase); paragraph.add("Hello World"); //设置段落对齐方式 paragraph.setAlignment(Element.ALIGN_LEFT); //设置缩进 paragraph.setIndentationLeft(100f); Paragraph paragraph1 = new Paragraph(); paragraph1.add("AA"); //注意增加段落时会自动换行 doc.add(paragraph); doc.add(paragraph1); doc.close(); } }
相关推荐
iText是著名的开放源码的站点sourceforge一个项目,是用于生成PDF文档的一个java类库。通过iText不仅可以生成PDF或rtf的文档,而且可以将XML、Html文件转化为PDF文件。 iText的安装非常方便,在...
java使用itextpdf、itext-asian对pdf文件加中文文字水印,此demo只提供参考,希望给需要的朋友带来帮助,谢谢支持!
itext应用包
第一部分 iText的简单应用 第一章创建一个Document 利用iText五步创建一个PDF文件:helloword。 第一步,创建一个 iTextSharp.text.Document对象的实例: Document document = new Document(); 第二步,为该Document...
导入 <groupId>org.xhtmlrenderer <artifactId>core-renderer <version>R8 直接根目录下新建包org.xhtmlrenderer.layout 覆盖jar
IText 和 ITextAsian 的开发包
itext中文: public static void main(String[] args) { try { Document document = new Document(); OutputStream os = new FileOutputStream(new File("C:\\Users\\Administrator\\Desktop\\test.pdf")); ...
多个版本的itext-jar包, itext-2.0.4/itext-2.1.5/itext-2.1.7
iText是著名的开放源码的站点sourceforge一个项目,是用于生成PDF文档的一个java类库。通过iText不仅可以生成PDF或rtf的文档,而且可以将XML、Html文件转化为PDF文件。 iText的安装非常方便,下载iText.jar文件后,...
java解决Itext生成PDF中文不换行的问题
一共有12个文件,分步详解说明了iText创建Pdf的步骤,12个文件要5分步过分吧!
itext 生成pdf 目录,itext 生成pdf 目录,itext 生成pdf 目录
Itext5.5.13 完整的全套包,包含bcpkix-jdk15on-1.47.jar bcprov-jdk15on-1.59.jar itext-asian-5.2.0.jar itext-hyph-xml-5.1.1.jar itext-pdfa-5.5.13-javadoc.jar itext-pdfa-5.5.13-sources.jar itext-pdfa-...
iText1.2.7、iText-rtf2.1.7、iTextAsian
赠送jar包:itext-2.1.7.jar; 赠送原API文档:itext-2.1.7-javadoc.jar; 赠送源代码:itext-2.1.7-sources.jar; 赠送Maven依赖信息文件:itext-2.1.7.pom; 包含翻译后的API文档:itext-2.1.7-javadoc-API文档-...
itext 操作PDF需要的jar包
iText7jar和英文文档,以及itext5的一些文档。建议大家去官网看itext7,改动有点大。我也在摸索中。
iText-5.0.6.jar iTextAsian.jar
itext 生成pdf的中文帮助文档,具体有:图片、块(下划线/删除线、上标/下标)、短句、段落等。
IText7jar集合