The svg-to-pdf call converts a SVG file to PDF using Inkscape.
To convert SVG files to PDF, you need to install Inkscape on your server:
sudo apt install inkscape
To use the PDF call, the account must have the svg-to-pdf
flag set to true
:
Using Backend.js, a SVG file can be converted to PDF as follows:
const backend = new Backend('https://viereck.ch/backend'); const account = backend.account('your-account-id', '44705748... your-account-key'); const svgToken = 'd94d3886...'; const resources = [ {name: 'logo.png', '#b': '7b8cf18d...'}, ... ]; account.svgToPdf(svgToken, resources, onDone, onError); function onDone(token, request) { ... } function onError(errorCode, request) { ... }
All SVG files and resources must be uploaded beforehand, if necessary.
POST /backend/svg-to-pdf
Account: ACCOUNT ID
Timestamp: TIMESTAMP
Signature: SIGNATURE
200
with the blob token of the generated PDF
400
if a file is missing
401
if the account ID or signature is missing or invalid
403
if the account is not allowed to use SVG to PDF
A simple request has the following structure:
The token refers to a previously uploaded SVG blob. The file is passed to inkscape, and the resulting PDF file is again stored as a blob.
If the source file refers to external resources, these resources must be uploaded as blobs as well, and specified in the request:
All resources are staged in a folder alongside the SVG file before calling inkscape.