REST Client Samples

Sample Workflows

Create and Upload

Create a new folder
PUT http://{host}:{port}/qoppapdf/v1/documents/mydir
Upload a PDF via PUT
PUT http://{host}:{port}/qoppapdf/v1/documents/mydir/mydoc.pdf
Content-Type: application/pdf
(PDF file in message body)
Upload a PDF via POST
POST http://{host}:{port}/qoppapdf/v1/documents/mydir?namingMode=1
Content-Type: application/pdf
(file as attachment)
Upload an image as a PDF
PUT http://{host}:{port}/qoppapdf/v1/documents/mydir/jpeg.pdf
Content-Type: image/jpeg
(image file in message body)
Upload a Word document as a PDF
PUT http://{host}:{port}/qoppapdf/v1/documents/mydir/word.pdf
Content-Type: application/msword
(Word file in message body)
Upload a text document as a PDF
PUT http://{host}:{port}/qoppapdf/v1/documents/mydir/text.pdf
Content-Type: text/plain
(text file in message body)
Get all the children in a folder
GET http://{host}:{port}/qoppapdf/v1/documents/mydir?details=true

Document Assembly

Append two PDFs that are both already uploaded
POST http://{host}:{port}/qoppapdf/v1/documents/mydir/mydoc.pdf/pages
Content-Type: multipart/form-data
(sample JSON as "pageAction" part)
{
	"InsertUploadedPagesAction":
	{
		"appendFilePath":"mydir/subdir/myotherdoc.pdf",
		"appendPassword":"password",
		"pageRange":1
	}
}
Upload and append a PDF to an existing PDF
POST http://{host}:{port}/qoppapdf/v1/documents/mydir/mydoc.pdf/pages
Content-Type: multipart/form-data
(PDF file as "file" part)
(sample JSON as "pageAction" part)
{
	"InsertAttachedPagesAction": {
		"pageIndex":2,
		"pageRange":"2-4"
	}
}
Append an image to an existing PDF
POST http://{host}:{port}/qoppapdf/v1/documents/mydir/mydoc.pdf/pages
Content-Type: multipart/form-data
(image file as "file" part)
(sample JSON as "pageAction" part)
{
	"InsertAttachedPagesAction": {
		"dpi":300
	}
}
Delete a page
DELETE http://{host}:{port}/qoppapdf/v1/documents/mydir/mydoc.pdf/pages/0
Add a new page to an existing PDF
POST http://{host}:{port}/qoppapdf/v1/documents/mydir/mydoc.pdf/pages
Content-Type: multipart/form-data
(sample JSON as "pageAction" part)
{
	"NewPageAction": {
		"width": 612,
		"height":792
	}
}

Optimize

Create a new profile
PUT http://{host}:{port}/qoppapdf/v1/optimize-profiles/myprofile
Content-Type: application/json
(sample JSON in message body)
{
  "discardAnnotations" : true,
  "discardUnusedResources" : true,
  "mergeDuplicateFonts" : true,
  "mergeDuplicateImages" : true,
  "compressObjectsIntoStreams" : true,
  "colorImageHandler": {
    "colorSpace": 1,
    "compression": 1,
    "dpi": 150,
    "jpegQuality": 0.8
  },
  "grayImageHandler": {
    "colorSpace": 1,
    "compression": 1,
    "dpi": 150,
    "jpegQuality": 0.7
  },
  "bwImageHandler": {
    "colorSpace": 2,
    "compression": 2,
    "dpi": 150,
    "jpegQuality": 0.6
  }
}
Optimize a PDF
POST http://{host}:{port}/qoppapdf/v1/documents/mydir/mydoc.pdf
Content-Type: application/json
(sample JSON in message body)
{
  "OptimizeAction": {
    "profileName": "myprofile",
    "savePath": "optimized/mydoc.pdf"
  }
}

Linearize

Linearize a PDF
POST http://{host}:{port}/qoppapdf/v1/documents/mydir/mydoc.pdf
Content-Type: application/json
(sample JSON in message body)
{
  "LinearizeAction": {
    "savePath": "linearized/mydoc.pdf"
  }
}

