Available starting from PD4ML v4.1.1

8 runnable, self-contained com.pd4ml.pdf.merge use-case examples - the page-range grammar, shared-resource dedup, encrypted sources/output, and tagging reconciliation.

Package root com.pd4ml.pdf.merge.example.usecases Class count 8

1. Running the examples

All examples live under src/test/java/com/pd4ml/pdf/merge/example/usecases/ (test scope - not shipped in the distributed jar) and are ordinary runnable classes with a main(String[] args). Easiest from an IDE: right-click the class, Run. From the command line:

$ mvn test-compile
$ mvn dependency:build-classpath -Dmdep.outputFile=cp.txt
$ java -cp "target/test-classes;target/classes;$(cat cp.txt)" \
     com.pd4ml.pdf.merge.example.usecases.<ClassName> <args...>
Not untested snippets

Every example builds its own small sample PDF(s) in memory (no external fixture files needed) and was actually run end-to-end.

↑ Back to top

2. Example index

#ClassDemonstrates
01Ex01_BasicTwoSourceMergeThe minimal call: select a page range from two sources and merge them. Start here.
02Ex02_PageRangeGrammarThe full page-range grammar: N, N-M (descending too), N+, and odd/even as suppressing filters, with deduplication.
03Ex03_SingleSourceFilterAndReorderWith exactly one source, selectPages(...) doubles as a filter/reorder pass, not just a subset tool.
04Ex04_SharedResourceDeduplicationTwo pages of the same source sharing one font object are cloned exactly once in the output.
05Ex05_EncryptedSourceMergingMerging an encrypted source alongside a plain one - transparent decryption via addSource's password.
06Ex06_EncryptOutputEncrypting the merged output, via the AES-256 shortcut or full PdfEncryptor.Options control.
07Ex07_TaggingReconciliationMerging a tagged source with an untagged one - best-effort /StructTreeRoot reconciliation.
08Ex08_ErrorHandlingPatternsEvery PdfMergeException failure mode and how to recognize it.

For a ready-made command-line tool covering the same ground without writing any code, see the pd4mergecli Reference and run com.pd4ml.pdf.merge.cli.Pd4MergeCli.

↑ Back to top

3. See also

↑ Back to top
PD4ML Merge Examples · Java 1.8 · com.pd4ml.pdf.merge.example.usecases · no third-party PDF dependency