PDF⽂件如何盖(骑缝章)
对于⽆纸化操作pdf⽂件如果需要打印,⼀般为了保证完整有效性⽤数字签名就可以了,但是需要打印纸质后数字签名就呵呵了,对于⼈眼的完整⾏只能靠骑缝章来简单的保证⼀下了。所以骑缝章完全事为了⼈类⾁眼识别出来的⼀个东西。对于要打印的pdf加⼀个骑缝章,⽆⾮就是把章按页数切割成等份的图⽚,合并在⼀起罢了。
import BadElementException;
import DocumentException;排比的答题格式
import Image;
罚款通知单范本
import Rectangle;
import pdf.PdfContentByte;
import pdf.PdfReader;
import pdf.PdfStamper;
import javax.imageio.ImageIO;
import java.awt.image.BufferedImage;
import java.io.*;
地道战观后感300字
/**
* 盖骑缝章
* Created by zhangzhenhua on 2016/11/2.
*/
public class PDFStamperCheckMark {
/**
* 切割图⽚
* @param imgPath 原始图⽚路径
* @param n 切割份数
* @return itextPdf的Image[]
* @throws IOException
* @throws BadElementException
*/
public static Image[] subImages(String imgPath,int n) throws IOException, BadElementException {
Image[] nImage = new Image[n];
ByteArrayOutputStream out = new ByteArrayOutputStream();
BufferedImage img = ad(new File(imgPath));
int h = Height();
祖父的园子主要内容int w = Width();
int sw = w/n;
怎么去油渍for(int i=0;i<n;i++){
科比介绍BufferedImage subImg;
if(i==n-1){//最后剩余部分
subImg = Subimage(i * sw, 0, w-i*sw, h);
}el {//前n-1块均匀切
subImg = Subimage(i * sw, 0, sw, h);
}
ImageIO.write(subImg,imgPath.substring(imgPath.lastIndexOf('.')+1),out);
nImage[i] = ByteArray());
out.flush();
<();
}
return nImage;
}
/**
黑斑鱼* 盖骑缝章
*
* @param infilePath 原PDF路径
* @param outFilePath 输出PDF路径
* @param picPath 章图⽚路径
* @throws IOException
* @throws DocumentException
*/
public static void stamperCheckMarkPDF(String infilePath,String outFilePath,String picPath) throws IOException, DocumentException {
PdfReader reader = new PdfReader(infilePath);//选择需要印章的pdf
PdfStamper stamp = new PdfStamper(reader, new FileOutputStream(outFilePath));//加完印章后的pdf
Rectangle pageSize = PageSize(1);//获得第⼀页
float height = Height();
float width = Width();
int nums = NumberOfPages();
Image[] nImage = subImages(picPath,nums);//⽣成骑缝章切割图⽚
for(int n=1;n<=nums;n++){
PdfContentByte over = OverContent(n);//设置在第⼏页打印印章
Image img = nImage[n-1];//选择图⽚
// img.tAlignment(1);
// img.scaleAbsolute(200,200);//控制图⽚⼤⼩
元宵节内容
img.Width(),Height()/2);//控制图⽚位置 over.addImage(img);
}
stamp.clo();
}
public static void main(String[] args) throws IOException, DocumentException {
String infilePath = "E:\\项⽬\\paperless\\page.pdf";
String outfilePaht = "E:\\项⽬\\paperless\\page_pic.pdf";
String picPath = "E:\\项⽬\\paperless\\公章.png";
stamperCheckMarkPDF(infilePath,outfilePaht,picPath);
}
}