Skip to main content

Request

For the interaction with the document conversion service the POST requests are used. The request parameters are entered in JSON format in the request body. The requests are sent to the https://documentserver/converter address where documentserver is the name of the server with the ONLYOFFICE Docs installed.

tip

Starting from version 8.1, it is recommended to add the shardkey parameter to the URL QueryString with the key value in it. For example, ?shardkey=Khirz6zTPdfd7. This allows you to load balance requests.

note

Please note that prior to version 5.5, the https://documentserver/ConvertService.ashx address was used to send requests.

note

In ONLYOFFICE Docs prior to version 4.2 the GET request with the parameters in the QueryString were used.

Request parameters

ParameterTypePresenceDescription
asyncbooleanoptionalDefines the conversion request type: asynchronous or not. Supported values: true, false. When the asynchronous request type is used, the response is formed instantly. In this case to get the result it is necessary to send requests without parameter change until the conversion is finished. The default value is false.
codePageintegeroptionalDefines the file encoding when converting from csv or txt format. Main supported values: 932 - Japanese (Shift-JIS), 950 - Chinese Traditional (Big5), 1250 - Central European (Windows), 1251 - Cyrillic (Windows), 65001 - Unicode (UTF-8). You can find all the supported values in this file.
delimiterintegeroptionalDefines the delimiter characters for separating values when converting from csv format. Supported values: 0 - no delimiter, 1 - tab, 2 - semicolon, 3 - colon, 4 - comma, 5 - space.
documentLayoutobjectoptionalDefines the document layout which specifies parameters for printing forms as pdf documents or images.
documentLayout.drawPlaceHoldersbooleanoptionalDefines if placeholders will be drawn or not.
documentLayout.drawFormHighlightbooleanoptionalDefines if forms will be highlighted or not.
documentLayout.isPrintbooleanoptionalDefines if the print mode is turned on or off. This parameter is used only for converting docx into pdf. If this parameter is equal to true, the drawPlaceHolders and drawFormHighlight flags are used as described above. If this parameter is false, the drawFormHighlight flag does not work and the drawPlaceHolders parameter allows saving the forms in the pdf format. The default value is false.
documentRendererobjectoptionalDefines the document renderer when converting from pdf, xps, oxps.
documentRenderer.textAssociationstringoptionalDefines the rendering mode: blockChar - all text is converted by single characters, blockLine - all text is converted by separate lines, plainLine - all text is converted as plain text with each line as a separate paragraph, plainParagraph - all text is converted as plain text with lines combined into paragraphs. The default value is plainLine.
filetypestringrequiredDefines the type of the document file to be converted.
keystringrequiredDefines the document identifier used to unambiguously identify the document file.
outputtypestringrequiredDefines the resulting converted document type. Starting from version 7.0, file formats can be specified instead of extensions: ooxml (converts to docx, docm, xlsx, xlsm, pptx or pptm), odf (converts to odt, ods or odp).
passwordstringoptionalDefines the password for the document file if it is protected with a password. After conversion the file has no password.
pdfobjectoptionalDefines settings for converting document files to pdf.
pdf.formbooleanoptionalDefines whether the document will be converted to the pdf form (true) or to a regular pdf file (false). If this parameter is omitted, the document contents will not be changed.
regionstringoptionalDefines the default display format for currency and date and time when converting from Spreadsheet format to pdf. Is set using the four letter (en-US, fr-FR, etc.) language codes. The default value is en-US.
spreadsheetLayoutobjectoptionalDefines settings for converting the spreadsheet to pdf.
spreadsheetLayout.fitToHeightintegeroptionalSets the height of the converted area, measured in the number of pages. The default value is 0.
spreadsheetLayout.fitToWidthintegeroptionalSets the width of the converted area, measured in the number of pages. The default value is 0.
spreadsheetLayout.gridLinesbooleanoptionalAllows to include grid lines to the output PDF file or not. The default value is false.
spreadsheetLayout.headingsbooleanoptionalAllows to include the headings to the output PDF file or not. The default value is false.
spreadsheetLayout.ignorePrintAreabooleanoptionalDetermines whether to ignore the print area chosen for the spreadsheet file or not. The default value is true.
spreadsheetLayout.marginsobjectoptionalSets the margins of the output PDF file.
spreadsheetLayout.margins.bottomstringoptionalSets the bottom margin of the output PDF file. The default value is 19.1mm.
spreadsheetLayout.margins.leftstringoptionalSets the left margin of the output PDF file. The default value is 17.8mm.
spreadsheetLayout.margins.rightstringoptionalSets the right margin of the output PDF file. The default value is 17.8mm.
spreadsheetLayout.margins.topstringoptionalSets the top margin of the output PDF file. The default value is 19.1mm.
spreadsheetLayout.orientationstringoptionalSets the orientation of the output PDF file. May be landscape, portrait. The default value is portrait.
spreadsheetLayout.pageSizeobjectoptionalSets the page size of the output PDF file.
spreadsheetLayout.pageSize.heightstringoptionalSets the page height of the output PDF file. The default value is 297mm.
spreadsheetLayout.pageSize.widthstringoptionalSets the page width of the output PDF file. The default value is 210mm.
spreadsheetLayout.scaleintegeroptionalAllows to set the scale of the output PDF file. The default value is 100.
thumbnailobjectoptionalDefines the settings for the thumbnail when specifying the image formats (bmp, gif, jpg, png) as outputtype.
thumbnail.aspectintegeroptionalDefines the mode to fit the image to the height and width specified: 0 - stretch file to fit height and width, 1 - keep the aspect for the image, 2 - metric sizes of the page are converted into pixels with 96dpi. The default value is 2.
thumbnail.firstbooleanoptionalDefines if the thumbnails should be generated for the first page only or for all the document pages. If false, the zip archive containing thumbnails for all the pages will be created. The default value is true.
thumbnail.heightintegeroptionalDefines the thumbnail height in pixels. The default value is 100.
thumbnail.widthintegeroptionalDefines the thumbnail width in pixels. The default value is 100.
titlestringoptionalDefines the converted file name.
tokenstringrequired by configurationDefines the encrypted signature added to the ONLYOFFICE Docs config in the form of a token.
urlstringrequiredDefines the absolute URL to the document to be converted. Be sure to add a token when using local links. Otherwise, an error will occur.
watermarkobjectoptionalDefines a JSON object containing the properties of a watermark which is inserted into the pdf and image files during conversion.
watermark.alignintegeroptionalDefines the vertical text align in the watermark shape: 0 - bottom, 1 - center, 4 - top.
watermark.fillarray of integers | stringoptionalDefines the watermark fill color in the RGB format, or the URL to image (base64 support: data:image/png;...). The empty array [] means that the watermark has no fill.
watermark.heightintegeroptionalDefines the watermark height measured in millimeters.
watermark.marginsarray of integersoptionalDefines the text margins measured in millimeters in the watermark shape.
watermark.paragraphsarray of objectsoptionalDefines the array with paragraphs from the current watermark with their properties.
watermark.paragraphs.alignintegeroptionalDefines the horizontal text align in the current paragraph: 0 - right, 1 - left, 2 - center, 3 - justify.
watermark.paragraphs.fillarray of integersoptionalDefines the paragraph highlight in the RGB format. The empty array [] means that the paragraph is not highlighted.
watermark.paragraphs.linespacingintegeroptionalDefines the text linespacing in the current paragraph.
watermark.paragraphs.runsarray of objectsoptionalDefines the array with runs from the current paragraph with their properties.
watermark.paragraphs.runs.boldbooleanoptionalDefines if the current text is displayed bold or not.
watermark.paragraphs.runs.fillarray of integersoptionalDefines the text highlight in the RGB format. The empty array [] means that the text is not highlighted.
watermark.paragraphs.runs.font-familystringoptionalDefines the text font family.
watermark.paragraphs.runs.font-sizestringoptionalDefines the text font size measured in points (pt).
watermark.paragraphs.runs.italicbooleanoptionalDefines if the current text is displayed italic or not.
watermark.paragraphs.runs.strikeoutbooleanoptionalDefines if the current text is displayed struck through or not.
watermark.paragraphs.runs.textstringoptionalDefines the run text.
watermark.paragraphs.runs.underlinebooleanoptionalDefines if the current text is displayed underlined or not.
watermark.rotateintegeroptionalDefines the watermark rotation angle measured in degrees.
watermark.strokearray of integersoptionalDefines the watermark stroke color in the RGB format. The empty array [] means that the watermark stroke has no fill.
watermark.stroke-widthintegeroptionalDefines the watermark stroke width measured in millimeters.
watermark.transparentfloatoptionalDefines the watermark transparency degree.
watermark.typestringoptionalDefines the shape type which specifies the preset shape geometry for the current watermark.
watermark.widthintegeroptionalDefines the watermark width measured in millimeters.
warning

