Skip to main content

How to wrap text so it doesn't overflow

Set a text annotation’s position, box dimensions and font size to keep added text within the available area.

When adding text to an existing PDF, use x and y for its position and width and height for the text box. Set alignment and a suitable font size. A fixed-size box does not guarantee that an unlimited amount of text will fit.

Direct API example

Send this JSON body to POST https://api.pdf.co/v1/pdf/edit/add with your API key in the x-api-key header:

{
  "url": "https://pdfco-test-files.s3.us-west-2.amazonaws.com/pdf-edit/sample.pdf",
  "annotations": [
    {
      "text": "This sample paragraph wraps within the specified text box. Increase its height or reduce the font size if longer content does not fit.",
      "x": 20,
      "y": 20,
      "width": 300,
      "height": 100,
      "size": 12,
      "fontName": "Arial",
      "pages": "0",
      "alignment": "left"
    }
  ]
}

Use PDF Inspector to measure placement. Page indexes start at 0. Increase the box dimensions or reduce the font size if content is clipped, while keeping the box inside the PDF page.

Zapier: PDF Filler

Use the native PDF Filler action’s Text Annotations field. Some older actions label this field Text Objects. Its compact format is:

x;y;pages;text;fontSize;fontName;fontColor;link;transparent;width;height;alignment

For example, this creates a 133-by-100 text box on the first page:

20;20;0;Your text here;12;Arial;000000;;true;133;100;left

Use the fields available in your selected action; the separate Add Text action does not expose every box setting. For longer text, test with a representative value.

Make

In Add Text and Images to a PDF, add an item under Text Annotations. Set X, Y, Text, Width, Height, Font Size and Alignment, then run the module and inspect the result.

Related documentation

Did this answer your question?