java使用PDFBox为PDF填加水印

看了很多例子后总结出来的

1、maven依赖

 
       org.apache.pdfbox
       pdfbox

       2.0.9

2、官方API :https://pdfbox.apache.org/docs/2.0.1/javadocs/

3、代码

package com.weikaisen.pdfbox;

import org.apache.pdfbox.pdmodel.PDDocument;
import org.apache.pdfbox.pdmodel.PDPage;
import org.apache.pdfbox.pdmodel.PDPageContentStream;
import org.apache.pdfbox.pdmodel.PDResources;
import org.apache.pdfbox.pdmodel.font.PDFont;
import org.apache.pdfbox.pdmodel.font.PDType1Font;
import org.apache.pdfbox.pdmodel.graphics.state.PDExtendedGraphicsState;
import org.apache.pdfbox.util.Matrix;
import java.io.File;
public class PDFBoxTest {

    private static void watermarkPDF (File fileStored) throws Exception {
        File tmpPDF;
        PDDocument doc;


你可能感兴趣的:(java使用PDFBox为PDF填加水印)