If the conversion is synchronous and the file takes a long time to be converted, a web request timeout error may occur. Although the conversion can be eventually completed, the result can only be obtained by sending the request again with the same key.

warning

Please note that the maximum number of pages that can be returned at once after converting a spreadsheet into pdf or image formats is no more than 1500.

info

In the tables below you can see possibility of conversion your documents into the most known file formats, where the Input format column corresponds to the values of the filetype parameter and the Output format columns correspond to the values of the outputtype parameter.

Examples of requests

Converting docx to pdf

This example shows a basic request to convert a docx file to pdf format.

{
"async": false,
"filetype": "docx",
"key": "Khirz6zTPdfd7",
"outputtype": "pdf",
"title": "Example Document Title.docx",
"url": "https://example.com/url-to-example-document.docx"
}

Where example.com is the name of the server where document manager and document storage service are installed. You can use the URL https://static.onlyoffice.com/assets/docs/samples/demo.docx of our sample document for testing. See the How it works section to find out more on ONLYOFFICE Docs service client-server interactions.

Converting password-protected docx to pdf

This example shows how to convert a password-protected docx file to pdf format using the password parameter.

{
"async": false,
"filetype": "docx",
"key": "Khirz6zTPdfd7",
"outputtype": "pdf",
"password": "123456",
"title": "Example Document Title.docx",
"url": "https://example.com/url-to-example-document.docx"
}