PDF/A Conversion and Verification

Convert a PDF to PDF/A
POST http://{host}:{port}/qoppapdf/v1/documents/mydir/mydoc.pdf
Content-Type: application/json
(sample JSON in message body)
{
  "PDFAConvertAction":{
    "profile": "pdfa1b",      
    "unsupportedAnnots": 1,
	"embeddedFiles": 1,
	"transparency": 1,
	"appendReport": true,
	"addAnnots": true,
    "savePath": "mydoc_converted.pdf"
  }
}
PDF/A Verification
GET http://{host}:{port}/qoppapdf/v1/documents/mydir/mydoc.pdf/preflight-results?profile=pdfa1b

OCR

OCR a PDF
POST http://{host}:{port}/qoppapdf/v1/documents/mydir/mydoc.pdf/pages
Content-Type: multipart/form-data
(sample JSON as "pageAction" part)
{
	"OCRAction": {
		"language":"eng",
		"dpi":300
	}
}
Extract the text from a PDF
GET http://{host}:{port}/qoppapdf/v1/documents/mydir/mydoc.pdf/pages/0/text

Watermarks, Headers, and Footers

Stamp the document with text
POST http://{host}:{port}/qoppapdf/v1/documents/mydir/mydoc.pdf/pages
Content-Type: multipart/form-data
(sample JSON as "pageAction" part)
{
	"TextStampAction":{
		"rotation":15,
		"transparency":50,
		"x":100,
		"y":100,
		"text":"HelloWorld",
		"color":0,
		"fontSize": 32,
		"fontName": "Courier",
		"fontStyle": "Plain",
		"pageIndex":1
	}
}
Stamp the document with an image
POST http://{host}:{port}/qoppapdf/v1/documents/mydir/mydoc.pdf/pages
Content-Type: multipart/form-data
(image file as "file" part)
(sample JSON as "pageAction" part)
{
	"ImageStampAction":{
		"rotation":15,
		"x":100,
		"y":100,
		"pageIndex":1
	}
}

Add Text and Images

Add text to the document
POST http://{host}:{port}/qoppapdf/v1/documents/mydir/mydoc.pdf/pages
Content-Type: multipart/form-data
(sample JSON as "pageAction" part)
{
	"AddTextAction":{
		"pageIndex":1,
		"text":"Hello World",
		"color":"#000000",
		"fontSize":12,
		"fontName":"Helvetica",
		"fontStyle":"Plain",
		"transparency":0,
		"x":0,
		"y":0,
		"horzAlign":0
	}
}
Add an image to the document
POST http://{host}:{port}/qoppapdf/v1/documents/mydir/mydoc.pdf/pages
Content-Type: multipart/form-data
(image file as "file" part)
(sample JSON as "pageAction" part)
{
	"AddImageAction":{
		"pageIndex":1,
		"transparency":0,
		"x":0,
		"y":0,
		"width":100,
		"height":100,
		"keepAspectRatio":1
	}
}

Encryption and Permissions

Get the current permissions
GET http://{host}:{port}/qoppapdf/v1/documents/mydir/mydoc.pdf/permissions
Clear the usage rights
DELETE http://{host}:{port}/qoppapdf/v1/documents/mydir/mydoc.pdf/permissions/usage-rights
Clear the password permissions
DELETE http://{host}:{port}/qoppapdf/v1/documents/mydir/mydoc.pdf/permissions/password-permissions
Set password permissions
PUT http://{host}:{port}/qoppapdf/v1/documents/mydir/mydoc.pdf/permissions/password-permissions
Content-Type: application/json
(sample JSON in message body)
{
	"encryptType":1,
	"openPassword":"openPass",
	"permissionsPassword":"permsPass",
	"changeDocumentAllowed":false,
	"assembleDocumentAllowed":false
}

Sign

