Skip to content

Usage Examples

Iker Larrea edited this page Dec 29, 2025 · 1 revision

Usage Examples

Basic Document Conversion

# Convert DOCX to PDF
curl -X POST http://localhost:8080/convert \
  -F "file=@document.docx" \
  -o output.pdf

# Convert spreadsheet
curl -X POST http://localhost:8080/convert \
  -F "file=@spreadsheet.xlsx" \
  -o output.pdf

Page Selection

# Convert specific page range (pages 3-10)
curl -X POST http://localhost:8080/convert \
  -F "file=@document.docx" \
  -F "pageRange=3-10" \
  -o excerpt.pdf

# Skip first page (useful for removing cover)
curl -X POST http://localhost:8080/convert \
  -F "file=@document.docx" \
  -F "pageRange=2-" \
  -o no-cover.pdf

# Multiple page ranges
curl -X POST http://localhost:8080/convert \
  -F "file=@document.docx" \
  -F "pageRange=1,3,5-7,10-" \
  -o selected-pages.pdf

Watermarks

Simple text watermark:

curl -X POST http://localhost:8080/convert \
  -F "file=@document.docx" \
  -F "watermark=DRAFT" \
  -F "watermarkColor=16711680" \
  -o draft.pdf

Tiled watermark (covers entire page):

curl -X POST http://localhost:8080/convert \
  -F "file=@document.docx" \
  -F "tiledWatermark=CONFIDENTIAL" \
  -F "watermarkColor=8421504" \
  -F "watermarkRotateAngle=45" \
  -o confidential.pdf

Custom watermark styling:

curl -X POST http://localhost:8080/convert \
  -F "file=@document.docx" \
  -F "watermark=INTERNAL USE ONLY" \
  -F "watermarkColor=16711680" \
  -F "watermarkFontHeight=72" \
  -F "watermarkFontName=Arial" \
  -F "watermarkRotateAngle=45" \
  -o watermarked.pdf

Watermark Colors (RGB as integer):

  • Red: 16711680 - (255 * 65536) + (0 * 256) + 0
  • Green: 65280 - (0 * 65536) + (255 * 256) + 0
  • Blue: 255 - (0 * 65536) + (0 * 256) + 255
  • Gray: 8421504 - (128 * 65536) + (128 * 256) + 128

Formula: (R * 65536) + (G * 256) + B

Security & Encryption

Password protect PDF:

curl -X POST http://localhost:8080/convert \
  -F "file=@sensitive.docx" \
  -F "encryptFile=true" \
  -F "documentOpenPassword=secret123" \
  -o encrypted.pdf

Restrict permissions:

curl -X POST http://localhost:8080/convert \
  -F "file=@document.docx" \
  -F "restrictPermissions=true" \
  -F "permissionPassword=admin123" \
  -F "printing=1" \
  -F "changes=2" \
  -F "enableCopyingOfContent=false" \
  -o restricted.pdf

Permission levels:

  • printing: 0=none, 1=low-res, 2=high-res
  • changes: 0=none, 1=insert/delete pages, 2=fill forms, 3=comments, 4=all except extraction

PDF/A Archival Format

PDF/A-2b (recommended for archival):

curl -X POST http://localhost:8080/convert \
  -F "file=@archive.docx" \
  -F "selectPdfVersion=2" \
  -F "useTaggedPdf=true" \
  -o archive-pdfa.pdf

PDF/A-3b (allows attachments):

curl -X POST http://localhost:8080/convert \
  -F "file=@document.docx" \
  -F "selectPdfVersion=3" \
  -o pdfa3.pdf

PDF Versions:

  • 0 - PDF 1.7 (default, most compatible)
  • 1 - PDF/A-1b (ISO 19005-1, long-term archival)
  • 2 - PDF/A-2b (ISO 19005-2, improved archival)
  • 3 - PDF/A-3b (ISO 19005-3, allows embedded files)
  • 15 - PDF 1.5
  • 16 - PDF 1.6
  • 17 - PDF 1.7

Accessibility (PDF/UA)

Create accessible PDF:

curl -X POST http://localhost:8080/convert \
  -F "file=@document.docx" \
  -F "pdfUaCompliance=true" \
  -F "useTaggedPdf=true" \
  -F "exportBookmarks=true" \
  -o accessible.pdf

Image Quality & Compression

High-quality output (lossless):

curl -X POST http://localhost:8080/convert \
  -F "file=@document.docx" \
  -F "useLosslessCompression=true" \
  -o high-quality.pdf

Balanced quality (JPEG compression):

curl -X POST http://localhost:8080/convert \
  -F "file=@document.docx" \
  -F "quality=85" \
  -F "reduceImageResolution=true" \
  -F "maxImageResolution=300" \
  -o optimized.pdf

Web-optimized (smaller file size):

curl -X POST http://localhost:8080/convert \
  -F "file=@document.docx" \
  -F "quality=70" \
  -F "reduceImageResolution=true" \
  -F "maxImageResolution=150" \
  -o web-optimized.pdf

Spreadsheet-Specific Options

One sheet per page:

curl -X POST http://localhost:8080/convert \
  -F "file=@spreadsheet.xlsx" \
  -F "singlePageSheets=true" \
  -o spreadsheet.pdf

Presentation Options

Export notes pages:

curl -X POST http://localhost:8080/convert \
  -F "file=@presentation.pptx" \
  -F "exportNotesPages=true" \
  -o presentation-with-notes.pdf

Export only notes (no slides):

curl -X POST http://localhost:8080/convert \
  -F "file=@presentation.pptx" \
  -F "exportNotesPages=true" \
  -F "exportOnlyNotesPages=true" \
  -o notes-only.pdf

Include hidden slides:

curl -X POST http://localhost:8080/convert \
  -F "file=@presentation.pptx" \
  -F "exportHiddenSlides=true" \
  -o all-slides.pdf

Forms & Interactive Elements

Export form fields:

curl -X POST http://localhost:8080/convert \
  -F "file=@form.docx" \
  -F "exportFormFields=true" \
  -F "formsType=1" \
  -o interactive-form.pdf

Form types:

  • 0 - FDF format
  • 1 - PDF format
  • 2 - HTML format
  • 3 - XML format

Combined Options Example

Professional document (watermark + encryption + PDF/A):

curl -X POST http://localhost:8080/convert \
  -F "file=@document.docx" \
  -F "watermark=CONFIDENTIAL" \
  -F "watermarkColor=16711680" \
  -F "encryptFile=true" \
  -F "documentOpenPassword=secret123" \
  -F "selectPdfVersion=2" \
  -F "useTaggedPdf=true" \
  -F "exportBookmarks=true" \
  -F "quality=90" \
  -o professional.pdf