Copier un champ depuis un autre PDF

Copier un champ d’un autre PDF

  1. Créez un PDF de destination avec au moins une page.

  2. Liez le PDF de destination à la façade FormEditor.

  3. Appelez copyOuterField(...) avec le chemin du document source, le nom du champ, la page cible et les coordonnées.

  4. Enregistrez le document de destination mis à jour.

public static void copyOuterField(Path inputFile, Path outputFile) {
    try (Document document = new Document()) {
        document.getPages().add();
        document.save(outputFile.toString());
    }

    FormEditor editor = new FormEditor();
    try {
        editor.bindPdf(outputFile.toString());
        editor.copyOuterField(inputFile.toString(), "First Name", 1, 200, 600);
        editor.save(outputFile.toString());
    } finally {
        editor.close();
    }
}