摘要: public static List<int> GetPage() {string strpath = @"D:\test.txt"; FileStream fs = new FileStream(strpath, FileMode.Open, FileAccess.Read); StreamReader sr = new StreamReader(fs, Encoding.Default); sr.BaseStream.Seek(0, SeekOrigin.Begin); string str = sr.ReadLine(); while (str != nu 阅读全文
posted @ 2012-11-29 18:06 息晴海 阅读(253) 评论(0) 推荐(0) 编辑
摘要: 在PDF中当涉及到布局问题时(不再是自动地添加文本、图片等等,对元素在页面上的位置有一定的要求),有时我们希望将一些图像或者文本放置在某页的指定位置,为实现该功能,我们将使用PdfContentByte类。PdfContent对象可以通过在使用Writer对象中使用getDirectContent()方法来得到该对象。例:PdfWriter writer=PdfWriter.GetInstance(document, new FileStream("D:\\hellowrold.pdf", FileMode.OpenOrCreate));PdfContentByte cb= 阅读全文
posted @ 2012-11-29 01:46 息晴海 阅读(10086) 评论(0) 推荐(0) 编辑
摘要: Document:一个PDF文档组件pdfWriter:书写器,用于往document中写入信息Chunk:文本块,这是可以写入文档的最小组件Phrase:短语,由一系列Chunk组成paragraph:段落,由一系列的Phrase或者Chunk组成Rectangle:代表几何图形组件。类似html中的Box以下为简单的pdf文件生成代码,注意文档和书写器的关联代码,以及两个异常。 public static void ProNewPdf() { Document document = new Document(); try { PdfWriter.GetInstance(document, 阅读全文
posted @ 2012-11-29 00:59 息晴海 阅读(406) 评论(0) 推荐(0) 编辑
摘要: 在iText中,当创建一个文件时,是可以定义上、下、左、右页边距的。例如:Document document=new Doucment(PageSize.A5,36,72,108,180);即该文档有一个0.5英寸的左边距和1英寸的右边距,上边距为1.5英寸,下边距为2.5英寸。说明:当创建一个矩形或设置页边距时,我们希望回到该用什么度量单位。例厘米、英寸或像素。事实上,默认的度量系统以排版单位磅为基础得出其他单位的近似值,例,1英寸=72磅,如果想在A4页面中创建一个矩形,需计算以下数据:21厘米/2.54=8.2677英寸8.2677英寸*72=595磅29.7厘米/2.54=11.692 阅读全文
posted @ 2012-11-29 00:30 息晴海 阅读(1570) 评论(0) 推荐(2) 编辑