Replace text in PDF file

Aspose.PDF Cloud API lets you create Cloud-based applications in your favorite programming language. You can create PDF documents from scratch, edit existing PDF files or convert supported file formats with the API. You can replace text in a PDF document as well as encrypt it with Password protection. Many other robust features are offered by the API that you can integrate into your applications.

Find and replace text is one of the commonly used features of almost all word processing applications. You might want to update some text in hundreds or thousands of PDF documents. With Aspose.PDF Cloud API, you can automate this task and achieve your requirements in little time by few lines of code. You can use any of the following APIs as per your requirements:

Sr. No. API Description
1 POST /pdf/{name}/text/replace Replace Text Items from a PDF Document
2 POST /pdf/{name}/pages /{pageNumber}/text/replace Replace all Text Items from a Page in a PDF Document

Let us discuss both use cases one by one. The scope of first one extends to the whole PDF document. It finds and replaces all occurrences of specific text and updates it with new text. Below .NET code snippet finds and replaces market with m_a_r_k_e_t in all pages of the document.

TextReplaceListRequest is a multiple text replacements request where Request Object Structure includes “TextReplaces” as a list of text replacement settings, “DefaultFont” as name of font to use if requested font is not embedded, “StartIndex” as index of the first match to be replaced, and “CountReplace” as the number of matches to be replaced.

Find and replace text

This screenshot elaborates on the efficiency of API where several instances of text are replaced in all sections of the page.

Find and Replace text on the page level

You can also update the text on a specific page with Aspose.PDF Cloud API. The text replacement can further be narrowed down to a specific area of a page with rectangular coordinates. However, please bear in mind that bottom left is the (0,0) coordinate and the standard unit in Aspose.PDF Cloud API is “Point” where 72 points equal 1 inch. The following code snippet is written using Aspose.PDF Cloud SDK for .NET, which is a wrapper around REST API allowing you to process documents quickly and easily in .NET, gaining all benefits of strong types and IDE highlights

Text replacement in a specific area of the page is further clarified by this screenshot as compared to the image we have considered in the previous example.

Encrypt and Password Protect a PDF Document

PDF documents can often contain confidential information so you might need to secure it from unauthorized access. Aspose.PDF Cloud API offers the most advanced Crypto Algorithms including RC4x40, RC4x128, AESx128, and AESx256. In addition to encryption, the API supports setting up an owner or permission password as well as a user password. Below is the .NET code snippet utilizing same feature:

Aspose.PDF Cloud API offers many other advanced features that can make your applications truly feature-rich. You can Sign Up for Free Trial and explore API references as well as API documentation for further information. In case of any assistance, please feel free to contact us via Free Support Forum.

Related Post:

Convert HTML to PDF with Aspose.PDF Cloud API