diff options
author | Teddy Wing | 2023-04-23 01:38:45 +0200 |
---|---|---|
committer | Teddy Wing | 2023-04-23 01:38:45 +0200 |
commit | 033ab9c40cd39dd71bf1b1cfbc5646a97b79fb21 (patch) | |
tree | b0875849613af3261f1f3931303c33cc91d2fb97 | |
parent | d48f72fd266fb9b6b48122a4b192140774475416 (diff) | |
download | pdf-form-replace-font2-033ab9c40cd39dd71bf1b1cfbc5646a97b79fb21.tar.bz2 |
Main.java: Only change font if it matches a given font name
Don't change all of the input fields' font to the replacement, only
those with a specific font we want to replace.
-rw-r--r-- | Main.java | 14 |
1 files changed, 13 insertions, 1 deletions
@@ -20,8 +20,20 @@ public class Main { Map<String, PdfFormField> fields = form.getFormFields(); for (var entry : fields.entrySet()) { + // TODO: Try printing original font family and size on field. PdfFormField field = entry.getValue(); - field.setFont(courier); + + PdfFont original_font = field.getFont(); + // System.out.println("Font: " + original_font); + + String original_postscript_name = original_font + .getFontProgram() + .getFontNames() + .getFontName(); + + if (original_postscript_name.equals("HelveticaLTStd-Bold")) { + field.setFont(courier); + } } pdf.close(); |