Where example.com is the name of the server where document manager and document storage service are installed. You can use the URL https://static.onlyoffice.com/assets/docs/samples/demo.docx of our sample document for testing. See the How it works section to find out more on ONLYOFFICE Docs service client-server interactions.

Converting docx to pdf form

This example shows how to convert a docx file to a fillable pdf form using the pdf.form parameter.

{
"async": false,
"filetype": "docx",
"key": "Khirz6zTPdfd7",
"outputtype": "pdf",
"pdf": {
"form": true
},
"title": "Example Document Title.docx",
"url": "https://example.com/url-to-example-document.docx"
}

Where example.com is the name of the server where document manager and document storage service are installed. You can use the URL https://static.onlyoffice.com/assets/docs/samples/demo.docx of our sample document for testing. See the How it works section to find out more on ONLYOFFICE Docs service client-server interactions.

Converting docx to pdf with watermark

This example shows how to convert a docx file to pdf format with a watermark inserted using the watermark parameter.

{
"async": false,
"filetype": "docx",
"key": "Khirz6zTPdfd7",
"outputtype": "pdf",
"title": "Example Document Title.docx",
"url": "https://example.com/url-to-example-document.docx",
"watermark": {
"align": 1,
"fill": [255, 0, 0],
"height": 100,
"margins": [10, 10, 10, 10],
"paragraphs": [
{
"align": 2,
"fill": [255, 0, 0],
"linespacing": 1,
"runs": [
{
"bold": true,
"italic": false,
"fill": [0, 0, 0],
"font-family": "Arial",
"font-size": 40,
"strikeout": false,
"text": "Watermark",
"underline": false
},
{
"text": "<%br%>"
}
]
}
],
"rotate": -45,
"transparent": 0.3,
"type": "rect",
"stroke-width": 1,
"stroke": [0, 0, 255],
"width": 100
}
}

Where example.com is the name of the server where document manager and document storage service are installed. You can use the URL https://static.onlyoffice.com/assets/docs/samples/demo.docx of our sample document for testing. See the How it works section to find out more on ONLYOFFICE Docs service client-server interactions.

Generating png thumbnail from docx

This example shows how to generate a png thumbnail from a docx file using the thumbnail parameter.

{
"filetype": "docx",
"key": "Khirz6zTPdfd7",
"outputtype": "png",
"thumbnail": {
"aspect": 0,
"first": true,
"height": 150,
"width": 100
},
"title": "Example Document Title.docx",
"url": "https://example.com/url-to-example-document.docx"
}

Where example.com is the name of the server where document manager and document storage service are installed. You can use the URL https://static.onlyoffice.com/assets/docs/samples/demo.docx of our sample document for testing. See the How it works section to find out more on ONLYOFFICE Docs service client-server interactions.

Converting spreadsheet to pdf

This example shows how to convert a spreadsheet file to pdf format using the spreadsheetLayout parameter.

{
"filetype": "xlsx",
"key": "Khirz6zTPdfd7",
"outputtype": "pdf",
"region": "en-US",
"spreadsheetLayout": {
"ignorePrintArea": true,
"orientation": "portrait",
"fitToWidth": 0,
"fitToHeight": 0,
"scale": 100,
"headings": false,
"gridLines": false,
"pageSize": {
"width": "210mm",
"height": "297mm"
},
"margins": {
"left": "17.8mm",
"right": "17.8mm",
"top": "19.1mm",
"bottom": "19.1mm"
}
},
"title": "Example Document Title.xlsx",
"url": "https://example.com/url-to-example-spreadsheet.xlsx"
}

Where example.com is the name of the server where document manager and document storage service are installed. You can use the URL https://static.onlyoffice.com/assets/docs/samples/demo.xlsx of our sample document for testing. See the How it works section to find out more on ONLYOFFICE Docs service client-server interactions.

Converting docx to pdf with JWT

This example shows how to convert a docx file to pdf format using a JSON Web Token for authentication.

{
"token": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJmaWxldHlwZSI6ImRvY3giLCJrZXkiOiJLaGlyejZ6VFBkZmQ3Iiwib3V0cHV0dHlwZSI6InBkZiIsInRpdGxlIjoiRXhhbXBsZSBEb2N1bWVudCBUaXRsZS5kb2N4IiwidXJsIjoiaHR0cDovL2V4YW1wbGUuY29tL3VybC10by1leGFtcGxlLWRvY3VtZW50LmRvY3gifQ.U-YAfuuy7clWjn-xOncfJ-sxVG5DlcYn0AOzJYkoR0M"
}

Where example.com is the name of the server where document manager and document storage service are installed. You can use the URL https://static.onlyoffice.com/assets/docs/samples/demo.docx of our sample document for testing. See the How it works section to find out more on ONLYOFFICE Docs service client-server interactions.