0CodeKit icon

0CodeKit

A toolbox of no-code utilities

Actions132

PDF → Draw Text on PDF

AI-generated

Overview

The "Draw Text on PDF" operation allows users to add custom text onto existing PDF documents. This is useful for scenarios such as watermarking, annotating, labeling, or adding signatures and notes directly onto PDF pages. For example, a user might want to stamp "Confidential" across certain pages of a report or add a date and author name at the bottom of each page.

This operation supports specifying the source PDF either by a public URL or by providing the PDF content as a Base64-encoded buffer. Users can customize the font, size, color, position, rotation, and alignment of the text, as well as select which pages to modify. The resulting PDF can be returned as a downloadable file or as a URL.

Properties

Name Meaning
PDF URL Public URL of the PDF file to modify.
PDF Buffer Base64-encoded PDF data. Can be specified instead of URL to provide the PDF content directly.
Text The text string to draw on the PDF. (Required)
Font The font used for the text. Options: Courier, Helvetica, Times Roman.
Font Size The font size in points (numeric). Default is 32.
Font Color The font color specified as a six-digit hexadecimal RGB code (e.g., "000000" for black, "FFFF00" for yellow).
Anchor Position The part of the page where the text should be anchored. Options: Bottom Center, Bottom Left, Bottom Right, Center, Center Left, Center Right, Top Center, Top Left, Top Right. Default is Center.
Alignment The part of the text that aligns with the anchor position. Same options as Anchor Position. Default is Center.
X Offset Horizontal offset in points relative to the anchor position. Positive values move right; negative values move left.
Y Offset Vertical offset in points relative to the anchor position. Positive values move up; negative values move down.
Rotation Counter-clockwise rotation of the text in degrees. Default is 0 (no rotation).
Pages Specifies which pages to draw the text on. Supports ranges and special syntax where "1" is first page, "^1" is last page, e.g., "1,3-5,^3-^1". If empty, defaults to all pages.
File Name The desired file name for the resulting PDF document.
Return as URL Boolean flag indicating whether to return the modified PDF as a downloadable URL instead of raw binary data. Default is false.

Output

The node outputs the modified PDF document. Depending on the "Return as URL" property:

  • If Return as URL is false, the output contains the PDF data typically encoded in Base64 format within the JSON output under a field representing the file content.
  • If Return as URL is true, the output provides a URL from which the modified PDF can be downloaded.

The output JSON structure includes metadata about the file and the actual PDF content or its download link.

Dependencies

  • Requires an API key credential for authenticating requests to the external PDF processing service at https://prod.0codekit.com.
  • The node sends a POST request to the /pdf/draw/text endpoint of this service with the provided parameters.
  • No additional local dependencies are required; all PDF manipulation is handled remotely.

Troubleshooting

  • Common issues:

    • Providing both PDF URL and PDF Buffer empty or invalid will cause errors because no input PDF is available.
    • Incorrect page range syntax in the "Pages" property may result in no pages being modified or errors.
    • Using unsupported font names or invalid hex color codes could lead to default styling or errors.
    • Large PDFs or complex operations might cause timeouts depending on the external service limits.
  • Error messages:

    • "Invalid PDF input" — Check that either a valid URL or a Base64-encoded buffer is provided.
    • "Page range out of bounds" — Verify the page numbers and ranges specified exist in the PDF.
    • "Authentication failed" — Ensure the API key credential is correctly configured and valid.
    • "Failed to process PDF" — Could indicate service-side issues or malformed parameters; retry or check inputs.

Links and References

  • PDF Specification — For understanding PDF structure.
  • Hex Color Codes — Reference for specifying font colors.
  • Font Families — General info on fonts (note: only specific fonts supported here).
  • External API documentation would be available via the service provider but is not included here.

Discussion