Log in Sign up

Edit PDF

Remember that in order to use our Tool Guides, you need to have previous knowledge about the basics to processing a PDF with our REST API. We strongly recommend that you read the Processing a PDF guide before starting this one.

Basic Edit PDF

The following example will show you how to add text elements to a PDF document. Take into account that by simply adding a text element, it will come with properties by default.

You can learn more about how to customize elements properties later in advanced samples.

Basic Edit PDF

As the whole process of creating the editpdf task (uploading your PDF, processing it and downloading it) works as explained in Processing a PDF, let’s focus on creating elements.

There are a few elements that can be added to a pdf: text, image or svg. Use the class associated to create the corresponding element, modify its properties if it is required and add it to the task. After doing this, you have a PDF file with a new element on it and ready to process.

Now it’s time to see more advanced examples to set element properties or add image elements to the PDF.

Advanced Edit PDF

First, take a look at the properties applicable to any element:

  • pages sets at which pages the element/s will be applied to. Cannot be less than 1.
  • rotation sets the rotation of the element/s in degrees. From 0 to 360.
  • opacity sets the grade of opacity of the element/s. From 0 to 100.
  • coordinates sets the position of the element in x,y coordinates. If no coordinates are specified, the element will be placed in the center of the page by default.
  • zindex value to calculate stack order in case of overlaping.
Unlike in all the other tools, in the Edit PDF tool, elements are placed using the PDF coordinates’ system (i.e point 0,0 is positioned at the bottom-left). As you can see, the Y axis is flipped.

These properties will customize an edition element, no matter the type. However, the API also provides properties related specifically to text. See the following:

Text properties

  • text assigns a text string to the element.
  • text_align sets the text alignment. Can be right, left, center, justify.
  • font_family sets the text font type.
  • font_color sets a color for text. Accepts both string and hex value like #000000.
  • font_size sets a size in points for text.
  • font_style sets font style.
  • letter_spacing sets the space between characters in text. By default it is 0. Negative values are accepted until -20.