Convert documents into different formats
🤖/document/convert converts documents into different formats.
Note: This Robot can convert files to PDF, but cannot convert PDFs to different formats. If you want to convert PDFs to say, JPEG or TIFF, use 🤖/image/resize. If you want to turn them into text files or recognize (OCR) them to make them searchable, reach out, as we have a new Robot in the works for this.
Sometimes, a certain file type might not support what you are trying to accomplish. Perhaps your company is trying to automate document formatting, but it only works with docx, so all your docs need to be converted. Or maybe your stored jpg files are taking up too much space and you want a lighter format. Whatever the case, we have you covered.
Using this Robot, you can bypass the issues that certain file types may bring, by converting your file into the most suitable format. This also works in conjunction with our other Robots, allowing for even greater versatility when using our services.
Warning: A general rule of this Robot is that converting files into an alien format category will result in an error. For example, SRT files can be converted into the VTT format, but not to an image.
The following file formats can be converted from:
ai
csv
doc
docx
eps
gif
html
jpg
latex
md
oda
odd
odt
ott
png
pot
pps
ppt
pptx
ppz
ps
rtf
rtx
svg
text
txt
xhtml
xla
xls
xlsx
xml
Usage example
Convert uploaded files to PDF documents:
{
"steps": {
"converted": {
"robot": "/document/convert",
"use": ":original",
"format": "pdf"
}
}
}
Parameters
-
use
String / Array of Strings / Object requiredSpecifies which Step(s) to use as input.
-
You can pick any names for Steps except
":original"
(reserved for user uploads handled by Transloadit) -
You can provide several Steps as input with arrays:
"use": [ ":original", "encoded", "resized" ]
💡 That’s likely all you need to know about
use
, but you can view Advanced use cases. -
-
format
StringrequiredThe desired format for document conversion. We support the following values:
doc
,docx
,html
,xhtml
,xml
,pdf
,jpg
,jpeg
,gif
,png
,svg
,ai
,eps
,ps
,txt
,text
,csv
,xls
,xlsx
,xla
,oda
,odt
,odd
,ott
,ppt
,pptx
,ppz
,pps
,pot
,rtf
,rtx
,latex
,vtt
andsrt
. -
markdown_format
String ⋅ default:"gfm"
Markdown can be represented in several variants, so when using this Robot to transform Markdown into HTML please specify which revision is being used.
-
markdown_theme
String ⋅ default:"github"
This parameter overhauls your Markdown files styling based on several canned presets.
-
pdf_margin
String ⋅ default:"6.25mm,6.25mm,14.11mm,6.25mm"
PDF Paper margins, separated by
,
and with units.We support the following unit values:
px
,in
,cm
,mm
.Currently this parameter is only supported when converting from
html
. -
pdf_print_background
Boolean ⋅ default:true
Print PDF background graphics.
Currently this parameter is only supported when converting from
html
. -
pdf_format
String ⋅ default:"Letter"
PDF paper format.
Currently this parameter is only supported when converting from
html
. -
pdf_display_header_footer
Boolean ⋅ default:false
Display PDF header and footer.
Currently this parameter is only supported when converting from
html
. -
pdf_header_template
StringHTML template for the PDF print header.
Should be valid HTML markup with following classes used to inject printing values into them:
date
formatted print datetitle
document titleurl
document locationpageNumber
current page numbertotalPages
total pages in the document
Currently this parameter is only supported when converting from
html
, and requirespdf_display_header_footer
to be enabled.To change the formatting of the HTML element, the
font-size
must be specified in a wrapper. For example, to center the page number at the top of a page you'd use the following HTML for the header template:<div style="font-size: 15px; width: 100%; text-align: center;"><span class="pageNumber"></span></div>
-
pdf_footer_template
StringHTML template for the PDF print footer.
Should use the same format as the
pdf_header_template
.Currently this parameter is only supported when converting from
html
, and requirespdf_display_header_footer
to be enabled.To change the formatting of the HTML element, the
font-size
must be specified in a wrapper. For example, to center the page number in the footer you'd use the following HTML for the footer template:<div style="font-size: 15px; width: 100%; text-align: center;"><span class="pageNumber"></span></div>
Demos
- Add a header of footer to a PDF
- Convert document files to PDF format
- Convert the format of your subtitle from srt to vtt
Related blog posts
- Re-Loadit: enhancing subtitles with /document/convert November 16, 2019
- Convert Markdown files to HTML or PDF in seconds April 19, 2021
- Celebrating transloadit’s 2021 milestones and progress January 31, 2022