RUPS Tutorial

iText RUPS: use RUPS to change your PDF syntax and dictionaries

RUPS logo

RUPS is a PDF inspection tool, which we use a lot internally to inspect PDFs received from customers and users. Although RUPS stands for Reading and Updating PDF Syntax, it wasn't able to update PDFs. Until recently...

We added functionality to update PDF dictionaries allowing us to test out other values in dictionary entries. This functionality was added in RUPS 5.5.0.

In this small tutorial we are going to demonstrate two cases where you could use RUPS to change your PDF syntax and Dictionaries. 

A warning before we start:

Do not randomly edit your PDF and expect a valid output. Using these techniques will most likely corrupt your PDF if you don't know what you are doing. If you are unsure on what you can change, consult the PDF specification.

Changing the Font

Let's start with an easy sample. We are going to change the font in a PDF. Our initial PDF is a simple hello world PDF. If you look at the fonts used in this PDF you'll see that the default Helvetica font was used. We are going to change Helvetica to Times New Roman.

  1. Open RUPS and navigate to the Resources dictionary of Page 1.
  2. Select the Font Dictionary as shown in the screenshot below.
  3. In the dictionary details window double click the value for /BaseFont and change it to /TimesNewRoman.
  4. Save the PDF.

RUPS tool

The saved PDF now displays the text using the Times New Roman font instead of Helvetica.
You can also remove the /BaseFont entry by clicking the red cross. This action might result in a PDF that looks different based on the viewer application and OS.


Changing the look of pages

In our next example, we are going to change an entire page. We'll start by taking the PDF of the stationery sample from the book "iText in Action, Second Edition". This is what it looks like before we begin:

Company stationery

Using the steps described above we are going to change the font to Times New Roman to make it look like this:

Company stationery

For our next step, we're going to get rid of the header.

  1. Navigate to the Page 1 page dictionary as shown in the screenshot below.
  2. Double click the value of the /MediaBox entry and enter the following value: [0, 200, 545, 670]
  3. Save the PDF.

RUPS tool

If you open the PDF, you will see that the page has shrunk and that the watermark now runs from corner to corner.

Altered mediabox

That concludes our small tutorial on how to use RUPS to update your PDF. We repeat our warning from before: Think before you edit.

Go to the iText RUPS page.

Ready to use iText?

Try our iText 7 Library and add-ons FREE for 30 days. Test your proof of concept, and see if our solution is right for you.

Get my FREE trial

Still have questions? 

We're happy to answer your questions. Reach out to us and we'll get back to you shortly.

Contact us
Stay updated

Join 11,000+ subscribers and become an iText PDF expert by staying up to date with our new products, updates, tips, technical solutions and happenings.

Subscribe Now