tech.chakapoko.com
Home / Java / Apache PDFBox

[Java]PDFBoxで空のPDFを作成する

package com.example;

import org.apache.pdfbox.pdmodel.PDDocument;
import org.apache.pdfbox.pdmodel.PDPage;

import java.io.File;
import java.io.IOException;

public class PDFBoxExample {

    public static void main(String[] args) throws IOException {
        try (PDDocument pdDocument = new PDDocument()) {
            PDPage pdPage = new PDPage();
            pdDocument.addPage(pdPage);
            pdDocument.save(new File("Example.pdf"));
        }
    }
}

create-a-blank-file.png