curl
curl --request POST \
--url https://api.iyzpdf.com/v1/convert/xml-to-html \
--header "X-API-Key: $IYZPDF_API_KEY" \
--header "Content-Type: application/json" \
--data '{
"xml": "<?xml version=\"1.0\" encoding=\"UTF-8\"?><invoice><number>INV-1001</number></invoice>",
"xslt": "<?xml version=\"1.0\" encoding=\"UTF-8\"?><xsl:stylesheet version=\"1.0\" xmlns:xsl=\"http://www.w3.org/1999/XSL/Transform\"><xsl:template match=\"/\"><html><body><h1><xsl:value-of select=\"invoice/number\" /></h1></body></html></xsl:template></xsl:stylesheet>"
}' \
--output invoice.htmlimport os
import requests
api_key = os.environ["IYZPDF_API_KEY"]
payload = {
"xml": "<?xml version="1.0" encoding="UTF-8"?><invoice><number>INV-1001</number></invoice>",
"xslt": "<?xml version="1.0" encoding="UTF-8"?><xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"><xsl:template match="/"><html><body><h1><xsl:value-of select="invoice/number" /></h1></body></html></xsl:template></xsl:stylesheet>",
}
response = requests.post(
"https://api.iyzpdf.com/v1/convert/xml-to-html",
headers={"X-API-Key": api_key},
json=payload,
timeout=60,
)
if not response.ok:
raise Exception(response.text)
with open("invoice.html", "w", encoding="utf-8") as output_file:
output_file.write(response.text)import { writeFile } from "node:fs/promises";
const apiKey = process.env.IYZPDF_API_KEY;
const response = await fetch("https://api.iyzpdf.com/v1/convert/xml-to-html", {
method: "POST",
headers: {
"X-API-Key": apiKey,
"Content-Type": "application/json"
},
body: JSON.stringify({
xml: "<?xml version=\"1.0\" encoding=\"UTF-8\"?><invoice><number>INV-1001</number></invoice>",
xslt: "<?xml version=\"1.0\" encoding=\"UTF-8\"?><xsl:stylesheet version=\"1.0\" xmlns:xsl=\"http://www.w3.org/1999/XSL/Transform\"><xsl:template match=\"/\"><html><body><h1><xsl:value-of select=\"invoice/number\" /></h1></body></html></xsl:template></xsl:stylesheet>"
})
});
if (!response.ok) {
throw new Error(await response.text());
}
await writeFile("invoice.html", await response.text());<?php
$apiKey = getenv('IYZPDF_API_KEY');
$payload = [
'xml' => '<?xml version="1.0" encoding="UTF-8"?><invoice><number>INV-1001</number></invoice>',
'xslt' => '<?xml version="1.0" encoding="UTF-8"?><xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"><xsl:template match="/"><html><body><h1><xsl:value-of select="invoice/number" /></h1></body></html></xsl:template></xsl:stylesheet>',
];
$ch = curl_init('https://api.iyzpdf.com/v1/convert/xml-to-html');
curl_setopt_array($ch, [
CURLOPT_POST => true,
CURLOPT_RETURNTRANSFER => true,
CURLOPT_HTTPHEADER => [
'X-API-Key: ' . $apiKey,
'Content-Type: application/json',
],
CURLOPT_POSTFIELDS => json_encode($payload),
]);
$html = curl_exec($ch);
$status = curl_getinfo($ch, CURLINFO_HTTP_CODE);
if ($html === false || $status !== 200) {
throw new RuntimeException('Request failed: ' . curl_error($ch) . PHP_EOL . $html);
}
file_put_contents('invoice.html', $html);
curl_close($ch);import java.net.URI;
import java.net.http.HttpClient;
import java.net.http.HttpRequest;
import java.net.http.HttpResponse;
import java.nio.file.Files;
import java.nio.file.Path;
public class XmlToHtmlExample {
public static void main(String[] args) throws Exception {
String apiKey = System.getenv("IYZPDF_API_KEY");
HttpClient client = HttpClient.newHttpClient();
String json = """
{
"xml": "<?xml version=\\"1.0\\" encoding=\\"UTF-8\\"?><invoice><number>INV-1001</number></invoice>",
"xslt": "<?xml version=\\"1.0\\" encoding=\\"UTF-8\\"?><xsl:stylesheet version=\\"1.0\\" xmlns:xsl=\\"http://www.w3.org/1999/XSL/Transform\\"><xsl:template match=\\"/\\"><html><body><h1><xsl:value-of select=\\"invoice/number\\" /></h1></body></html></xsl:template></xsl:stylesheet>"
}
""";
HttpRequest request = HttpRequest.newBuilder()
.uri(URI.create("https://api.iyzpdf.com/v1/convert/xml-to-html"))
.header("X-API-Key", apiKey)
.header("Content-Type", "application/json")
.POST(HttpRequest.BodyPublishers.ofString(json))
.build();
HttpResponse<String> response = client.send(request, HttpResponse.BodyHandlers.ofString());
if (response.statusCode() != 200) {
throw new RuntimeException("Request failed with status " + response.statusCode());
}
Files.writeString(Path.of("invoice.html"), response.body());
}
}using System.Net.Http.Json;
var apiKey = Environment.GetEnvironmentVariable("IYZPDF_API_KEY");
using var client = new HttpClient();
client.DefaultRequestHeaders.Add("X-API-Key", apiKey);
var payload = new
{
xml = "<?xml version=\"1.0\" encoding=\"UTF-8\"?><invoice><number>INV-1001</number></invoice>",
xslt = "<?xml version=\"1.0\" encoding=\"UTF-8\"?><xsl:stylesheet version=\"1.0\" xmlns:xsl=\"http://www.w3.org/1999/XSL/Transform\"><xsl:template match=\"/\"><html><body><h1><xsl:value-of select=\"invoice/number\" /></h1></body></html></xsl:template></xsl:stylesheet>"
};
using var response = await client.PostAsJsonAsync(
"https://api.iyzpdf.com/v1/convert/xml-to-html",
payload);
response.EnsureSuccessStatusCode();
var html = await response.Content.ReadAsStringAsync();
await File.WriteAllTextAsync("invoice.html", html);{
"fileName": "output.html",
"size": 4281,
"creditsUsed": 1,
"creditsRemaining": 49,
"contentType": "text/html; charset=utf-8"
}{
"error": {
"code": "INVALID_REQUEST",
"message": "The request payload is invalid or incomplete."
}
}{
"error": {
"code": "UNAUTHORIZED",
"message": "Missing or invalid API key."
}
}{
"error": {
"code": "INSUFFICIENT_CREDITS",
"message": "You need more credits to complete this request.",
"creditsRequired": 2,
"creditsBalance": 0,
"purchaseUrl": "https://iyzpdf.com/portal/credits"
}
}{
"error": {
"code": "FILE_TOO_LARGE",
"message": "The uploaded file or request body exceeds the allowed size limit."
}
}{
"error": {
"code": "UNSUPPORTED_MEDIA_TYPE",
"message": "The uploaded file type or content type is not supported."
}
}{
"error": {
"code": "RATE_LIMIT_EXCEEDED",
"message": "Too many requests. Please retry after the rate limit resets."
}
}{
"error": {
"code": "PROCESSING_FAILED",
"message": "The document could not be processed."
}
}Conversion
XML To HTML
Transform XML and XSLT into HTML.
POST
https://api.iyzpdf.com/v1
/
convert
/
xml-to-html
curl
curl --request POST \
--url https://api.iyzpdf.com/v1/convert/xml-to-html \
--header "X-API-Key: $IYZPDF_API_KEY" \
--header "Content-Type: application/json" \
--data '{
"xml": "<?xml version=\"1.0\" encoding=\"UTF-8\"?><invoice><number>INV-1001</number></invoice>",
"xslt": "<?xml version=\"1.0\" encoding=\"UTF-8\"?><xsl:stylesheet version=\"1.0\" xmlns:xsl=\"http://www.w3.org/1999/XSL/Transform\"><xsl:template match=\"/\"><html><body><h1><xsl:value-of select=\"invoice/number\" /></h1></body></html></xsl:template></xsl:stylesheet>"
}' \
--output invoice.htmlimport os
import requests
api_key = os.environ["IYZPDF_API_KEY"]
payload = {
"xml": "<?xml version="1.0" encoding="UTF-8"?><invoice><number>INV-1001</number></invoice>",
"xslt": "<?xml version="1.0" encoding="UTF-8"?><xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"><xsl:template match="/"><html><body><h1><xsl:value-of select="invoice/number" /></h1></body></html></xsl:template></xsl:stylesheet>",
}
response = requests.post(
"https://api.iyzpdf.com/v1/convert/xml-to-html",
headers={"X-API-Key": api_key},
json=payload,
timeout=60,
)
if not response.ok:
raise Exception(response.text)
with open("invoice.html", "w", encoding="utf-8") as output_file:
output_file.write(response.text)import { writeFile } from "node:fs/promises";
const apiKey = process.env.IYZPDF_API_KEY;
const response = await fetch("https://api.iyzpdf.com/v1/convert/xml-to-html", {
method: "POST",
headers: {
"X-API-Key": apiKey,
"Content-Type": "application/json"
},
body: JSON.stringify({
xml: "<?xml version=\"1.0\" encoding=\"UTF-8\"?><invoice><number>INV-1001</number></invoice>",
xslt: "<?xml version=\"1.0\" encoding=\"UTF-8\"?><xsl:stylesheet version=\"1.0\" xmlns:xsl=\"http://www.w3.org/1999/XSL/Transform\"><xsl:template match=\"/\"><html><body><h1><xsl:value-of select=\"invoice/number\" /></h1></body></html></xsl:template></xsl:stylesheet>"
})
});
if (!response.ok) {
throw new Error(await response.text());
}
await writeFile("invoice.html", await response.text());<?php
$apiKey = getenv('IYZPDF_API_KEY');
$payload = [
'xml' => '<?xml version="1.0" encoding="UTF-8"?><invoice><number>INV-1001</number></invoice>',
'xslt' => '<?xml version="1.0" encoding="UTF-8"?><xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"><xsl:template match="/"><html><body><h1><xsl:value-of select="invoice/number" /></h1></body></html></xsl:template></xsl:stylesheet>',
];
$ch = curl_init('https://api.iyzpdf.com/v1/convert/xml-to-html');
curl_setopt_array($ch, [
CURLOPT_POST => true,
CURLOPT_RETURNTRANSFER => true,
CURLOPT_HTTPHEADER => [
'X-API-Key: ' . $apiKey,
'Content-Type: application/json',
],
CURLOPT_POSTFIELDS => json_encode($payload),
]);
$html = curl_exec($ch);
$status = curl_getinfo($ch, CURLINFO_HTTP_CODE);
if ($html === false || $status !== 200) {
throw new RuntimeException('Request failed: ' . curl_error($ch) . PHP_EOL . $html);
}
file_put_contents('invoice.html', $html);
curl_close($ch);import java.net.URI;
import java.net.http.HttpClient;
import java.net.http.HttpRequest;
import java.net.http.HttpResponse;
import java.nio.file.Files;
import java.nio.file.Path;
public class XmlToHtmlExample {
public static void main(String[] args) throws Exception {
String apiKey = System.getenv("IYZPDF_API_KEY");
HttpClient client = HttpClient.newHttpClient();
String json = """
{
"xml": "<?xml version=\\"1.0\\" encoding=\\"UTF-8\\"?><invoice><number>INV-1001</number></invoice>",
"xslt": "<?xml version=\\"1.0\\" encoding=\\"UTF-8\\"?><xsl:stylesheet version=\\"1.0\\" xmlns:xsl=\\"http://www.w3.org/1999/XSL/Transform\\"><xsl:template match=\\"/\\"><html><body><h1><xsl:value-of select=\\"invoice/number\\" /></h1></body></html></xsl:template></xsl:stylesheet>"
}
""";
HttpRequest request = HttpRequest.newBuilder()
.uri(URI.create("https://api.iyzpdf.com/v1/convert/xml-to-html"))
.header("X-API-Key", apiKey)
.header("Content-Type", "application/json")
.POST(HttpRequest.BodyPublishers.ofString(json))
.build();
HttpResponse<String> response = client.send(request, HttpResponse.BodyHandlers.ofString());
if (response.statusCode() != 200) {
throw new RuntimeException("Request failed with status " + response.statusCode());
}
Files.writeString(Path.of("invoice.html"), response.body());
}
}using System.Net.Http.Json;
var apiKey = Environment.GetEnvironmentVariable("IYZPDF_API_KEY");
using var client = new HttpClient();
client.DefaultRequestHeaders.Add("X-API-Key", apiKey);
var payload = new
{
xml = "<?xml version=\"1.0\" encoding=\"UTF-8\"?><invoice><number>INV-1001</number></invoice>",
xslt = "<?xml version=\"1.0\" encoding=\"UTF-8\"?><xsl:stylesheet version=\"1.0\" xmlns:xsl=\"http://www.w3.org/1999/XSL/Transform\"><xsl:template match=\"/\"><html><body><h1><xsl:value-of select=\"invoice/number\" /></h1></body></html></xsl:template></xsl:stylesheet>"
};
using var response = await client.PostAsJsonAsync(
"https://api.iyzpdf.com/v1/convert/xml-to-html",
payload);
response.EnsureSuccessStatusCode();
var html = await response.Content.ReadAsStringAsync();
await File.WriteAllTextAsync("invoice.html", html);{
"fileName": "output.html",
"size": 4281,
"creditsUsed": 1,
"creditsRemaining": 49,
"contentType": "text/html; charset=utf-8"
}{
"error": {
"code": "INVALID_REQUEST",
"message": "The request payload is invalid or incomplete."
}
}{
"error": {
"code": "UNAUTHORIZED",
"message": "Missing or invalid API key."
}
}{
"error": {
"code": "INSUFFICIENT_CREDITS",
"message": "You need more credits to complete this request.",
"creditsRequired": 2,
"creditsBalance": 0,
"purchaseUrl": "https://iyzpdf.com/portal/credits"
}
}{
"error": {
"code": "FILE_TOO_LARGE",
"message": "The uploaded file or request body exceeds the allowed size limit."
}
}{
"error": {
"code": "UNSUPPORTED_MEDIA_TYPE",
"message": "The uploaded file type or content type is not supported."
}
}{
"error": {
"code": "RATE_LIMIT_EXCEEDED",
"message": "Too many requests. Please retry after the rate limit resets."
}
}{
"error": {
"code": "PROCESSING_FAILED",
"message": "The document could not be processed."
}
}Notes
- Credits:
1 - XML is limited to
5 MB - XSLT is limited to
1 MB - Invalid XML or XSLT returns a validation error
- The default attachment name is
output.html
Authorizations
Send your server-side API key in the X-API-Key header.