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.
- Open Rups and navigate to the Resources dictionary of Page 1.
- Select the Font Dictionary as shown in the screenshot below.
- In the dictionary details window double click the value for /BaseFont and change it to /TimesNewRoman.
- Save the PDF.
The saved PDF now displays the text using the Times New Roman 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:
Using the steps described above we are going to change the font to Times New Roman to make it look like this:
For our next step, we're going to get rid of the header.
- Navigate to the Page 1 page dictionary as shown in the screenshot below.
- Double click the value of the /MediaBox entry and enter the following value: [0, 200, 545, 670]
- Save the PDF.
If you open the PDF, you will see that the page has shrunk and that the watermark now runs from corner to corner.
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 homepage.