aboutsummaryrefslogtreecommitdiffstats
AgeCommit message (Collapse)Author
2023-04-23pom.xml: Add iText 7.2.5 dependencyTeddy Wing
Thanks to this Stack Overflow answer by Raphaƫl Colantonio (https://stackoverflow.com/users/3728901/rapha%c3%abl-colantonio) for the tip about type:pom : https://stackoverflow.com/questions/70086051/itextpdf-dependency-not-found-by-maven/70090910#70090910 Without that tag, the compile failed.
2023-04-23.gitignore: Ignore the Maven target/ directoryTeddy Wing
2023-04-23Regenerate Maven project structureTeddy Wing
The previous one wouldn't compile because I used hyphens in my package name. Regenerate the project structure replacing the hyphens with underscores: $ mvn archetype:generate -DarchetypeGroupId=org.apache.maven.archetypes -DarchetypeArtifactId=maven-archetype-simple -DarchetypeVersion=1.4 ... Define value for property 'groupId': com.teddywing.pdf_form_replace_font2 Define value for property 'artifactId': pdf-form-replace-font2 Define value for property 'version' 1.0-SNAPSHOT: : 0.0.1-SNAPSHOT Define value for property 'package' com.teddywing.pdf_form_replace_font2: : Confirm properties configuration: groupId: com.teddywing.pdf_form_replace_font2 artifactId: pdf-form-replace-font2 version: 0.0.1-SNAPSHOT package: com.teddywing.pdf_form_replace_font2 Y: :
2023-04-23Generate a Maven project structureTeddy Wing
I followed the Maven Getting Started (https://maven.apache.org/guides/getting-started/index.html) guide to set up a project structure so I could use it to manage dependencies. I picked the 'maven-archetype-simple' archetype (https://maven.apache.org/archetypes/maven-archetype-simple/). This code was generated with the following command and interactive prompts: $ mvn archetype:generate -DarchetypeGroupId=org.apache.maven.archetypes -DarchetypeArtifactId=maven-archetype-simple -DarchetypeVersion=1.4 Define value for property 'groupId': com.teddywing.pdf-form-replace-font2 Define value for property 'artifactId': pdf-form-replace-font2 Define value for property 'version' 1.0-SNAPSHOT: : 0.0.1-SNAPSHOT Define value for property 'package' com.teddywing.pdf-form-replace-font2: : Confirm properties configuration: groupId: com.teddywing.pdf-form-replace-font2 artifactId: pdf-form-replace-font2 version: 0.0.1-SNAPSHOT package: com.teddywing.pdf-form-replace-font2 Y: :
2023-04-23Main.java: Switch form field font to Courier NewTeddy Wing
2023-04-23Main.java: Don't embed the fontTeddy Wing
This finally works. My guess is that the library was embedding the font and, crucially, _subsetting_ the font. But since we don't set any values before writing out the PDF, it was probably subsetting to 0 glyphs, effectively making it appear that the desired font wasn't being set. Forcing no embedding renders the font correctly.
2023-04-23Main.java: Trying to use a TTF to replace the font, not workingTeddy Wing
Still working on this, trying to figure out why the font replacement isn't working.
2023-04-23Main.java: Debug font sizeTeddy Wing
2023-04-23Main.java: Only change font if it matches a given font nameTeddy Wing
Don't change all of the input fields' font to the replacement, only those with a specific font we want to replace.
2023-04-22Change PDF form field fontTeddy Wing
Use iText to change the font of interactive form fields in a PDF. Changes the font in 'f1040.pdf' to Courier. This code is based on the following example from iText: https://kb.itextsupport.com/home/it7kb/ebooks/itext-7-jump-start-tutorial-for-net/chapter-5-manipulating-an-existing-pdf-document-net#Chapter5:ManipulatinganexistingPDFdocument|.NET-Changingthepropertiesofformfields For now I just downloaded the dependencies' JAR files and put them in a 'lib/' directory rather than have to learn how to use a dependency management tool like Maven. Here is the contents of the 'lib/' directory: barcodes-7.2.2.jar commons-7.2.2.jar font-asian-7.2.2.jar forms-7.2.2.jar hyph-7.2.2.jar io-7.2.2.jar kernel-7.2.2.jar layout-7.2.2.jar pdfa-7.2.2.jar pdftest-7.2.2.jar sign-7.2.2.jar slf4j-api-1.7.9.jar styled-xml-parser-7.2.2.jar svg-7.2.2.jar To run this: $ make $ make run