Request
curl -X POST https://api.iterationlayer.com/document-generation/v1/generate \
-H "Authorization: Bearer YOUR_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"format": "pdf",
"document": {
"metadata": {
"title": "The Golden Fork - Menu",
"author": "The Golden Fork"
},
"page": {
"size": { "preset": "A4" },
"margins": {
"top_in_pt": 72,
"right_in_pt": 72,
"bottom_in_pt": 72,
"left_in_pt": 72
}
},
"styles": {
"text": {
"font_family": "Helvetica",
"font_size_in_pt": 11.0,
"line_height": 1.5,
"color": "#333333"
},
"headline": {
"font_family": "Helvetica",
"font_size_in_pt": 24.0,
"color": "#111111",
"spacing_before_in_pt": 12.0,
"spacing_after_in_pt": 6.0,
"is_bold": true
},
"link": {
"color": "#0066CC",
"is_underlined": true
},
"list": {
"text_style": {
"font_family": "Helvetica",
"font_size_in_pt": 11.0,
"line_height": 1.5,
"color": "#333333"
},
"marker_color": "#333333",
"marker_gap_in_pt": 8.0
},
"table": {
"header": {
"background_color": "#333333",
"text_color": "#FFFFFF",
"font_size_in_pt": 11.0,
"is_bold": true
},
"body": {
"background_color": "#FFFFFF",
"text_color": "#333333",
"font_size_in_pt": 11.0
},
"border": {
"outer": {
"top": { "color": "#CCCCCC", "width_in_pt": 1.0 },
"right": { "color": "#CCCCCC", "width_in_pt": 1.0 },
"bottom": { "color": "#CCCCCC", "width_in_pt": 1.0 },
"left": { "color": "#CCCCCC", "width_in_pt": 1.0 }
},
"inner": {
"horizontal": { "color": "#EEEEEE", "width_in_pt": 0.5 },
"vertical": { "color": "#EEEEEE", "width_in_pt": 0.5 }
}
}
},
"grid": {
"background_color": "#FFFFFF",
"border_color": "#CCCCCC",
"border_width_in_pt": 0.0,
"gap_in_pt": 12.0
},
"separator": {
"color": "#CCCCCC",
"thickness_in_pt": 1.0,
"spacing_before_in_pt": 12.0,
"spacing_after_in_pt": 12.0
},
"image": {
"border_color": "#000000",
"border_width_in_pt": 0.0
}
},
"footer": [
{
"type": "paragraph",
"runs": [{
"text": "The Golden Fork · 88 Harbor Blvd, San Francisco, CA 94111 · thegoldenfork.com"
}]
}
],
"content": [
{ "type": "headline", "level": "h1", "text": "The Golden Fork" },
{ "type": "paragraph", "runs": [
{ "text": "Fresh, seasonal cuisine crafted with locally sourced ingredients. Please inform your server of any allergies or dietary restrictions." }
] },
{ "type": "separator" },
{ "type": "headline", "level": "h2", "text": "Appetizers" },
{
"type": "table",
"column_widths_in_percent": [30, 45, 25],
"header": {
"cells": [
{ "text": "Item" },
{ "text": "Description" },
{ "text": "Price", "horizontal_alignment": "right" }
]
},
"rows": [
{ "cells": [
{ "text": "Burrata Caprese" },
{ "text": "Heirloom tomatoes, fresh burrata, basil oil, aged balsamic" },
{ "text": "$16.00", "horizontal_alignment": "right" }
] },
{ "cells": [
{ "text": "Tuna Tartare" },
{ "text": "Sushi-grade ahi, avocado, sesame, crispy wonton chips" },
{ "text": "$19.00", "horizontal_alignment": "right" }
] },
{ "cells": [
{ "text": "French Onion Soup" },
{ "text": "Caramelized onion broth, Gruyère crouton" },
{ "text": "$14.00", "horizontal_alignment": "right" }
] }
]
},
{ "type": "separator" },
{ "type": "headline", "level": "h2", "text": "Main Courses" },
{
"type": "table",
"column_widths_in_percent": [30, 45, 25],
"header": {
"cells": [
{ "text": "Item" },
{ "text": "Description" },
{ "text": "Price", "horizontal_alignment": "right" }
]
},
"rows": [
{ "cells": [
{ "text": "Pan-Seared Salmon" },
{ "text": "Wild-caught salmon, lemon beurre blanc, roasted asparagus, fingerling potatoes" },
{ "text": "$34.00", "horizontal_alignment": "right" }
] },
{ "cells": [
{ "text": "Filet Mignon" },
{ "text": "8oz center-cut, truffle mash, grilled broccolini, red wine jus" },
{ "text": "$48.00", "horizontal_alignment": "right" }
] },
{ "cells": [
{ "text": "Wild Mushroom Risotto" },
{ "text": "Arborio rice, porcini, chanterelle, Parmigiano-Reggiano, truffle oil" },
{ "text": "$28.00", "horizontal_alignment": "right" }
] },
{ "cells": [
{ "text": "Roasted Half Chicken" },
{ "text": "Free-range chicken, herb jus, seasonal vegetables, garlic confit" },
{ "text": "$32.00", "horizontal_alignment": "right" }
] }
]
},
{ "type": "separator" },
{ "type": "paragraph", "runs": [
{ "text": "Prices exclude tax and gratuity. A 20% gratuity is added for parties of 6 or more." }
] }
]
}
}'Response
{
"success": true,
"data": {
"buffer": "JVBERi0xLjcKMSAwIG9iago8...",
"mime_type": "application/pdf"
}
}Request
import { IterationLayer } from "iterationlayer";
const client = new IterationLayer({ apiKey: "YOUR_API_KEY" });
const result = await client.generateDocument({
format: "pdf",
document: {
metadata: {
title: "The Golden Fork - Menu",
author: "The Golden Fork",
},
page: {
size: { preset: "A4" },
margins: {
top_in_pt: 72,
right_in_pt: 72,
bottom_in_pt: 72,
left_in_pt: 72,
},
},
styles: {
text: {
font_family: "Helvetica",
font_size_in_pt: 11.0,
line_height: 1.5,
color: "#333333",
},
headline: {
font_family: "Helvetica",
font_size_in_pt: 24.0,
color: "#111111",
spacing_before_in_pt: 12.0,
spacing_after_in_pt: 6.0,
is_bold: true,
},
link: {
color: "#0066CC",
is_underlined: true,
},
list: {
text_style: {
font_family: "Helvetica",
font_size_in_pt: 11.0,
line_height: 1.5,
color: "#333333",
},
marker_color: "#333333",
marker_gap_in_pt: 8.0,
},
table: {
header: {
background_color: "#333333",
text_color: "#FFFFFF",
font_size_in_pt: 11.0,
is_bold: true,
},
body: {
background_color: "#FFFFFF",
text_color: "#333333",
font_size_in_pt: 11.0,
},
border: {
outer: {
top: { color: "#CCCCCC", width_in_pt: 1.0 },
right: { color: "#CCCCCC", width_in_pt: 1.0 },
bottom: { color: "#CCCCCC", width_in_pt: 1.0 },
left: { color: "#CCCCCC", width_in_pt: 1.0 },
},
inner: {
horizontal: { color: "#EEEEEE", width_in_pt: 0.5 },
vertical: { color: "#EEEEEE", width_in_pt: 0.5 },
},
},
},
grid: {
background_color: "#FFFFFF",
border_color: "#CCCCCC",
border_width_in_pt: 0.0,
gap_in_pt: 12.0,
},
separator: {
color: "#CCCCCC",
thickness_in_pt: 1.0,
spacing_before_in_pt: 12.0,
spacing_after_in_pt: 12.0,
},
image: {
border_color: "#000000",
border_width_in_pt: 0.0,
},
},
footer: [
{
type: "paragraph",
runs: [{
text: "The Golden Fork · 88 Harbor Blvd, San Francisco, CA 94111 · thegoldenfork.com",
}],
},
],
content: [
{ type: "headline", level: "h1", text: "The Golden Fork" },
{ type: "paragraph", runs: [
{ text: "Fresh, seasonal cuisine crafted with locally sourced ingredients. Please inform your server of any allergies or dietary restrictions." },
] },
{ type: "separator" },
{ type: "headline", level: "h2", text: "Appetizers" },
{
type: "table",
column_widths_in_percent: [30, 45, 25],
header: {
cells: [
{ text: "Item" },
{ text: "Description" },
{ text: "Price", horizontal_alignment: "right" },
],
},
rows: [
{ cells: [
{ text: "Burrata Caprese" },
{ text: "Heirloom tomatoes, fresh burrata, basil oil, aged balsamic" },
{ text: "$16.00", horizontal_alignment: "right" },
] },
{ cells: [
{ text: "Tuna Tartare" },
{ text: "Sushi-grade ahi, avocado, sesame, crispy wonton chips" },
{ text: "$19.00", horizontal_alignment: "right" },
] },
{ cells: [
{ text: "French Onion Soup" },
{ text: "Caramelized onion broth, Gruyère crouton" },
{ text: "$14.00", horizontal_alignment: "right" },
] },
],
},
{ type: "separator" },
{ type: "headline", level: "h2", text: "Main Courses" },
{
type: "table",
column_widths_in_percent: [30, 45, 25],
header: {
cells: [
{ text: "Item" },
{ text: "Description" },
{ text: "Price", horizontal_alignment: "right" },
],
},
rows: [
{ cells: [
{ text: "Pan-Seared Salmon" },
{ text: "Wild-caught salmon, lemon beurre blanc, roasted asparagus, fingerling potatoes" },
{ text: "$34.00", horizontal_alignment: "right" },
] },
{ cells: [
{ text: "Filet Mignon" },
{ text: "8oz center-cut, truffle mash, grilled broccolini, red wine jus" },
{ text: "$48.00", horizontal_alignment: "right" },
] },
{ cells: [
{ text: "Wild Mushroom Risotto" },
{ text: "Arborio rice, porcini, chanterelle, Parmigiano-Reggiano, truffle oil" },
{ text: "$28.00", horizontal_alignment: "right" },
] },
{ cells: [
{ text: "Roasted Half Chicken" },
{ text: "Free-range chicken, herb jus, seasonal vegetables, garlic confit" },
{ text: "$32.00", horizontal_alignment: "right" },
] },
],
},
{ type: "separator" },
{ type: "paragraph", runs: [
{ text: "Prices exclude tax and gratuity. A 20% gratuity is added for parties of 6 or more." },
] },
],
},
});
await Bun.write("golden-fork-menu.pdf", Buffer.from(result.data.buffer, "base64"));Response
{
"success": true,
"data": {
"buffer": "JVBERi0xLjcKMSAwIG9iago8...",
"mime_type": "application/pdf"
}
}Request
import base64
from iterationlayer import IterationLayer
client = IterationLayer(api_key="YOUR_API_KEY")
result = client.generate_document(
format="pdf",
document={
"metadata": {
"title": "The Golden Fork - Menu",
"author": "The Golden Fork",
},
"page": {
"size": {"preset": "A4"},
"margins": {
"top_in_pt": 72,
"right_in_pt": 72,
"bottom_in_pt": 72,
"left_in_pt": 72,
},
},
"styles": {
"text": {
"font_family": "Helvetica",
"font_size_in_pt": 11.0,
"line_height": 1.5,
"color": "#333333",
},
"headline": {
"font_family": "Helvetica",
"font_size_in_pt": 24.0,
"color": "#111111",
"spacing_before_in_pt": 12.0,
"spacing_after_in_pt": 6.0,
"is_bold": True,
},
"link": {
"color": "#0066CC",
"is_underlined": True,
},
"list": {
"text_style": {
"font_family": "Helvetica",
"font_size_in_pt": 11.0,
"line_height": 1.5,
"color": "#333333",
},
"marker_color": "#333333",
"marker_gap_in_pt": 8.0,
},
"table": {
"header": {
"background_color": "#333333",
"text_color": "#FFFFFF",
"font_size_in_pt": 11.0,
"is_bold": True,
},
"body": {
"background_color": "#FFFFFF",
"text_color": "#333333",
"font_size_in_pt": 11.0,
},
"border": {
"outer": {
"top": {"color": "#CCCCCC", "width_in_pt": 1.0},
"right": {"color": "#CCCCCC", "width_in_pt": 1.0},
"bottom": {"color": "#CCCCCC", "width_in_pt": 1.0},
"left": {"color": "#CCCCCC", "width_in_pt": 1.0},
},
"inner": {
"horizontal": {"color": "#EEEEEE", "width_in_pt": 0.5},
"vertical": {"color": "#EEEEEE", "width_in_pt": 0.5},
},
},
},
"grid": {
"background_color": "#FFFFFF",
"border_color": "#CCCCCC",
"border_width_in_pt": 0.0,
"gap_in_pt": 12.0,
},
"separator": {
"color": "#CCCCCC",
"thickness_in_pt": 1.0,
"spacing_before_in_pt": 12.0,
"spacing_after_in_pt": 12.0,
},
"image": {
"border_color": "#000000",
"border_width_in_pt": 0.0,
},
},
"footer": [
{
"type": "paragraph",
"runs": [{
"text": "The Golden Fork · 88 Harbor Blvd, San Francisco, CA 94111 · thegoldenfork.com",
}],
},
],
"content": [
{"type": "headline", "level": "h1", "text": "The Golden Fork"},
{"type": "paragraph", "runs": [
{"text": "Fresh, seasonal cuisine crafted with locally sourced ingredients. Please inform your server of any allergies or dietary restrictions."},
]},
{"type": "separator"},
{"type": "headline", "level": "h2", "text": "Appetizers"},
{
"type": "table",
"column_widths_in_percent": [30, 45, 25],
"header": {
"cells": [
{"text": "Item"},
{"text": "Description"},
{"text": "Price", "horizontal_alignment": "right"},
],
},
"rows": [
{"cells": [
{"text": "Burrata Caprese"},
{"text": "Heirloom tomatoes, fresh burrata, basil oil, aged balsamic"},
{"text": "$16.00", "horizontal_alignment": "right"},
]},
{"cells": [
{"text": "Tuna Tartare"},
{"text": "Sushi-grade ahi, avocado, sesame, crispy wonton chips"},
{"text": "$19.00", "horizontal_alignment": "right"},
]},
{"cells": [
{"text": "French Onion Soup"},
{"text": "Caramelized onion broth, Gruyère crouton"},
{"text": "$14.00", "horizontal_alignment": "right"},
]},
],
},
{"type": "separator"},
{"type": "headline", "level": "h2", "text": "Main Courses"},
{
"type": "table",
"column_widths_in_percent": [30, 45, 25],
"header": {
"cells": [
{"text": "Item"},
{"text": "Description"},
{"text": "Price", "horizontal_alignment": "right"},
],
},
"rows": [
{"cells": [
{"text": "Pan-Seared Salmon"},
{"text": "Wild-caught salmon, lemon beurre blanc, roasted asparagus, fingerling potatoes"},
{"text": "$34.00", "horizontal_alignment": "right"},
]},
{"cells": [
{"text": "Filet Mignon"},
{"text": "8oz center-cut, truffle mash, grilled broccolini, red wine jus"},
{"text": "$48.00", "horizontal_alignment": "right"},
]},
{"cells": [
{"text": "Wild Mushroom Risotto"},
{"text": "Arborio rice, porcini, chanterelle, Parmigiano-Reggiano, truffle oil"},
{"text": "$28.00", "horizontal_alignment": "right"},
]},
{"cells": [
{"text": "Roasted Half Chicken"},
{"text": "Free-range chicken, herb jus, seasonal vegetables, garlic confit"},
{"text": "$32.00", "horizontal_alignment": "right"},
]},
],
},
{"type": "separator"},
{"type": "paragraph", "runs": [
{"text": "Prices exclude tax and gratuity. A 20% gratuity is added for parties of 6 or more."},
]},
],
},
)
with open("golden-fork-menu.pdf", "wb") as f:
f.write(base64.b64decode(result["data"]["buffer"]))Response
{
"success": true,
"data": {
"buffer": "JVBERi0xLjcKMSAwIG9iago8...",
"mime_type": "application/pdf"
}
}Request
package main
import (
"encoding/base64"
"os"
il "github.com/iterationlayer/sdk-go"
)
func main() {
client := il.NewClient("YOUR_API_KEY")
result, err := client.GenerateDocument(il.GenerateDocumentRequest{
Format: "pdf",
Document: il.DocumentDefinition{
Metadata: il.DocumentMetadata{
Title: "The Golden Fork - Menu",
Author: "The Golden Fork",
},
Page: il.PageConfig{
Size: il.PageSize{Preset: "A4"},
Margins: il.Margins{TopInPt: 72, RightInPt: 72, BottomInPt: 72, LeftInPt: 72},
},
Content: []il.ContentBlock{
il.NewHeadlineBlock("h1", "The Golden Fork"),
il.ParagraphBlock{Type: "paragraph", Markdown: "Fresh, seasonal cuisine crafted with locally sourced ingredients."},
il.NewSeparatorBlock(),
il.NewHeadlineBlock("h2", "Appetizers"),
il.NewTableBlock([]il.TableRow{
{Cells: []il.TableCell{{Text: "Burrata Caprese"}, {Text: "Heirloom tomatoes, fresh burrata, basil oil"}, {Text: "$16.00"}}},
{Cells: []il.TableCell{{Text: "Tuna Tartare"}, {Text: "Sushi-grade ahi, avocado, sesame"}, {Text: "$19.00"}}},
{Cells: []il.TableCell{{Text: "French Onion Soup"}, {Text: "Caramelized onion broth, Gruyère crouton"}, {Text: "$14.00"}}},
}),
il.NewSeparatorBlock(),
il.NewHeadlineBlock("h2", "Main Courses"),
il.NewTableBlock([]il.TableRow{
{Cells: []il.TableCell{{Text: "Pan-Seared Salmon"}, {Text: "Wild-caught salmon, lemon beurre blanc"}, {Text: "$34.00"}}},
{Cells: []il.TableCell{{Text: "Filet Mignon"}, {Text: "8oz center-cut, truffle mash, red wine jus"}, {Text: "$48.00"}}},
{Cells: []il.TableCell{{Text: "Wild Mushroom Risotto"}, {Text: "Arborio rice, porcini, chanterelle"}, {Text: "$28.00"}}},
{Cells: []il.TableCell{{Text: "Roasted Half Chicken"}, {Text: "Free-range chicken, herb jus"}, {Text: "$32.00"}}},
}),
il.NewSeparatorBlock(),
il.ParagraphBlock{Type: "paragraph", Markdown: "Prices exclude tax and gratuity."},
},
},
})
if err != nil {
panic(err)
}
decoded, _ := base64.StdEncoding.DecodeString(result.Data.Buffer)
os.WriteFile("golden-fork-menu.pdf", decoded, 0644)
}Response
{
"success": true,
"data": {
"buffer": "JVBERi0xLjcKMSAwIG9iago8...",
"mime_type": "application/pdf"
}
}