TGA to PDF API
POST a TGA to /v2/convert/tga/to/pdf and get a one-page PDF. The pixels go in compressed without loss, alpha becomes a soft mask, and the page is the image's size at 96 px per inch unless you name a sheet.
- Endpoint
- POST /v2/
convert/ tga/ to/ pdf - Accepts
- tga
- Sample timing
- 2 ms median of 5 runsHow we measure
- Request size
- Up to 10 MB on the Free plan or 100 MB on paid plans, all files together
Request and response
Every sample below ran against the API before this page was published. Set PDFCONVERSIONAPI_KEY to your key and run it as is.
curl -sS -X POST \
https://api.pdfconversionapi.com/v2/convert/tga/to/pdf \
-H "Authorization: Bearer $PDFCONVERSIONAPI_KEY" \
-F File=@shield-icon.tga \
--form-string PageSize=a5 \
-o response.json
# FileData is base64. Save the first file in converted/,
# or print the JSON error.
if jq -e '.Files' response.json > /dev/null; then
mkdir -p converted
name=$(jq -r '.Files[0].FileName' response.json)
jq -r '.Files[0].FileData' response.json \
| base64 --decode > "converted/$name"
else
cat response.json
fiimport base64
import os
import requests
key = os.environ["PDFCONVERSIONAPI_KEY"]
response = requests.post(
"https://api.pdfconversionapi.com/v2/convert/tga/to/pdf",
headers={"Authorization": f"Bearer {key}"},
files=[("File", open("shield-icon.tga", "rb"))],
data={
"PageSize": "a5",
},
timeout=180,
)
result = response.json()
if not response.ok:
raise SystemExit(f"{result['Code']}: {result['Message']}")
os.makedirs("converted", exist_ok=True)
for file in result["Files"]:
path = os.path.join("converted", file["FileName"])
with open(path, "wb") as out:
out.write(base64.b64decode(file["FileData"]))
print(path, file["FileSize"], "bytes")
import { mkdir, readFile, writeFile } from "node:fs/promises";
import { join } from "node:path";
const form = new FormData();
const file = "shield-icon.tga";
form.append("File", new Blob([await readFile(file)]), file);
form.append("PageSize", "a5");
const url = "https://api.pdfconversionapi.com/v2/convert/tga/to/pdf";
const key = process.env.PDFCONVERSIONAPI_KEY;
const response = await fetch(url, {
method: "POST",
headers: { Authorization: `Bearer ${key}` },
body: form,
});
const result = await response.json();
if (!response.ok) {
throw new Error(`${result.Code}: ${result.Message}`);
}
await mkdir("converted", { recursive: true });
for (const file of result.Files) {
const path = join("converted", file.FileName);
await writeFile(path, Buffer.from(file.FileData, "base64"));
console.log(path, file.FileSize, "bytes");
}
{
"ConversionCost": 1,
"ConversionTime": 0.002,
"Files": [
{
"FileName": "shield-icon.pdf",
"FileExt": "pdf",
"FileSize": 4009,
"FileData": "JVBERi0xLjcKJYCAgIAKMSAw…"
}
]
}Response from our test run on 2026-11-03. ConversionTime shows the median of 5 runs. FileData is shortened here; the real response carries the whole file as base64.
The sample, converted
The same file the code sends. Download the input and the output and compare them yourself.

