### Include Activation Dependency with Maven
Source: https://pdfbox.apache.org/3.0/dependencies.html
Include the activation library, which was removed from the JDK starting with JDK 9, for preflight and some examples. Use version 1.1.1.
```xml
javax.activation
activation
1.1.1
```
--------------------------------
### Extract Pages from PDF Starting at a Specific Page
Source: https://pdfbox.apache.org/3.0/commandline.html
Creates a new PDF containing all pages from a specified starting page to the end of the original document. Requires the input PDF file.
```bash
PDFSplit -startPage=5 -i=sample_with_13_pages.pdf
```
--------------------------------
### Extract a Range of Pages from PDF
Source: https://pdfbox.apache.org/3.0/commandline.html
Creates a new PDF containing pages within a specified start and end page range. Requires the input PDF file.
```bash
PDFSplit -startPage=5 -endPage=10 -i=sample_with_13_pages.pdf
```
--------------------------------
### Include JAXB API Dependency with Maven
Source: https://pdfbox.apache.org/3.0/dependencies.html
Include the jaxb-api library, which was removed from the JDK starting with JDK 9, for preflight and some examples. Use version 2.3.1.
```xml
javax.xml.bind
jaxb-api
2.3.1
```
--------------------------------
### Create PDF from Text
Source: https://pdfbox.apache.org/3.0/commandline.html
Use this command to generate a PDF document from a plain text file. Specify input and output files, and optionally configure character set, font size, line spacing, margins, page size, and font type.
```bash
java -jar pdfbox-app-3.y.z.jar fromtext -i= -o=
```
--------------------------------
### Create PDF from Images
Source: https://pdfbox.apache.org/3.0/commandline.html
This command converts image files into a PDF document. You can specify input and output files, and control page size, resizing behavior, and auto-orientation based on image proportions.
```bash
java -jar pdfbox-app-3.y.z.jar fromimage -i= -o=
```
--------------------------------
### Load PDF with Scratch File Cache
Source: https://pdfbox.apache.org/3.0/faq.html
This approach loads a PDF using a scratch file, allowing for mixed memory and disk usage to handle memory constraints.
```java
Loader.loadPDF(file, () -> new ScratchFile(MemoryUsageSetting.setupMixed(...)))
```
--------------------------------
### Import XFDF Data to PDF
Source: https://pdfbox.apache.org/3.0/commandline.html
Imports AcroForm data from an XFDF file into a PDF document. Specify input PDF and XFDF data files.
```bash
java -jar pdfbox-app-3.y.z.jar import:xfdf [OPTIONS] -i=
```
--------------------------------
### Overlay PDF with Content
Source: https://pdfbox.apache.org/3.0/commandline.html
Overlays a base PDF document with content from one or more overlay PDF files. Supports different overlay strategies for specific pages or all pages.
```bash
java -jar pdfbox-app-3.y.z.jar overlay [OPTIONS] -i= -o=
```
```bash
overlayPDF -i=input.pdf -default=overlay.pdf -o=output.pdf
```
```bash
overlayPDF -i=input.pdf -default=defaultOverlay.pdf -page="10=overlayForPage10.pdf" -position=FOREGROUND -o=output.pdf
```
```bash
overlayPDF -i=input.pdf -odd=oddOverlay.pdf -even=evenOverlay.pdf -o=output.pdf
```
--------------------------------
### Include Bouncy Castle PKIX Dependency with Maven
Source: https://pdfbox.apache.org/3.0/dependencies.html
Include the bcpkix-jdk18on library from Bouncy Castle for public key encryption/decryption and signing/verifying PDFs. Use version 1.81.
```xml
org.bouncycastle
bcpkix-jdk18on
1.81
```
--------------------------------
### List Available Printers
Source: https://pdfbox.apache.org/3.0/commandline.html
Lists all available printers and their settings that can be used with the PDFBox print application. This command helps in identifying the correct printer name.
```bash
java -jar pdfbox-app-3.y.z.jar print -listPrinters
```
--------------------------------
### Add Libraries to Preflight Validator CLI Classpath
Source: https://pdfbox.apache.org/3.0/dependencies.html
Use this command to include JAR files from a 'lib' subdirectory in the classpath when running the Preflight validator command-line application. This is for A1b conformance checks.
```bash
java -cp "preflight-app-3.0.2.jar:./lib/*" org.apache.pdfbox.preflight.Validator_A1b args
```
--------------------------------
### Configure Log4j for PDFBox
Source: https://pdfbox.apache.org/3.0/faq.html
To suppress Log4j warnings, initialize the log4j system properly. You can set the log4j configuration using a system property.
```bash
log4j:WARN No appenders could be found for logger (org.apache.pdfbox.util.ResourceLoader).
log4j:WARN Please initialize the log4j system properly.
```
```bash
java -Dlog4j.configuration=log4j.xml org.apache.pdfbox.ExtractText
```
```bash
log4j.configuration=file:///
```
--------------------------------
### Include JAI Image I/O Core Dependency with Maven
Source: https://pdfbox.apache.org/3.0/dependencies.html
Include the JAI Image I/O Core library for reading JPEG 2000 (JPX) images in your project's pom.xml. Set the version field to the appropriate version.
```xml
com.github.jai-imageio
jai-imageio-core
...
```
--------------------------------
### Add Libraries to PDFBox CLI Classpath
Source: https://pdfbox.apache.org/3.0/dependencies.html
Use this command to include JAR files from a 'lib' subdirectory in the classpath when running the main PDFBox command-line application. Ensure the correct JAR file name and path are used.
```bash
java -cp "pdfbox-app-3.0.2.jar:./lib/*" org.apache.pdfbox.tools.PDFBox args
```
--------------------------------
### Convert PDF Pages to Images
Source: https://pdfbox.apache.org/3.0/commandline.html
Renders each page of a PDF document into an image file. Supports various image formats and quality settings. Requires the input PDF file.
```bash
java -jar pdfbox-app-3.y.z.jar render [OPTIONS] -i=
```
--------------------------------
### Include Bouncy Castle Provider Dependency with Maven
Source: https://pdfbox.apache.org/3.0/dependencies.html
Include the bcprov-jdk18on library from Bouncy Castle for public key encryption/decryption and signing/verifying PDFs. Use version 1.82.
```xml
org.bouncycastle
bcprov-jdk18on
1.82
```
--------------------------------
### Include JBIG2 ImageIO Dependency with Maven
Source: https://pdfbox.apache.org/3.0/dependencies.html
Include the JBIG2 library for reading JBIG2 images in your project's pom.xml. Set the version field to the appropriate version.
```xml
org.apache.pdfbox
jbig2-imageio
...
```
--------------------------------
### Include PDFBox Core Dependencies with Maven
Source: https://pdfbox.apache.org/3.0/dependencies.html
Add the main pdfbox library and its transitive dependencies to your project using Maven. Set the version field to the latest stable PDFBox version.
```xml
org.apache.pdfbox
pdfbox
...
```
--------------------------------
### Load PDF with Temporary File Cache
Source: https://pdfbox.apache.org/3.0/faq.html
Use this method to load a PDF using a temporary file for caching, which can help manage memory usage for large documents.
```java
Loader.loadPDF(file, IOUtils.createTempFileOnlyStreamCache())
```
--------------------------------
### Create PDType1Font instance
Source: https://pdfbox.apache.org/3.0/migration.html
Instantiate PDType1Font using the new constructor with Standard14Fonts.FontName. Instances are no longer singletons and may require user caching.
```java
new PDType1Font(Standard14Fonts.FontName.HELVETICA);
```
--------------------------------
### Load PDF using RandomAccessReadBufferedFile
Source: https://pdfbox.apache.org/3.0/migration.html
Use the Loader class with RandomAccessReadBufferedFile for flexible PDF loading. Ensure the PDDocument is closed properly to avoid issues.
```java
try (PDDocument document = Loader.loadPDF(new RandomAccessReadBufferedFile("yourfile.pdf")))
{
for (PDPage page : document.getPages())
{
....
}
}
```
--------------------------------
### Include Bouncy Castle Mail Dependency with Maven
Source: https://pdfbox.apache.org/3.0/dependencies.html
Include the bcmail-jdk18on library from Bouncy Castle for public key encryption/decryption and signing/verifying PDFs. Use version 1.82.
```xml
org.bouncycastle
bcmail-jdk18on
1.82
```
--------------------------------
### Include JAI Image I/O JPEG2000 Dependency with Maven
Source: https://pdfbox.apache.org/3.0/dependencies.html
Include the JAI Image I/O JPEG2000 library for reading JPEG 2000 (JPX) images in your project's pom.xml. Set the version field to the appropriate version.
```xml
com.github.jai-imageio
jai-imageio-jpeg2000
...
```
--------------------------------
### Print PDF Document
Source: https://pdfbox.apache.org/3.0/commandline.html
Sends a PDF document to a printer. Requires the input PDF file and appropriate printer permissions. Supports various printing options.
```bash
java -jar pdfbox-app-3.y.z.jar print [OPTIONS] -i=
```
--------------------------------
### Enable Subsampling for Rendering
Source: https://pdfbox.apache.org/3.0/faq.html
Activate subsampling on the PDFRenderer to potentially reduce memory usage during image rendering.
```java
setSubsamplingAllowed(true);
```
--------------------------------
### Split PDF into 2-Page Chunks
Source: https://pdfbox.apache.org/3.0/commandline.html
Splits a PDF into multiple files, with each file containing 2 pages, except for the last file which may contain fewer pages. Requires the input PDF file.
```bash
PDFSplit -split=2 -i=sample_with_13_pages.pdf
```
--------------------------------
### Split PDF Document into Multiple Files
Source: https://pdfbox.apache.org/3.0/commandline.html
Splits a PDF document into smaller files. Each new file will be named with a sequential number appended to the original filename prefix. Use 'outputPrefix' to customize filenames.
```bash
java -jar pdfbox-app-3.y.z.jar split [OPTIONS] -i=
```
--------------------------------
### Split a PDF Range into Multiple Files
Source: https://pdfbox.apache.org/3.0/commandline.html
Splits a specified range of pages from a PDF into multiple smaller files, each containing a set number of pages. Requires the input PDF file.
```bash
PDFSplit -split=2 -startPage=5 -endPage=10 -i=sample_with_13_pages.pdf
```
--------------------------------
### Include TwelveMonkeys JPEG Dependency with Maven
Source: https://pdfbox.apache.org/3.0/dependencies.html
Include the TwelveMonkeys imageio-jpeg library for more reliable JPEG decoding in your project's pom.xml. Set the version field to the appropriate version.
```xml
com.twelvemonkeys.imageio
imageio-jpeg
...
```
--------------------------------
### Decompress PDF Document
Source: https://pdfbox.apache.org/3.0/commandline.html
Use this command to decompress a PDF document, making its content readable with a text editor. Specify the input PDF file and the output file path for the decompressed version. Optionally, provide a password or choose to skip image decompression.
```bash
java -jar pdfbox-app-3.y.z.jar decode [OPTIONS]
```
--------------------------------
### Save PDF without Compression
Source: https://pdfbox.apache.org/3.0/migration.html
Override the default compressed saving behavior by using PDDocument.save with CompressParameters.NO_COMPRESSION, particularly for creating PDF/A-1b documents.
```java
PDDocument.save(PDDocument, CompressParameters.NO_COMPRESSION);
```
--------------------------------
### Add pdfbox-io Maven Dependency
Source: https://pdfbox.apache.org/3.0/migration.html
Include the pdfbox-io module in your Maven project to utilize the new IO classes.
```xml
org.apache.pdfbox
pdfbox-io
```
--------------------------------
### Debug PDF Structure
Source: https://pdfbox.apache.org/3.0/commandline.html
Analyzes and inspects the internal structure of an existing PDF document. Can optionally open a specified PDF file.
```bash
java -jar pdfbox-app-3.y.z.jar debug [inputfile]
```
--------------------------------
### Add PDFBox 3.0 Maven Dependency
Source: https://pdfbox.apache.org/3.0/getting-started.html
Include this dependency in your Maven project to use the latest PDFBox release.
```xml
org.apache.pdfbox
pdfbox
3.0.7
```
--------------------------------
### Enable Text Sorting by Position
Source: https://pdfbox.apache.org/3.0/faq.html
Use this setting to extract text in a left-to-right, top-to-bottom order, which is often more intuitive than the default content stream order.
```java
setSortByPosition(true);
```
--------------------------------
### Enable Pure Java CMYK Conversion for Rendering Performance
Source: https://pdfbox.apache.org/3.0/getting-started.html
Use this JVM argument to potentially improve PDF rendering performance, especially for pages with many images. This setting is available since PDFBox 2.0.4.
```java
-Dorg.apache.pdfbox.rendering.UsePureJavaCMYKConversion=true
```
--------------------------------
### Merge PDF Documents
Source: https://pdfbox.apache.org/3.0/commandline.html
Merges a list of PDF documents into a single output PDF file. Requires specifying the output file and at least one input file.
```bash
java -jar pdfbox-app-3.y.z.jar merge [-hV] -o=outfile -i= [-i=]
```
--------------------------------
### Properly Close PDDocument
Source: https://pdfbox.apache.org/3.0/faq.html
Ensure that all PDDocument objects are closed to avoid warnings. Use a finally block to guarantee the close() method is called, even if errors occur.
```java
PDDocument doc = new PDDocument();
try
{
doc = PDDocument.loadPDF( "my.pdf" );
}
finally
{
if( doc != null )
{
doc.close();
}
}
```
--------------------------------
### Extract Text from PDF
Source: https://pdfbox.apache.org/3.0/commandline.html
Extracts all text from a specified PDF document. Supports various output formats and page range selections.
```bash
java -jar pdfbox-app-3.y.z.jar export:text [OPTIONS] -i=
```
--------------------------------
### Disable Resource Cache for Images
Source: https://pdfbox.apache.org/3.0/faq.html
Disable the cache for PDImageXObject objects to prevent excessive memory consumption, especially for PDFs with repeated images. This may slow down rendering for such files.
```java
PDDocument.setResourceCache(new DefaultResourceCache() {
@Override
public void put(COSObject indirect, PDXObject xobject) {
// do nothing
}
});
```
--------------------------------
### Disable Gsub for Complex Scripts
Source: https://pdfbox.apache.org/3.0/migration.html
Deactivate the complex script feature, including Latin ligatures and Indian scripts, by calling TrueTypeFont.setEnableGsub(false) if visual differences are undesirable.
```java
TrueTypeFont.setEnableGsub(false);
```
=== COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.