Skip to main content

Posts

How to Merge PDF Files in Java: Entire Documents, Selected Pages, and Input Streams

  When preparing reports or organizing project files, you may need to combine several PDFs into a single document. Sometimes you need all the pages from each file. Other times, you only want to include certain pages. If the PDF data comes from memory or a network response, working with input streams may be more convenient. This article covers three ways to merge PDFs in Java: combining entire documents, merging selected pages from multiple PDFs, and merging PDFs using input streams. 1. Add the Maven Dependency First, add the following repository and dependency to your Java project's pom.xml file: <repositories> <repository> <id> com.e-iceblue </id> <name> e-iceblue </name> <url> https://repo.e-iceblue.com/nexus/content/groups/public/ </url> </repository> </repositories> <dependencies> <dependency> <groupId> e-iceblue </groupId> <arti...

Find and Highlight Text in Word Documents Using Java

When reviewing Word documents, you may need to highlight specific words or phrases. For example, you might want to mark every occurrence of "risk" in a report, or highlight phrases such as "risk assessment" and "risk analysis". Java can handle both exact text searches and pattern-based searches. This article shows how to highlight the first match or all matches using either strings or regular expressions. 1. Install a Word Document Processing Library Add the following repository and dependency to your Maven project's pom.xml file: <repositories> <repository> <id> com.e-iceblue </id> <name> e-iceblue </name> <url> https://repo.e-iceblue.com/nexus/content/groups/public/ </url> </repository> </repositories> <dependencies> <dependency> <groupId> e-iceblue </groupId> <artifactId> spire.doc </artifactId...