- Input
- shield-icon.tga (16 KB)
- Output
- shield-icon.pdf (3.9 KB)
- Source
- A 256 x 256 pixel-art shield icon with a transparent background and a half-transparent shadow, drawn by us and saved as a 32-bit run-length-encoded TGA. (CC0-1.0). How it was made
- Made by
- 2026-11-04, API build
9eeeb0640aba
Parameters
Send these as form fields next to the file. Names are case-insensitive. If you set one of the documented options below that we don't support yet, the request fails with a 400 that names it instead of returning a file made without it.
| Parameter | What it does |
|---|---|
PageSizeenum, default default | default and auto size the page to the image: the 256 px shield gives a 192 × 192 pt page (2.67 in). A named sheet centers the image on it at that same size; the sample uses A5.Values: default, auto, a3, a4, a5, letter, legal |
PageOrientationenum, default default | landscape swaps a named sheet's width and height (Letter becomes 792 × 612 pt). It has no effect when the page follows the image.Values: default, portrait, landscape |
Rotateinteger | Clockwise turn. The square shield keeps its 192 pt page at 90 or 180; 30 enlarges the page to 262.28 pt to fit the turned corners. Without it the TGA is drawn the way it displays, since the origin bits in its header are applied when it is read.Values: -360 to 360 whole degrees, or none |
MarginHorizontalinteger, default 0 | Clear space at the sides, in mm. With no PageSize, 15 widened the page by 42.52 pt each side to 277.04 pt. On a sheet the art is shrunk if it would cross them: A5 with 60 mm left the shield 79.37 pt square, and 74 mm leaves no room, which returns 400.Values: 0–500 (mm) |
MarginVerticalinteger, default 0 | Clear space at the top and bottom, in mm. On A5, which is 210 mm tall, 104 still fitted a 5.67 pt shield, while 105 gave 400 'MarginHorizontal and MarginVertical leave no room for the image on the page'.Values: 0–500 (mm) |
FileNamestring | PDF name without extension; FileName=my-scan returned my-scan.pdf. |
StoreFileboolean, default false | Return a URL valid for 3 hours instead of the base64 PDF. |
What carries over, and what doesn't
Kept
- Every pixel: color and alpha pulled back out of the sample PDF match the TGA exactly
- Transparency, as an 8-bit soft mask next to the RGB image, so the shadow stays half-transparent
- Full resolution: the 256 × 256 image is embedded at 256 × 256 whatever the sheet
- The image's printed size on a larger sheet: on A5 the shield is still drawn 192 pt square, centered
Lost or not yet supported
- The TGA itself. The PDF stores its own deflate-compressed copy of the pixels (4,009 bytes for the sample on A5).
- Any resizing or color changes:
ImageWidth,ColorSpaceand other image options are not read on this route and are ignored. - Edge room unless you set margins. A 3000 × 3000 test texture fitted to A4 ran from the left edge to the right one;
MarginHorizontal=25andMarginVertical=25pulled it 70.87 pt in. - The TGA image ID and footer.
Limits
- One TGA per request, one page out.
- Images are never enlarged to fill a sheet, only shrunk when they are too big for it.
- Margins from 0 to 500 mm a side, and turns in whole degrees from -360 to 360.
- 100,000,000 pixels per image; requests up to 10 MB on the Free plan or 100 MB on paid plans.
- 120 seconds per conversion.
Where teams use it
Art review packets and style guides
Turn sprites or textures into PDF pages that anyone can open and annotate, with transparency kept so the art sits on the white page instead of a black box.
Printing a texture at a known size
With PageSize=a4 or letter the art is centered on a real sheet, ready for a printer, at 96 pixels per inch unless it has to shrink to fit.
Questions
How big is the page?
With no PageSize, one image pixel is 0.75 pt, the size it has at 96 pixels per inch. The 256 × 256 sample becomes a 192 × 192 pt page, 2.67 inches square.
Does the shadow print as gray or black?
As gray. Alpha is stored as a soft mask, so the shadow at alpha 112 lets the white page show through and prints as a mid gray, not solid black.
Why didn't ImageWidth make the image smaller?
This route doesn't read ImageWidth; it sizes the page from the pixels or from PageSize. To get a smaller image, resize first with /v2/convert/tga/to/png and ImageWidth, then convert that PNG.
Can I rotate the sprite on the page?
Yes, Rotate turns it clockwise about its center. A quarter turn of the 256 × 256 shield keeps the 192 pt square page, and other angles widen the page to the turned outline: 262.28 pt at 30 degrees. Fractions such as 12.5 are refused with a 400.
Can I put several TGAs into one PDF?
Not on this route, which takes one file. /v2/convert/images/to/pdf takes several images and gives each its own page.
Convert your first TGA file in a minute.