Skip to content

PDF Write String API — Add Text to Existing PDFs

Add text to existing PDF documents with customizable styling and positioning using PdfBroker.io. Useful for templates like diplomas, certificates, or any document where user-specific text needs to be added.

Endpoint

POST https://api.pdfbroker.io/api/pdf/pdfwritestring

Request Parameters

Parameter Type Description
pdfFileBase64String string Base64-encoded PDF file content
fontFileBase64String string Optional Base64-encoded TrueType font file
options object Configuration for text placement and styling

Text Options

Option Type Default Description
text string Required Content to write
textColor object Black (0,0,0) RGB values as object with r, g, b properties
font object Name, size, and style (0=Normal, 1=Bold, 2=Italic, 3=Bold+Italic)
pageNumber integer 1 Target page number
xPosition float Horizontal offset from xOrigin
yPosition float Vertical offset from yOrigin
xOrigin integer 0 Reference point: 0=Left, 1=Center, 2=Right
yOrigin integer 0 Reference point: 0=Top, 1=Center, 2=Bottom

Example Request

{
    "pdfFileBase64String": "JVBERi0xLjcNCiW1tbW1...",
    "options": {
        "text": "John Doe",
        "textColor": { "r": 0, "g": 0, "b": 0 },
        "font": { "name": "Arial", "size": 24, "style": 1 },
        "pageNumber": 1,
        "xPosition": 0,
        "yPosition": 0,
        "xOrigin": 1,
        "yOrigin": 1
    }
}

Note

See the Swagger documentation for the complete API specification. A live demo is also available.