Skip to content

wharvex/PdfBoxDemo2

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
 
 
 
 
 
 
 
 

Repository files navigation

Add Text to PDF (PDFBox 3.0.5) - Maven project

This small utility appends text to an existing PDF using Apache PDFBox 3.0.5.

Requirements:

  • Java 17+
  • Maven

Build:

mvn package

The build produces a shaded runnable jar in: target/add-text-pdf-1.0.0.jar

Usage:

java -jar target/add-text-pdf-1.0.0.jar <input.pdf> <output.pdf> "<text-to-add>" [pageIndex] [x] [y] [fontSize]

Parameters:

  • input.pdf: path to existing PDF
  • output.pdf: path to write the modified PDF
  • "text-to-add": quoted text; supports newlines with \n
  • pageIndex: zero-based page index (default: 0)
  • x: x coordinate in PDF user space units (default: 50)
  • y: y coordinate in PDF user space units (default: 700)
  • fontSize: font size in points (default: 12)

Examples:

  • Append "Hello" on first page at (50,700):

    java -jar target/add-text-pdf-1.0.0.jar input.pdf output.pdf "Hello"
  • Append multi-line text on page 2 at (100,600) with 14pt:

    java -jar target/add-text-pdf-1.0.0.jar input.pdf output.pdf "Line1\nLine2" 1 100 600 14

Notes:

  • This program appends text (does not remove or reflow existing content).
  • Coordinates origin is at the bottom-left of the page.
  • The default font is Helvetica-Bold (PDType1Font.HELVETICA_BOLD).

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages