Compilation
/builds/sync
Compile a LaTeX document and get back the generated PDF, waiting for the end of the build (synchronous).
The request carries a compilation specification: the LaTeX compiler to use, the resources (the LaTeX sources and their dependencies — images, bibliographies, included files…) and build options. Three input modes are supported, all served by the same endpoint:
- GET querystring — small documents, quick one-liners;
- POST JSON — the richest mode, suited to server code;
- POST multipart/form-data — upload local or binary files directly.
On success the response body is the generated PDF (HTTP 201).
On failure the response is a JSON payload with the error and the compiler
logs (see the response reference).
Available compilers
| Compiler | Description |
|---|---|
pdflatex |
Default. Classic pdfTeX, ASCII-oriented, widely compatible. |
xelatex |
Unicode-native engine, uses system fonts (fontspec). |
lualatex |
Unicode-native engine with embedded Lua scripting. |
platex |
Japanese pTeX engine (DVI output, converted with dvipdfmx). |
uplatex |
Unicode Japanese upTeX engine (DVI output, converted with dvipdfmx). |
context |
ConTeXt standalone typesetting system. |
The compiler property defaults to pdflatex.
GET querystring mode
Pass the main document and annex resources as GET parameters. Handy for quick one-liners and ?compiler=…&url=… bookmarklets; better suited to small documents, as everything travels in the URL.
| Name | Type | Default | Description |
|---|---|---|---|
contentone of content / url / file |
string | — | Main document, as a (URL-encoded) LaTeX string. Values starting with http given without a resource-type[] are guessed as URLs. |
urlone of content / url / file |
string (URL) | — | Main document, fetched by the server from this URL. |
fileone of content / url / file |
string (base64) | — | Main document, base64-encoded. |
compiler |
string | pdflatex |
One of pdflatex, xelatex, lualatex, platex, uplatex, context. |
resource-path[] |
string (repeatable) | — | Path of an annex resource, relative to the main document (eg. logo.png, chapters/intro.tex). |
resource-type[] |
string (repeatable) | guessed |
Type of the matching resource-value[]: url, file (base64) or content (plain string). base64 and string are accepted aliases. |
resource-value[] |
string (repeatable) | — | Content (URL, base64 data or string) of the matching resource. |
options.* |
string | — | Dotted build options, eg. options.compiler.shell_escape=true. See the options reference. |
# Compile a document passed inline as the main resource:
curl -G https://latex.ytotech.com/builds/sync \
--data-urlencode 'content=\documentclass{article} \begin{document} Hello World LaTeX-On-HTTP \end{document}' \
--output hello_world.pdf
# Compile a document fetched from an URL, with the XeLaTeX compiler,
# plus an annex resource (an image downloaded from an URL):
curl -G https://latex.ytotech.com/builds/sync \
--data-urlencode 'compiler=xelatex' \
--data-urlencode 'url=https://raw.githubusercontent.com/YtoTech/latex-on-http/master/examples/templates/moderncv.tex' \
--data-urlencode 'resource-type[]=url' \
--data-urlencode 'resource-path[]=logo.png' \
--data-urlencode 'resource-value[]=https://www.ytotech.com/images/ytotech_logo.png' \
--output resume.pdf
# Compile a document passed inline as the main resource:
http --download --output hello_world.pdf GET https://latex.ytotech.com/builds/sync \
compiler==pdflatex \
'content==\documentclass{article} \begin{document} Hello World LaTeX-On-HTTP \end{document}'
# Compile a document fetched from an URL, with the XeLaTeX compiler,
# plus an annex resource (an image downloaded from an URL):
http --download --output resume.pdf GET https://latex.ytotech.com/builds/sync \
compiler==xelatex \
'url==https://raw.githubusercontent.com/YtoTech/latex-on-http/master/examples/templates/moderncv.tex' \
'resource-type[]==url' \
'resource-path[]==logo.png' \
'resource-value[]==https://www.ytotech.com/images/ytotech_logo.png'
import requests
response = requests.get(
"https://latex.ytotech.com/builds/sync",
params={
"compiler": "pdflatex",
"content": (
"\\documentclass{article}\n"
"\\begin{document}\n"
"Hello World LaTeX-On-HTTP\n"
"\\end{document}"
),
"resource-type[]": "url",
"resource-path[]": "logo.png",
"resource-value[]": "https://www.ytotech.com/images/ytotech_logo.png",
},
timeout=120,
)
response.raise_for_status()
with open("hello_world.pdf", "wb") as pdf_file:
pdf_file.write(response.content)
<?php
// Annex resources are passed as resource-path[]/resource-type[]/
// resource-value[] entries; for several resources, build the query
// manually to repeat each resource-*[] key.
$params = [
"compiler" => "pdflatex",
"content" => "\\documentclass{article}\n\\begin{document}\nHello World LaTeX-On-HTTP\n\\end{document}",
"resource-type[]" => "url",
"resource-path[]" => "logo.png",
"resource-value[]" => "https://www.ytotech.com/images/ytotech_logo.png",
];
$pdf = file_get_contents("https://latex.ytotech.com/builds/sync?" . http_build_query($params));
if ($pdf !== false) {
file_put_contents("hello_world.pdf", $pdf);
}
package main
import (
"io"
"log"
"net/http"
"net/url"
"os"
)
func main() {
params := url.Values{}
params.Set("compiler", "pdflatex")
params.Set("content", "\\documentclass{article}\n\\begin{document}\nHello World LaTeX-On-HTTP\n\\end{document}")
params.Set("resource-type[]", "url")
params.Set("resource-path[]", "logo.png")
params.Set("resource-value[]", "https://www.ytotech.com/images/ytotech_logo.png")
// For several resources, use params.Add to repeat each resource-*[] key.
response, err := http.Get("https://latex.ytotech.com/builds/sync?" + params.Encode())
if err != nil {
log.Fatal(err)
}
defer response.Body.Close()
pdf, err := io.ReadAll(response.Body)
if err != nil {
log.Fatal(err)
}
if response.StatusCode == http.StatusCreated {
os.WriteFile("hello_world.pdf", pdf, 0644)
} else {
log.Fatalf("Compilation failed: %s", pdf)
}
}
Mix.install([{:req, "~> 0.8"}])
response =
Req.get!("https://latex.ytotech.com/builds/sync",
params: [
{"compiler", "pdflatex"},
{"content", "\\documentclass{article}\n\\begin{document}\nHello World LaTeX-On-HTTP\n\\end{document}"},
{"resource-type[]", "url"},
{"resource-path[]", "logo.png"},
{"resource-value[]", "https://www.ytotech.com/images/ytotech_logo.png"}
]
)
if response.status == 201 do
File.write!("hello_world.pdf", response.body)
else
IO.puts("Compilation failed: #{response.body["error"]}")
end
const params = new URLSearchParams({
compiler: "pdflatex",
content: "\\documentclass{article}\n\\begin{document}\n"
+ "Hello World LaTeX-On-HTTP\n\\end{document}",
"resource-type[]": "url",
"resource-path[]": "logo.png",
"resource-value[]": "https://www.ytotech.com/images/ytotech_logo.png",
});
const response = await fetch("https://latex.ytotech.com/builds/sync?" + params.toString());
if (!response.ok) {
const error = await response.json();
console.error(`Compilation failed: ${error.error}`, error.logs);
} else {
// The body is the compiled PDF: pipe it to a file, a blob, etc.
const pdfBlob = await response.blob();
}
(let [params (js/URLSearchParams.)]
(.append params "compiler" "pdflatex")
(.append params "content" "\\documentclass{article}\n\\begin{document}\nHello World LaTeX-On-HTTP\n\\end{document}")
(.append params "resource-type[]" "url")
(.append params "resource-path[]" "logo.png")
(.append params "resource-value[]" "https://www.ytotech.com/images/ytotech_logo.png")
(-> (js/fetch (str "https://latex.ytotech.com/builds/sync?" (.toString params)))
(.then (fn [response]
(if (.-ok response)
(.then (.blob response)
(fn [pdf-blob]
;; Display or save the PDF, eg.:
(set! (.-src (.getElementById js/document "pdf-view"))
(js/URL.createObjectURL pdf-blob))))
(.then (.json response)
(fn [error]
(js/console.error "Compilation failed" error))))))))
POST JSON mode
The richest input mode: a JSON payload describing the compiler, the resources (inline content, base64 files, remote URLs or cache hits) and the build options.
| Name | Type | Default | Description |
|---|---|---|---|
compiler |
string | pdflatex |
One of pdflatex, xelatex, lualatex, platex, uplatex, context. |
resourcesrequired |
list of objects | — | The files uploaded and compiled. See the resource fields: each entry takes a main flag, a path and exactly one source field (content, file, url or cache). |
options |
object | — | Build options, nested (options.compiler.…, options.response.…). Top-level dotted keys ("options.compiler.silent": true) are also accepted and merged. |
Resource entries
The resources list describes the files uploaded and compiled
server-side. The file arborescence is reconstructed from the
path properties, so relative references
(\include{chapters/intro}, \includegraphics{logo.png}…)
work as in a local compilation. Each entry takes:
| Name | Type | Default | Description |
|---|---|---|---|
main |
boolean | — | Mark the entry as the main LaTeX document. With several entries exactly one must be flagged; with a single entry it is the main document automatically. |
path |
string | — | File path, relative to the main document, under which the resource is written server-side before the compilation. Mandatory for non-main entries so they can be referred to from the LaTeX sources. |
content |
string | — | Resource source: plain text content, as a valid JSON string (UTF-8). Use this mode for LaTeX sources. |
file |
string (base64) | — | Resource source: file content, base64-encoded. |
url |
string (URL) | — | Resource source: the file is downloaded by the server from this URL before the compilation. |
cache |
string (hash) | — | Resource source: retrieve the content from the server input cache, identified by its sha256:… hash. Only useful to smart clients that precomputed resource hashes (caches API). |
multipart |
string | — | Multipart API only: name of the multipart/form-data part holding the resource content. The part is read as binary data (base64-encoded server-side). |
curl -X POST https://latex.ytotech.com/builds/sync \
-H "Content-Type: application/json" \
-d '{
"compiler": "lualatex",
"resources": [
{
"main": true,
"content": "\\documentclass{article}\n\\usepackage{graphicx}\n\\begin{document}\n Hello World\\\\\n \\includegraphics[height=2cm,width=7cm,keepaspectratio=true]{logo.png}\n \\include{page2}\n\\end{document}"
},
{
"path": "logo.png",
"url": "https://www.ytotech.com/images/ytotech_logo.png"
},
{
"path": "page2.tex",
"file": "VGhpcyBpcyB0aGUgc2Vjb25kIHBhZ2UsIHdoaWNoIHdhcyBwYXNzZWQgYXMgYSBiYXNlNjQgZW5jb2RlZCBmaWxl"
}
]
}' \
--output hello_world.pdf
http --download --output hello_world.pdf POST https://latex.ytotech.com/builds/sync \
compiler=lualatex \
resources:='[
{
"main": true,
"content": "\\documentclass{article}\n\\usepackage{graphicx}\n\\begin{document}\n Hello World\\\\\n \\includegraphics[height=2cm,width=7cm,keepaspectratio=true]{logo.png}\n \\include{page2}\n\\end{document}"
},
{
"path": "logo.png",
"url": "https://www.ytotech.com/images/ytotech_logo.png"
},
{
"path": "page2.tex",
"file": "VGhpcyBpcyB0aGUgc2Vjb25kIHBhZ2UsIHdoaWNoIHdhcyBwYXNzZWQgYXMgYSBiYXNlNjQgZW5jb2RlZCBmaWxl"
}
]'
import requests
payload = {
"compiler": "lualatex",
"resources": [
{
"main": True,
"content": "\\documentclass{article}\n \\usepackage{graphicx}\n \\begin{document}\n Hello World\\\\\n \\includegraphics[height=2cm,width=7cm,keepaspectratio=true]{logo.png}\n \\include{page2}\n \\end{document}",
},
{
"path": "logo.png",
"url": "https://www.ytotech.com/images/ytotech_logo.png",
},
{
"path": "page2.tex",
"file": "VGhpcyBpcyB0aGUgc2Vjb25kIHBhZ2UsIHdoaWNoIHdhcyBwYXNzZWQgYXMgYSBiYXNlNjQgZW5jb2RlZCBmaWxl",
},
],
}
response = requests.post(
"https://latex.ytotech.com/builds/sync",
json=payload,
timeout=120,
)
if response.ok:
with open("hello_world.pdf", "wb") as pdf_file:
pdf_file.write(response.content)
else:
error = response.json()
print(f"Compilation failed: {error['error']}")
print(error.get("logs", ""))
<?php
$payload = json_encode([
"compiler" => "lualatex",
"resources" => [
[
"main" => true,
"content" => "\\documentclass{article}\n \\usepackage{graphicx}\n \\begin{document}\n Hello World\\\\\n \\includegraphics[height=2cm,width=7cm,keepaspectratio=true]{logo.png}\n \\include{page2}\n \\end{document}",
],
[
"path" => "logo.png",
"url" => "https://www.ytotech.com/images/ytotech_logo.png",
],
[
"path" => "page2.tex",
"file" => "VGhpcyBpcyB0aGUgc2Vjb25kIHBhZ2UsIHdoaWNoIHdhcyBwYXNzZWQgYXMgYSBiYXNlNjQgZW5jb2RlZCBmaWxl",
],
],
]);
$context = stream_context_create([
"http" => [
"method" => "POST",
"header" => "Content-Type: application/json\r\n",
"content" => $payload,
"timeout" => 120,
// Return the body of 4xx responses as well, so compilation
// failures can be handled instead of emitting a PHP warning.
"ignore_errors" => true,
],
]);
$response = file_get_contents("https://latex.ytotech.com/builds/sync", false, $context);
$statusLine = $http_response_header[0] ?? "";
if ($response !== false && str_contains($statusLine, "201")) {
file_put_contents("hello_world.pdf", $response);
} else {
$error = json_decode($response, true);
echo "Compilation failed: {$error["error"]}\n";
echo $error["logs"] . "\n";
}
package main
import (
"bytes"
"encoding/json"
"io"
"log"
"net/http"
"os"
)
func main() {
payload := map[string]any{
"compiler": "lualatex",
"resources": []map[string]any{
{
"main": true,
"content": "\\documentclass{article}\n \\usepackage{graphicx}\n \\begin{document}\n Hello World\\\\\n \\includegraphics[height=2cm,width=7cm,keepaspectratio=true]{logo.png}\n \\include{page2}\n \\end{document}",
},
{"path": "logo.png", "url": "https://www.ytotech.com/images/ytotech_logo.png"},
{
"path": "page2.tex",
"file": "VGhpcyBpcyB0aGUgc2Vjb25kIHBhZ2UsIHdoaWNoIHdhcyBwYXNzZWQgYXMgYSBiYXNlNjQgZW5jb2RlZCBmaWxl",
},
},
}
body, err := json.Marshal(payload)
if err != nil {
log.Fatal(err)
}
response, err := http.Post(
"https://latex.ytotech.com/builds/sync",
"application/json",
bytes.NewReader(body),
)
if err != nil {
log.Fatal(err)
}
defer response.Body.Close()
responseBody, _ := io.ReadAll(response.Body)
if response.StatusCode == http.StatusCreated {
os.WriteFile("hello_world.pdf", responseBody, 0644)
} else {
log.Fatalf("Compilation failed: %s", responseBody)
}
}
Mix.install([{:req, "~> 0.8"}])
payload = %{
compiler: "lualatex",
resources: [
%{
main: true,
content: "\\documentclass{article}\n \\usepackage{graphicx}\n \\begin{document}\n Hello World\\\\\n \\includegraphics[height=2cm,width=7cm,keepaspectratio=true]{logo.png}\n \\include{page2}\n \\end{document}"
},
%{path: "logo.png", url: "https://www.ytotech.com/images/ytotech_logo.png"},
%{
path: "page2.tex",
file: "VGhpcyBpcyB0aGUgc2Vjb25kIHBhZ2UsIHdoaWNoIHdhcyBwYXNzZWQgYXMgYSBiYXNlNjQgZW5jb2RlZCBmaWxl"
}
]
}
response = Req.post!("https://latex.ytotech.com/builds/sync", json: payload)
if response.status == 201 do
File.write!("hello_world.pdf", response.body)
else
IO.puts("Compilation failed: #{response.body["error"]}")
IO.puts(response.body["logs"] || "")
end
const response = await fetch("https://latex.ytotech.com/builds/sync", {
method: "POST",
headers: { "Content-Type": "application/json" },
body: JSON.stringify({
compiler: "lualatex",
resources: [
{
main: true,
content: "\\documentclass{article}\n \\usepackage{graphicx}\n \\begin{document}\n Hello World\\\\\n \\includegraphics[height=2cm,width=7cm,keepaspectratio=true]{logo.png}\n \\include{page2}\n \\end{document}",
},
{
path: "logo.png",
url: "https://www.ytotech.com/images/ytotech_logo.png",
},
{
path: "page2.tex",
file: "VGhpcyBpcyB0aGUgc2Vjb25kIHBhZ2UsIHdoaWNoIHdhcyBwYXNzZWQgYXMgYSBiYXNlNjQgZW5jb2RlZCBmaWxl",
},
],
}),
});
if (!response.ok) {
const error = await response.json();
console.error(`Compilation failed: ${error.error}`, error.logs);
} else {
const pdfBlob = await response.blob();
}
(-> (js/fetch "https://latex.ytotech.com/builds/sync"
#js {:method "POST"
:headers #js {"Content-Type" "application/json"}
:body (js/JSON.stringify
(clj->js {:compiler "lualatex"
:resources [{:main true
:content "\\documentclass{article}\n \\usepackage{graphicx}\n \\begin{document}\n Hello World\\\\\n \\includegraphics[height=2cm,width=7cm,keepaspectratio=true]{logo.png}\n \\include{page2}\n \\end{document}"}
{:path "logo.png"
:url "https://www.ytotech.com/images/ytotech_logo.png"}
{:path "page2.tex"
:file "VGhpcyBpcyB0aGUgc2Vjb25kIHBhZ2UsIHdoaWNoIHdhcyBwYXNzZWQgYXMgYSBiYXNlNjQgZW5jb2RlZCBmaWxl"}]}))})
(.then (fn [response]
(if (.-ok response)
(-> (.blob response)
(.then (fn [pdf-blob]
;; Display the PDF in the page, eg.:
(set! (.-src (.getElementById js/document "pdf-view"))
(js/URL.createObjectURL pdf-blob)))))
(-> (.json response)
(.then (fn [error]
(js/console.error (.-error error)
(.-logs error)))))))))
POST multipart/form-data mode
Send the resources as multipart/form-data parts: the natural choice to upload local/binary files (images, bibliographies, class files…), with no base64 encoding step.
| Name | Type | Default | Description |
|---|---|---|---|
compiler |
string (form field) | pdflatex |
LaTeX compiler to use. |
options.* |
string (form fields) | — | Dotted build options as form fields, eg. options.compiler.halt_on_error=true. |
resources |
string (form field, JSON) | — | JSON list of resource entries. Each entry maps to an uploaded file part with the multipart field (naming the form part), plus main and path; entries without multipart may still use inline content/file/url sources. The file content is transferred as binary data. |
(file parts) |
binary | — | The uploaded files referenced by the multipart entries. If no resources form field is given, the resources are reconstructed from the uploaded parts: the first .tex part is the main document, each part is stored under its file name. |
# Declare the resources with a JSON form entry, and reference the
# uploaded multipart file parts by name (binary transfer, no base64):
curl -X POST https://latex.ytotech.com/builds/sync \
-F 'compiler=pdflatex' \
-F 'resources=[{"main": true, "multipart": "main"}, {"path": "logo.png", "multipart": "logo"}]' \
-F 'main=@main.tex' \
-F 'logo=@logo.png' \
--output document.pdf
# Or simply upload the files: the first .tex part is taken as the
# main document, and every part is stored under its file name.
curl -X POST https://latex.ytotech.com/builds/sync \
-F 'file=@main.tex' \
--output document.pdf
# Inline content with HTTPie:
http --multipart --download --output hello.pdf -v POST https://latex.ytotech.com/builds/sync \
compiler=pdflatex \
resources='[{"main": true, "content": "\\documentclass{article}\n \\begin{document}\n Hello World\n \\end{document}"}]'
# Local files, referenced in the resources specification:
http --multipart --download --output document.pdf POST https://latex.ytotech.com/builds/sync \
file1@main.tex \
compiler=xelatex \
resources='[{"main": true, "multipart": "file1"}]'
import json
import requests
resources = [
{"main": True, "multipart": "main"},
{"path": "logo.png", "multipart": "logo"},
]
with open("main.tex", "rb") as main_file, open("logo.png", "rb") as logo_file:
response = requests.post(
"https://latex.ytotech.com/builds/sync",
data={
"compiler": "pdflatex",
"resources": json.dumps(resources),
},
files=[
("main", ("main.tex", main_file)),
("logo", ("logo.png", logo_file)),
],
timeout=120,
)
response.raise_for_status()
with open("document.pdf", "wb") as pdf_file:
pdf_file.write(response.content)
<?php
$ch = curl_init("https://latex.ytotech.com/builds/sync");
curl_setopt_array($ch, [
CURLOPT_POST => true,
CURLOPT_POSTFIELDS => [
"compiler" => "pdflatex",
"resources" => json_encode([
["main" => true, "multipart" => "main"],
["path" => "logo.png", "multipart" => "logo"],
]),
"main" => new CURLFile("main.tex"),
"logo" => new CURLFile("logo.png"),
],
CURLOPT_RETURNTRANSFER => true,
]);
$response = curl_exec($ch);
$status = curl_getinfo($ch, CURLINFO_HTTP_CODE);
curl_close($ch);
if ($status === 201) {
file_put_contents("document.pdf", $response);
} else {
$error = json_decode($response, true);
echo "Compilation failed: {$error["error"]}\n";
}
package main
import (
"bytes"
"io"
"log"
"mime/multipart"
"net/http"
"os"
)
func main() {
var requestBody bytes.Buffer
writer := multipart.NewWriter(&requestBody)
_ = writer.WriteField("compiler", "pdflatex")
_ = writer.WriteField(
"resources",
`[{"main": true, "multipart": "main"}, {"path": "logo.png", "multipart": "logo"}]`,
)
for _, part := range []struct{ field, path string }{
{"main", "main.tex"},
{"logo", "logo.png"},
} {
file, err := os.Open(part.path)
if err != nil {
log.Fatal(err)
}
fileWriter, err := writer.CreateFormFile(part.field, part.path)
if err != nil {
log.Fatal(err)
}
if _, err := io.Copy(fileWriter, file); err != nil {
log.Fatal(err)
}
file.Close()
}
writer.Close()
request, err := http.NewRequest(
"POST",
"https://latex.ytotech.com/builds/sync",
&requestBody,
)
if err != nil {
log.Fatal(err)
}
request.Header.Set("Content-Type", writer.FormDataContentType())
response, err := http.DefaultClient.Do(request)
if err != nil {
log.Fatal(err)
}
defer response.Body.Close()
responseBody, _ := io.ReadAll(response.Body)
if response.StatusCode == http.StatusCreated {
os.WriteFile("document.pdf", responseBody, 0644)
} else {
log.Fatalf("Compilation failed: %s", responseBody)
}
}
Mix.install([{:req, "~> 0.8"}, {:jason, "~> 1.4"}])
resources = [
%{main: true, multipart: "main"},
%{path: "logo.png", multipart: "logo"}
]
response =
Req.post!("https://latex.ytotech.com/builds/sync",
form_multipart: [
{"compiler", "pdflatex"},
{"resources", Jason.encode!(resources)},
{"main", {File.read!("main.tex"), filename: "main.tex"}},
{"logo", {File.read!("logo.png"), filename: "logo.png"}}
]
)
if response.status == 201 do
File.write!("document.pdf", response.body)
else
IO.puts("Compilation failed: #{response.body["error"]}")
end
const resources = [
{ main: true, multipart: "main" },
{ path: "logo.png", multipart: "logo" },
];
const formData = new FormData();
formData.append("compiler", "pdflatex");
formData.append("resources", JSON.stringify(resources));
formData.append("main", mainTexFile); // File objects, eg. from <input type="file">
formData.append("logo", logoPngFile);
const response = await fetch("https://latex.ytotech.com/builds/sync", {
method: "POST",
body: formData, // The browser sets the multipart Content-Type itself.
});
(let [form-data (js/FormData.)
resources (clj->js [{:main true :multipart "main"}
{:path "logo.png" :multipart "logo"}])]
(.append form-data "compiler" "pdflatex")
(.append form-data "resources" (js/JSON.stringify resources))
(.append form-data "main" main-tex-file "main.tex") ;; File objects, eg. from <input type="file">
(.append form-data "logo" logo-png-file "logo.png")
(-> (js/fetch "https://latex.ytotech.com/builds/sync"
#js {:method "POST" :body form-data})
(.then (fn [response]
(if (.-ok response)
(-> (.blob response)
(.then (fn [pdf-blob]
;; Display the PDF in the page, eg.:
(set! (.-src (.getElementById js/document "pdf-view"))
(js/URL.createObjectURL pdf-blob)))))
(-> (.json response)
(.then (fn [error]
(js/console.error (.-error error))))))))))
Build options
The options object tunes the compilation and the response
contents. Boolean values may be given as JSON booleans, or as strings
("true", "1", "t") in querystring and
multipart modes.
| Name | Type | Default | Description |
|---|---|---|---|
options.compiler.bibliography |
boolean | true |
Run bibtex/biber as needed to regenerate .bbl files (LaTeXmk -bibtex option). |
options.compiler.halt_on_error |
boolean | false |
Stop on the first error, even if non-fatal (-halt-on-error option). |
options.compiler.silent |
boolean | false |
Non-verbose mode: -interaction=batchmode and LaTeXmk -silent. By default -interaction=nonstopmode is used. |
options.compiler.force |
boolean | true |
Force LaTeXmk to process the document even if errors occur (-f flag). |
options.compiler.shell_escape |
boolean | false |
Enable TeX -shell-escape inside the isolated compilation sandbox, for packages such as minted that run pygmentize. The engine otherwise receives an explicit -no-shell-escape option. See the sandboxing model. |
options.response.log_files_on_failure |
boolean | true |
Return the full LaTeX log files (log_files property) in the JSON payload on compilation error. |
options.response.commands |
boolean | false |
Return the details of the commands run during the compilation (commands property) in the JSON payload on compilation error. |
Response
On success
201 Created with the generated PDF as body (Content-Type: application/pdf, Content-Disposition: inline, so browsers display it instead of downloading it). The response carries an X-Job-ID header identifying the compilation job.
On failure
400 with a JSON payload describing the failure: error (error code), duration, logs (compiler output) and, unless disabled, log_files (full LaTeX log files). Add options.response.commands to get the commands run. 429 when the fair-use quota is exceeded (rate limiting & quotas). 503 if the compilation sandbox is unavailable; 500 on unexpected server errors.
Example error payload (with options.response.log_files_on_failure
enabled, the default):
{
"error": "COMPILATION_ERROR",
"duration": 0.68,
"logs": "This is pdfTeX, Version ...\n! LaTeX Error: File `graphix.sty' not found.\n...",
"log_files": {
"__main_document__.log": "... full LaTeX log ..."
}
}
Error codes
| Error code | HTTP | Meaning |
|---|---|---|
INVALID_PAYLOAD_SHAPE |
400 |
The payload does not match the input specification (shape_errors details the schema violations). |
MISSING_COMPILATION_SPECIFICATION |
400 |
No compilation specification could be parsed from the request. |
MISSING_RESOURCES |
400 |
The resources list is missing. |
RESOURCES_SPEC_MUST_BE_A_LIST |
400 |
resources is not a list. |
MULTIPLE_RESOURCE_SOURCES |
400 |
A resource entry specifies several source fields at once (url, file, git, tar, cache, content): use exactly one. |
MUST_SPECIFY_MAIN_DOCUMENT |
400 |
No resource is flagged as the main document (main: true), while the compilation has several entries. |
MORE_THAN_ONE_MAIN_DOCUMENT |
400 |
Several resources are flagged as the main document. |
MISSING_PATH_ON_RESOURCE |
400 |
A non-main resource entry is missing its path. |
INVALID_COMPILER |
400 |
Unknown compiler value. available_compilers lists the supported engines. |
INVALID_RESOURCE_TYPE |
400 |
Querystring mode: resource-type[] is not one of url, file (or base64), content (or string). |
RESOURCES_SPEC_MUST_BE_OF_SAME_LENGTH |
400 |
Querystring mode: resource-path[], resource-type[] and resource-value[] have different lengths. |
INVALID_STRING_CONTENT |
400 |
A content resource is not a JSON string. |
INVALID_BASE64_CONTENT |
400 |
A file resource is not valid base64 content. path is the resource's path in the build filesystem. |
RESOURCE_FETCH_FAILURE |
400 |
A resource could not be fetched. fetch_error carries a machine-readable type: http_error (a non-2xx status), connection_error, request_timeout, invalid_url (missing or unsupported scheme, no host, or an invalid port — allowed_schemes lists the accepted schemes), ssrf_blocked (the URL would reach a private, loopback or link-local address), resource_too_large (the resource exceeds the instance MAX_RESOURCE_SIZE limit — size and max_size are in bytes) or total_too_large (the combined size of the build's fetched resources exceeds the instance MAX_TOTAL_RESOURCE_SIZE limit — total_size and max_total_size are in bytes). The size limits apply to every resource type, including inline content and cache hits. |
FETCH_METHOD_NOT_SUPPORTED |
400 |
The resource source is not implemented server-side (eg. git/tar are accepted by the schema but not yet supported). |
COMPILATION_ERROR |
400 |
The LaTeX compilation failed. logs (and, by default, log_files) detail the LaTeX errors. |
COMPILATION_TIMEOUT |
400 |
The compilation exceeded the server timeout (DEFAULT_COMPILE_TIMEOUT, 100 s by default). |
SANDBOX_UNAVAILABLE |
503 |
The compilation sandbox could not be set up; the server refuses to compile without isolation. See the sandboxing documentation. |
QUOTA_EXCEEDED |
429 |
Fair-use quota exceeded for your client IP. Honor Retry-After and back off: continuing to retry escalates into a temporary ban. See the rate limiting documentation. |
QUOTA_STORE_UNAVAILABLE |
503 |
The quota store (Valkey) is unreachable on an instance configured with QUOTA_FAIL_MODE=closed; most instances fail open and keep serving instead. |
REQUEST_TOO_LARGE |
413 |
The request body exceeds the instance limit (MAX_REQUEST_BODY_BYTES, 40 MiB by default). Reduce the size of the uploaded resources; the body is rejected before it is read. |
SERVER_ERROR |
500 |
An unexpected error occurred server-side. |