Skip to main content

Posts

How to Add and Remove Attachments in PDF Using Java

  In many professional and academic scenarios, PDF documents often need to carry additional files, such as Excel spreadsheets, PowerPoint slides, or supplementary data. Being able to manage attachments within a PDF can improve document organization, facilitate sharing, and make it easier for recipients to access related materials. In this article, we will explore four practical ways to add and remove attachments in PDF files using Java , covering both direct attachments and annotation-based attachments: Adding a standard attachment to a PDF Attaching a file via annotation Removing standard attachments Removing annotation-based attachments Installing the Required Library To implement these examples, we use Spire.PDF for Java , a library that provides APIs for loading PDF documents, adding attachments, managing annotations, and saving changes. You can download the JAR package or include it via Maven: <repositories> <repository> <id> com.e-iceblue </...

How to Find and Highlight Text in PDF Using Java: 4 Practical Methods

  PDF documents are widely used in reports, contracts, textbooks, and exams. Often, we need to search for specific text and highlight it —for example, marking key terms in reports, highlighting important clauses in contracts, or extracting certain content for analysis. Manual processing is time-consuming and prone to errors, so automating text search and highlighting in PDFs is essential. In this guide, we’ll demonstrate four practical ways to find and highlight text in PDF files using Java : Highlight text on a single page Highlight text within a specific rectangular area Highlight text throughout the entire document Highlight text using regular expressions Installing the Required Library We use Spire.PDF for Java , a powerful PDF processing library that allows you to load PDFs, search text, edit content, and highlight text. You can download the JAR package or include it via Maven: <repositories> <repository> <id> com.e-iceblue </id> ...