C# 填充pdf 模板生成报告

         C#生成pdf文件,比较了很多方法,最后,先用Adobe Acrobat DC生成一个pfd报告模板(主要是为的以后修改方便),然后C#读取模板pdf文件,向里面填充数据,图片。

           类似于这样

  coderBlogForm.SetField("REPORT_NUM", model.REPORT_NUM);

 

       其它资料:

图像的位置主要是指图像在文档中的对齐方式、图像和文本的位置关系。 IText中通过函数public void setAlignment(int alignment)进行处理, 参数alignment为Image.RIGHT、Image.MIDDLE、Image.LEFT分 别指右对齐、居中、左对齐;

 当参数alignment为Image.TEXTWRAP、Image.UNDERLYING分别 指文字绕图形显示、图形作为文字的背景显示。

 这两种参数可以结合以达到预期的效果,

 如setAlignment(Image.RIGHT|Image.TEXTWRAP)

 显示的效果为图像右对齐,文字围绕图像显示。

 图像的尺寸和旋转

 //设置图像的宽和高

 image.scaleAbsolute(int newWidth, int newHeight);

 //设置图像比例,表示显示的大小为原始大小的多少比例

 image.scalePercent(int percent);

 //设置图像的高宽比例

 image.scalePercent(int percentX,int percentY);

 //设置图像旋转一定的角度;参数arg为弧度,而不是角度

 image.setRotation(float arg);

图像的尺寸和旋转

 如果图像在文档中不按原尺寸显示,可以通过下面的函数进行设定:

public void scaleAbsolute(int newWidth, int newHeight)

public void scalePercent(int percent)

public void scalePercent(int percentX, int percentY)

 函数public void scaleAbsolute(int newWidth, int newHeight)直接设定显示尺寸;

函 数public void scalePercent(int percent)设定显示比例,如scalePercent(50)表示显示的大小为原尺 寸的50%;

而函数scalePercent(int percentX, int percentY)则图像高宽的显示比例。

posted @ 2017-07-05 10:58  林子……  阅读(3164)  评论(0编辑  收藏  举报