Rest API to access converter¶
The communication to the converter is done via a REST API with no authentication. The sequence is basically as:
Some of the parameters below have been preserved to keep functionality with previous version of the doconverter service.
POST¶
To create a new job:
Server | Type | Endpoint |
---|---|---|
Prod | Upload file | https://doconverter.web.cern.ch/doconverter/api/v1.0/uploads |
Dev | Upload file | https://dev-doconverter.web.cern.ch/doconverter/api/v1.0/uploads |
While a new document is uploaded to the doconverter server, several parameters need to be specified:
- uploadedfile: Use multipart/form-data to upload your file.
- converter: format we would like to convert to, e.g. pdf, pdfa, ps, thumb*...
- dirresponse: where you expect to store the converted file, it will be use when sending back your new converted document
- urlresponse: callback that we will use to contact you e.g. https://mydomain.ch/api/receivefiles
- options: special options depending on type of document conversion
An example can be found within doconverter project functional test module, see Github
Input File | Conversion output | Options | Expected result | Comments |
---|---|---|---|---|
Office 2019, Autocad(cdx), OpenOffice, rtf,htm,bmp,jpg,tif | converter=[pdf,dfa,ps] | N/A | pdf file | N/A |
Special case for Word documents(e.g. doc,docx) | converter=[pdf,pdfa] | hidedocumentrevisions=[false,true] | pdf file | You may want to have comments visible on your pdf, by default they are not |
PDF file | converter=toimg | typeofimg=[jpeg,bmp,tiff,png]:imgresh=200:imgresv=200* | zip or tif file | Depending on the format of file chosen a tif file or zip file containing all the numbered pages of the document will be sent back. E.g. original file mypresentation.pdf -> zip: mypresentation.zip or tif: mypresentation.tif |
PDF file | converter=thumb | imgresh=200:imgresv=200:imgheight=300:imgwidth=300** | png file | if original file was called mydocument.pdf -> mydocument1.png |
PLT file | converter=hpgl | color=[true,false] | pdf file | N/A |
tif,png,jgp | converter=tesocr | N/A | pdf searchable file | It uses tesseract-ocr as engine that just support image files |
pdf, tif | converter=modiocr | language=[english,french] | pdf searchable file | N/A |
Info
imgresh,imgresv: should be one of '72x72','100x100','150x150','200x200','300x300','400x400','600x600','1200x1200' imgresh,imgresv,imgheight,imgwidth:should be one of '72x72','100x100','150x150','200x200','300x300','400x400','600x600','1200x1200' and imgheight_imgwidth should be an integer in pixels e.g.: thumb_200_200_150_150
Callback: receive your job results¶
You should get a result of your submitted job, either a success in that case you get a file with the expected format or a error in that case you get an error message:
- directory: where you would like to place your document
- status: 1 if success, different number otherwise
- filename: name of the file provided in the content
- error_message: in case of an error, an explanation why that happened
- content: expected file coded in a multipart/form-data section
An example can be found at Github