Skip to main content
Java PDF SDK

Java PDF SDK for Editing Existing PDFs

Edit existing PDF text and objects from Java 17+ with typed request builders, synchronous service calls, and result diagnostics.

Configure Java 17 with Maven or Gradle

Pin the SDK artifact and the compiler configuration explicitly. The Maven example uses a modern compiler plugin so maven.compiler.release is honored.

Maven

Gradle

Compile a complete edit and inspect TextEditResponse

Download the public quick-start PDF as input.pdf. This complete class validates errors and the expected change count before saving to output.pdf.

Use typed Java requests across text and PDF objects

Request builders

Build literal or regular-expression replace, insert, delete, and style requests with Java types.

Read the operation guide

Layout contracts

Select source anchoring, reflow with fallback, or required reflow and inspect response diagnostics.

Read the operation guide

Pages and objects

Use document- and page-scoped clients for pages, images, vector paths, forms, XObjects, and fonts.

Read the operation guide

Extract typed reading-unit records from a document or page

Analyze the current session as classified text blocks with reading order, source-element provenance, page-space bounds, and relationships. Each synchronous call reflects the current session state.

Read the structured-text guide

Choose between anchored placement, reflow when possible, and required reflow

Select how replacement text should behave when its length changes: keep it anchored to the original position, reflow it when the document structure supports reflow, or require reflow and return an error when it cannot be applied.

  • sourceAnchored() retains the selected source position.
  • reflowWhenSupported() permits source-anchored fallback.
  • requireReflow() reports unsupported targets as errors.

Return edited PDF bytes from a Spring controller

The controller writes the multipart upload to a temporary file, opens it with released Java 3.0.1, checks the edit result, returns application/pdf, and deletes the temporary file. Configure multipart limits in Spring MVC, authorization in the Spring Security filter chain, server timeouts in the deployment platform, and exception responses with @ControllerAdvice.

Account for blocking calls, output paths, and application logging

RuntimeJava 17+
Client modelSynchronous
InputFile, path, or byte[]
ProcessingHosted PDFDancer service
  • The Java client is synchronous. Size request pools and service timeouts for network-bound PDF operations.
  • Text operations require editable PDF text rather than outlines, paths, page images, or unsupported encodings.
  • Use a separate session for each PDF. Test concurrent batch processing under your expected document sizes and request volume.
  • An SLF4J no-provider warning means the application has not selected a logging provider; it does not by itself mean the edit failed.
  • Saved output still requires workflow-specific PDF/A, digital-signature, rendering, and security validation.

Continue from dependency setup to the Java API

Java PDF SDK questions

Start Using PDFDancer Today

Get started in seconds with our free tier. No credit card required.

Want to evaluate first? Run the anonymous quick start.