Documentation

Learn how to use PromptPDF effectively

PDF Download API

The PDF Download API endpoint allows you to convert document content to PDF format programmatically.

Endpoint

POST https://api.promptpdf.com/v1/pdf

Authentication

This endpoint requires authentication. See the Authentication page for details.

Request Parameters

The request body should be a JSON object with the following parameters:

ParameterTypeRequiredDescription
contentstringYesThe document content to convert to PDF
titlestringNoThe document title (default: "Document")
filenamestringNoThe filename for the PDF (default: "document.pdf")
optionsobjectNoAdditional PDF generation options

PDF Options

The options parameter can include the following properties:

OptionTypeDescription
pageSizestringPage size: "a4", "letter", "legal" (default: "a4")
marginsobjectPage margins in points: {top, right, bottom, left}
fontstringFont: "times", "helvetica", "courier" (default: "times")
fontSizenumberFont size in points (default: 12)
lineHeightnumberLine height multiplier (default: 1.5)
includePageNumbersbooleanWhether to include page numbers (default: true)

Example Request

// Using fetch API
const response = await fetch('https://api.promptpdf.com/v1/pdf', {
  method: 'POST',
  headers: {
    'Content-Type': 'application/json',
    'Authorization': 'Bearer YOUR_API_KEY'
  },
  body: JSON.stringify({
    content: "123 Maple Street\nAnytown, CA 91234\n\nMarch 19, 2025\n\nCustomer Service Department\nTech Solutions Inc.\n456 Oak Avenue\nAnytown, CA 91235\n\n**Subject: Formal Complaint Regarding Defective Laptop**\n\nDear Customer Service Manager:\n\nI am writing to file a formal complaint regarding a defective laptop I purchased from your store on March 10, 2025....",
    title: "Complaint Letter",
    filename: "complaint-letter.pdf",
    options: {
      pageSize: "letter",
      margins: { top: 72, right: 72, bottom: 72, left: 72 },
      font: "times",
      fontSize: 12,
      lineHeight: 1.5,
      includePageNumbers: true
    }
  })
});

// The response is a binary PDF file
const pdfBlob = await response.blob();
const url = URL.createObjectURL(pdfBlob);

// Create a download link
const a = document.createElement('a');
a.href = url;
a.download = 'complaint-letter.pdf';
document.body.appendChild(a);
a.click();
document.body.removeChild(a);
URL.revokeObjectURL(url);

Response

The response is a binary PDF file with the following headers:

Content-Type: application/pdf
Content-Disposition: attachment; filename="complaint-letter.pdf"

Error Responses

If an error occurs, the API will return a JSON response with error details:

{
  "success": false,
  "error": {
    "code": "pdf_generation_failed",
    "message": "Failed to generate PDF",
    "details": "Invalid content format"
  }
}

Alternative PDF Generation Method

If the primary PDF generation method fails, you can try the alternative method:

POST https://api.promptpdf.com/v1/pdf-alt

This endpoint accepts the same parameters as the primary method but uses a different PDF generation engine.

PDF Generation Tips

  • Use **text** for bold text in your content
  • Use *text* for italic text in your content
  • Use - item for bullet points
  • Use \n for line breaks
  • Use \n\n for paragraph breaks
  • Keep document size reasonable for faster processing
  • Avoid complex formatting for better compatibility

Limitations

  • Maximum content size: 100,000 characters
  • Maximum processing time: 30 seconds
  • Limited support for complex formatting
  • No support for embedded images (coming soon)
  • No support for custom fonts (limited to standard fonts)

Next Steps

After downloading a PDF, you may want to:

  • Store the PDF in your system
  • Send the PDF via email
  • Display the PDF in your application