前面我们介绍了如何设置PDF 文档属性,该文将介绍如何使用Spire.PDF for Java设置PDF文档自定义属性.
import com.spire.pdf.*;
public class PDFCustomProperties {
public static void main(String[] args) throws Exception {
String inputPath = "Sample.pdf";
PdfDocument doc = new PdfDocument(inputPath);
doc.loadFromFile(inputPath);
//设置自定义属性
doc.getDocumentInformation().setCustomerDefined("Number", "123");
doc.getDocumentInformation().setCustomerDefined("Name", "Daisy");
doc.getDocumentInformation().setCustomerDefined("Company", "e-iceblue");
//保存文档
doc.saveToFile("Output/Result.pdf");
doc.close();
}
}
效果图: