Document Processing
The DocumentProcessing Web API is the part of DS Server that works on documents without a user interface. A backend in any language sends it a document or a template over HTTP and gets a converted, merged, combined or analyzed document back: PDF from DOCX, invoices from a template and JSON data, page thumbnails, barcodes or the form fields of a PDF. Each task has its own guide below, with a curl request and the same call in C#.
How a Request Looks
Every endpoint sits below /documentprocessing/ of your DS Server's service URL. The service URL is http://localhost:5000 when DS Server runs on its own on the default port, and it contains the path of the IIS site behind IIS, such as https://yourdomain.com/DocumentServices. A request to convert a document looks like this:
curl POST "http://localhost:5000/documentprocessing/document/convert?returnFormat=PDF" \
"Authorization: Bearer <access_token>" \
"Content-Type: application/json" \
@document.json
The parts of every request:
- The access token in an
Authorization: Bearerheader. A backend requests it from DS Server with the client ID and secret of a security profile, as Authentication shows. - Documents as Base64. The body is JSON with the content type
application/json. A document is a Base64 string: a single document is the body itself, a JSON string, as for convert, info, thumbnails and the PDF readers, and endpoints that take more, such as merge, append and pdf/create, take a JSON object with properties such astemplate,documentsordocumentData. - Options as query parameters, such as
returnFormat=PDForappend=false. - Results as Base64. A created document comes back as a Base64 string in a JSON string, and several documents or images as a JSON array of such strings. The endpoints that read documents, such as info or pdf/acroforms/fields, return JSON with the information.
The .NET package TXTextControl.DocumentServices.DocumentProcessing wraps the same requests in the DocumentProcessing class, which takes and returns byte arrays and requests the access token itself. ASP.NET Core lists its methods.
The server must be licensed: until it is registered, every endpoint answers 400 with the message "DS Server is not registered.". Licensing shows how to register it, and Errors and Status Codes explains the other answers.
Find the Right Page
| If you want to | Read |
|---|---|
| Get an access token and send it with your requests | Authentication |
| Convert DOCX, RTF, HTML or PDF into another format | Converting Documents |
| Create documents from a template and JSON data | Merging Templates |
| Combine several documents into one | Appending Documents |
| Replace text placeholders in a document | Find and Replace |
| List the merge fields, merge blocks and properties of a document | Document Information |
| Render the pages of a document as images | Thumbnails |
| Create PDF or PDF/A with a signature, attachments or permissions, or read the metadata and attachments of a PDF | PDF Documents |
| Read the form fields of a PDF form | PDF Form Fields |
| Create barcode and QR code images | Barcodes |
| Find out why a request is refused | Errors and Status Codes |
Where to Start
- Authentication: create a security profile and request a token.
- Converting Documents: send a first request and decode the result.
- The page of the task you need, from the table above.
The endpoints, with every parameter and response, are listed in the DocumentProcessing reference. A first ASP.NET Core application with the .NET package is built in Getting Started.
Pages in This Section
- Authentication: request an access token, send it and renew it.
- Converting Documents: convert a document to PDF, DOCX, HTML and other formats.
- Merging Templates: merge a template with JSON data into one or many documents.
- Appending Documents: combine documents with a divider between them.
- Find and Replace: replace text in a document.
- Document Information: read the properties, merge fields and merge blocks of a document.
- Thumbnails: create images of document pages.
- PDF Documents: create and read PDF documents.
- PDF Form Fields: read the AcroForm fields of a PDF.
- Barcodes: create barcode images and check barcode text.
- Errors and Status Codes: the answers of the Web API and what they mean.