Add a signature field to the PDF
PUT http://{host}:{port}/qoppapdf/v1/documents/mydir/mydoc.pdf/fields/signature-fields/myfield
Content-Type: application/json
(sample JSON in message body)
{
    "widget":[
        {
            "pageIndex":0,
            "rectangle":
            {
                "x":100,
                "y":100,
                "width":200,
                "height":50
            }
        }
    ]
}
Get all signature fields the PDF
GET http://{host}:{port}/qoppapdf/v1/documents/mydir/mydoc.pdf/fields/signature-fields
Sign the PDF
POST http://{host}:{port}/qoppapdf/v1/documents/mydir/mydoc.pdf/fields/signature-fields/myfield/signature
Content-Type: multipart/form-data
(pfx or p12 file as "file" part)
(sample JSON as "digitalID" part)
{
  "keystorePassword":"password", 
  "keyAlias":"alias", 
  "keyPassword":"password", 
  "certifyingSignature":true, 
  "certifyingPermissions":3,
  "signLocation" : "US",
  "signReason" : "I approve this document",
  "signContactInformation" : "me@example.com"
}
Clear signature
DELETE http://{host}:{port}/qoppapdf/v1/documents/mydir/mydoc.pdf/fields/signature-fields/mySigField

Download and Export to Images

Download the PDF
GET http://{host}:{port}/qoppapdf/v1/documents/mydir/mydoc.pdf/content
Accept: application/pdf
Download the PDF as html/svg
GET http://{host}:{port}/qoppapdf/v1/documents/mydir/mydoc.pdf/content
Accept: text/html
Download the PDF as a tiff
GET http://{host}:{port}/qoppapdf/v1/documents/mydir/mydoc.pdf/content?dpi=300
Accept: image/tiff
Download a single page as an image
GET http://{host}:{port}/qoppapdf/v1/documents/mydir/mydoc.pdf/pages/0/content?dpi=300&quality=.5
Accept: image/jpeg

Form Fields

Get form fields
GET http://{host}:{port}/qoppapdf/v1/documents/mydir/mydoc.pdf/fields
Export form fields
GET http://{host}:{port}/qoppapdf/v1/documents/mydir/mydoc.pdf/fields/content?exportEmptyFields=true
Accept: application/vnd.adobe.xfdf
Import form fields
POST http://{host}:{port}/qoppapdf/v1/documents/mydir/otherdoc.pdf/fields/content
Content-Type: application/vnd.adobe.xfdf
(xfdf or fdf file in message body)
Flatten form fields
POST http://{host}:{port}/qoppapdf/v1/documents/mydir/mydoc.pdf
Content-Type: application/json
(sample JSON in message body)
{
  "FlattenFieldsAction": {
    "paintButtons": true,
    "paintOnlyImageButtons": true,
    "paintNonPrintableFields": true,
    "savePath": "flatFields/mydoc.pdf"
  }
}

Annotations

Get annotations
GET http://{host}:{port}/qoppapdf/v1/documents/mydir/mydoc.pdf/annotations?pageIndex=0
Export annotations
GET http://{host}:{port}/qoppapdf/v1/documents/mydir/mydoc.pdf/annotations/content
Accept: application/vnd.adobe.xfdf
Import annotations
POST http://{host}:{port}/qoppapdf/v1/documents/mydir/otherdoc.pdf/annotations/content
Content-Type: application/vnd.adobe.xfdf
(xfdf or fdf file in message body)
Flatten annotations
POST http://{host}:{port}/qoppapdf/v1/documents/mydir/mydoc.pdf
Content-Type: application/json
(sample JSON in message body)
{
"FlattenAnnotationsAction": {
"paintNonPrintableAnnots": true,
"savePath": "flatAnnots/mydoc.pdf"
}
}

Attachments

Get all embedded files
GET http://{host}:{port}/qoppapdf/v1/documents/mydir/mydoc.pdf/attachments
Download an embedded file
GET http://{host}:{port}/qoppapdf/v1/documents/mydir/mydoc.pdf/attachments/attachmentName.png/content?attachment=true
Add an embedded file
POST http://{host}:{port}/qoppapdf/v1/documents/mydir/mydoc.pdf/attachments
Content-Type: multipart/form-data
(Attachment file as "file" part)
Get all file attachment annotations
GET http://{host}:{port}/qoppapdf/v1/documents/mydir/mydoc.pdf/annotations?subtype=FileAttachment
Download an embedded file from a file attachment annotation
GET http://{host}:{port}/qoppapdf/v1/documents/mydir/mydoc.pdf/annotations/annotName/attachment/content?attachment=true
Add a file attachment annotation
POST http://{host}:{port}/qoppapdf/v1/documents/mydir/mydoc.pdf/annotations
Content-Type: multipart/form-data
(Attachment file as "file" part)
(sample JSON as "annotation" part)
{
    "subtype": "FileAttachment",
	"rectangle": {
		"x": 50,
		"y": 50,
		"width": 25,
		"height": 25
	},
	"pageIndex": 0
}

Create and Apply Redactions

Create Redactions
POST http://{host}:{port}/qoppapdf/v1/documents/mydir/mydoc.pdf/annotations/redaction
Content-Type: application/json
(sample JSON in message body)
{
  "searchText":"text to redact"
}
Apply Redactions
POST http://{host}:{port}/qoppapdf/v1/documents/mydir/mydoc.pdf
Content-Type: application/json
(sample JSON in message body)
{
  "ApplyRedactionsAction":{
    "savePath":"redacted/mydoc.pdf"
  }
}

Convert Word to PDF

Upload Word document
PUT http://{host}:{port}/qoppapdf/v1/documents/mydir/converted.pdf
Content-Type: application/vnd.openxmlformats-officedocument.wordprocessingml.document
(Word file as message body)
Download PDF
GET http://{host}:{port}/qoppapdf/v1/documents/mydir/converted.pdf/content

Convert Excel to PDF

Upload Excel document
PUT http://{host}:{port}/qoppapdf/v1/documents/mydir/converted.pdf
Content-Type: application/vnd.openxmlformats-officedocument.spreadsheetml.sheet
(Excel file as message body)
Download PDF
GET http://{host}:{port}/qoppapdf/v1/documents/mydir/converted.pdf/content

Convert PowerPoint to PDF

Upload PowerPoint document
PUT http://{host}:{port}/qoppapdf/v1/documents/mydir/converted.pdf
    Content-Type: application/vnd.openxmlformats-officedocument.presentationml.presentation
    (PowerPoint file as message body)
Download PDF
GET http://{host}:{port}/qoppapdf/v1/documents/mydir/converted.pdf/content

Convert Image to PDF

Upload Image file
PUT http://{host}:{port}/qoppapdf/v1/documents/mydir/converted.pdf
Content-Type: image/jpeg
(Image file as message body)
Download PDF
GET http://{host}:{port}/qoppapdf/v1/documents/mydir/converted.pdf/content

Resize Pages

Resize page
POST http://{host}:{port}/qoppapdf/v1/documents/mydir/mydoc.pdf/pages
Content-Type: multipart/form-data
(sample JSON as "pageAction" part)
{
	"ResizePageAction":{
		"pageIndex":1,
		"newPageWidth":500,
		"newPageHeight":500,
		"scaleContent":100
	}
}

Delete a Page

Delete page
DELETE http://{host}:{port}/qoppapdf/v1/documents/mydir/mydoc.pdf/pages/0

Compare Documents

Generate a comparison PDF document
POST http://{host}:{port}/qoppapdf/v1/documents/mydir/mydoc.pdf
(sample JSON in message body)
{
    "CompareAction":{
        "savePath": "compare/comparisonOutput.pdf",
        "namingMode": 1,
        "compareFilePath": "samples/compareTo.pdf",
        "currentOptions":{
            "layerName":"mydoc",
            "color":"#FF0000"
        },
        "compareOptions":{
            "layerName":"compareTo",
            "color":"#00C400"
        }
    }
}