# Welcome to Pogodoc (/docs) import { Card, Cards } from "fumadocs-ui/components/card"; import { Step, Steps } from "fumadocs-ui/components/steps";
Customer: {data.customerName}
| {item.name} | ${item.price} |
Amount: $<%= amount %>
Date: <%= date %>
"; var data = new DictionaryAmount: $<%= amount %>
Date: <%= date %>
` data := map[string]interface{}{ "customerName": "John Doe", "amount": 1299.99, "date": time.Now().Format("01/02/2006"), } result, err := client.GenerateDocument(pogodoc.GenerateDocumentProps{ Template: &template, InitializeRenderJobRequest: pogodoc.InitializeRenderJobRequest{ Data: data, Type: pogodoc.InitializeRenderJobRequestType("ejs"), Target: pogodoc.InitializeRenderJobRequestTarget("pdf"), }, }, ctx) if err != nil { log.Fatal(err) } // Get the URL to your generated PDF fmt.Printf("Document URL: %s\n", result.Output.Data.Url) } ```Amount: $<%= amount %>
Date: <%= date %>
'; $data = [ 'customerName' => 'John Doe', 'amount' => 1299.99, 'date' => date('m/d/Y'), ]; $response = $client->generateDocument([ 'template' => $template, 'data' => $data, 'renderConfig' => [ 'type' => 'ejs', 'target' => 'pdf', ] ]); // Get the URL to your generated PDF printf("Document URL: %s\n", $response->output->data->url); ```Amount: $<%= amount %>
Date: <%= date %>
''' data = { 'customerName': 'John Doe', 'amount': 1299.99, 'date': datetime.now().strftime('%m/%d/%Y'), } response = pogodoc.generate_document( template=template, data=data, render_config=RenderConfig( type='ejs', target='pdf', ) ) # Get the URL to your generated PDF print(f"Document URL: {response.output.data.url}") ```Amount: $<%= amount %>
Date: <%= date %>
`; const data = { customerName: 'John Doe', amount: 1299.99, date: new Date().toLocaleDateString(), }; const response = await pogodoc.generateDocument({ template, data, renderConfig: { type: 'ejs', target: 'pdf', }, }); // Get the URL to your generated PDF console.log('Document URL:', response.output?.data.url); ```<%= message %>
", data: { name: "World", message: "This is an inline template!" }, type: "ejs", target: "pdf", }); ``` This is great for: * Quick prototypes and testing * Simple, dynamic documents * One-off document generation * When you don't want to manage templates in the dashboard For production use, we recommend [saving templates](/docs/templates) in the dashboard for: * Reusability * Team collaboration * Visual editing *** ## Templates ### Is there a library of templates available? Yes! Pogodoc provides multiple ways to access templates: **1. Community Templates Library** Browse professionally designed templates in our [community library](https://app.pogodoc.com/templates): * Invoices, receipts, and financial documents * Social media graphics and marketing materials * Reports, certificates, and badges * Clone and customize any template **2. AI Template Generation** Use our AI chatbot to create custom templates: * Describe your needs in plain English * AI generates a complete template with sample data * Edit and refine using our visual editor * Save for future use **3. Upload Your Own** Create templates using any web technology: * HTML/CSS with EJS templating * React, Vue, Svelte, or any framework * Upload as a ZIP file * Full control over design and styling Learn more in our [Templates documentation](/docs/templates). ### What template formats are supported? Pogodoc supports multiple template formats: **HTML-Based Templates:** * **EJS** (Embedded JavaScript) - Simple, powerful templating with placeholders * **HTML** - Pure HTML with static data **JavaScript Frameworks:** * **React** - Build templates with React components * **Vue** - Use Vue components and composition API * **Svelte** - Compile-time templates with Svelte * any other framework **Framework-Agnostic:** Any web technology that compiles to HTML/CSS/JS works! Build with your preferred tools and upload the bundle. See our [Templates guide](/docs/templates) for detailed information and examples. ### Can I use custom fonts in my templates? Yes! You can use custom fonts in several ways: **1. Web Fonts (Google Fonts, etc.):** ```html ``` **2. Self-Hosted Fonts:** Include font files in your template ZIP: ```css @font-face { font-family: "CustomFont"; src: url("./fonts/custom.woff2") format("woff2"); } body { font-family: "CustomFont", sans-serif; } ``` **3. Base64 Embedded Fonts:** Embed font data directly in CSS (increases template size). **Best practices:** * Use common web fonts for faster rendering * Include fallback fonts: `font-family: 'CustomFont', Arial, sans-serif` * Optimize font files (use WOFF2 format) * Only include weights you actually use ### Can I use images in my templates? Absolutely! You can include images in multiple ways: **1. External URLs:** ```html
```
**2. Base64 Encoded:**
```html
```
**4. Dynamic from Data:**
```html
Your order #<%= orderId %> has been confirmed.
<% if (premium) { %>Thank you for being a premium member!
<% } %> ", data: new DictionaryYour order #<%= orderId %> has been confirmed.
<% if (premium) { %>Thank you for being a premium member!
<% } %> ` result, err := client.GenerateDocument(pogodoc.GenerateDocumentProps{ Template: &template, InitializeRenderJobRequest: pogodoc.InitializeRenderJobRequest{ Data: map[string]interface{}{ "name": "John Doe", "orderId": 12345, "premium": true, }, Type: pogodoc.InitializeRenderJobRequestType("ejs"), Target: pogodoc.InitializeRenderJobRequestTarget("pdf"), }, }, ctx) ``` ## Render Targets Generate documents in multiple output formats: | Target | Description | Use Cases | | --------- | ------------------------ | -------------------------------------- | | `pdf` | PDF documents | Invoices, reports, printable documents | | `png` | PNG images | Social media graphics, thumbnails | | `jpg` π§ | JPEG images | Compressed images for web | | `html` π§ | HTML output | Web previews, email content | | `docx` π§ | Word documents | Editable business documents | | `xlsx` π§ | Excel spreadsheets | Data reports, financial documents | | `pptx` π§ | PowerPoint presentations | Slides, presentations |Your order #<%= orderId %> has been confirmed.
<% if (premium) { %>Thank you for being a premium member!
<% } %> ', 'data' => [ 'name' => 'John Doe', 'orderId' => 12345, 'premium' => true, ], 'renderConfig' => [ 'type' => 'ejs', 'target' => 'pdf', ], ]); ``` ## Render Targets Generate documents in multiple output formats: | Target | Description | Use Cases | | --------- | ------------------------ | -------------------------------------- | | `pdf` | PDF documents | Invoices, reports, printable documents | | `png` | PNG images | Social media graphics, thumbnails | | `jpg` π§ | JPEG images | Compressed images for web | | `html` π§ | HTML output | Web previews, email content | | `docx` π§ | Word documents | Editable business documents | | `xlsx` π§ | Excel spreadsheets | Data reports, financial documents | | `pptx` π§ | PowerPoint presentations | Slides, presentations |Your order #<%= orderId %> has been confirmed.
<% if (premium) { %>Thank you for being a premium member!
<% } %> ''', data={ 'name': 'John Doe', 'orderId': 12345, 'premium': True, }, render_config=RenderConfig( type='ejs', target='pdf', ) ) ``` ## Render Targets Generate documents in multiple output formats: | Target | Description | Use Cases | | --------- | ------------------------ | -------------------------------------- | | `pdf` | PDF documents | Invoices, reports, printable documents | | `png` | PNG images | Social media graphics, thumbnails | | `jpg` π§ | JPEG images | Compressed images for web | | `html` π§ | HTML output | Web previews, email content | | `docx` π§ | Word documents | Editable business documents | | `xlsx` π§ | Excel spreadsheets | Data reports, financial documents | | `pptx` π§ | PowerPoint presentations | Slides, presentations |Your order #<%= orderId %> has been confirmed.
<% if (premium) { %>Thank you for being a premium member!
<% } %> `, data: { name: "John Doe", orderId: 12345, premium: true, }, renderConfig: { type: "ejs", target: "pdf", }, }); ``` ## Render Targets Generate documents in multiple output formats: | Target | Description | Use Cases | | --------- | ------------------------ | -------------------------------------- | | `pdf` | PDF documents | Invoices, reports, printable documents | | `png` | PNG images | Social media graphics, thumbnails | | `jpg` π§ | JPEG images | Compressed images for web | | `html` π§ | HTML output | Web previews, email content | | `docx` π§ | Word documents | Editable business documents | | `xlsx` π§ | Excel spreadsheets | Data reports, financial documents | | `pptx` π§ | PowerPoint presentations | Slides, presentations |{metric.value}
Thank you for being a premium member!
<% } %> ``` ### Plain HTML Templates Plain HTML with no templating logic, useful for static content: ```htmlThis certifies that the holder has completed the course.
``` *** ## Creating EJS TemplatesInvoice #<%= invoiceNumber %>
Date: <%= date %>
<%= customer.name %>
<%= customer.address %>
<%= customer.city %>, <%= customer.state %> <%= customer.zip %>
| Description | Quantity | Price | Total |
|---|---|---|---|
| <%= item.description %> | <%= item.quantity %> | $<%= item.price.toFixed(2) %> | $<%= (item.quantity * item.price).toFixed(2) %> |
| Subtotal: | $<%= subtotal.toFixed(2) %> | ||
| Tax (<%= taxRate %>%): | $<%= tax.toFixed(2) %> | ||
| Total: | $<%= total.toFixed(2) %> | ||
<%= storeAddress %>
Tel: <%= storePhone %>
Receipt #<%= receiptNumber %>
<%= date %> <%= time %>
This is to certify that
Awarded on <%= date %>
Certificate ID: <%= certificateId %>
<%= instructorName %>
Instructor
<%= organizationName %>
Organization
Premium member benefits
<% } else { %>Upgrade to premium
<% } %> ``` ### Loops ```htmlTotal: <%= formatPrice(total) %>
``` ### Comments ```html <%# This is a comment and won't appear in output %> ``` ## Best Practices ### 1. Use Inline Styles CSS classes may not work reliably in PDFs. Always use inline styles or `Customer: <%= customer.name %>
<% } %> ``` ### 5. Format Numbers Use JavaScript functions to format numbers properly: ```htmlPrice: $<%= price.toFixed(2) %>
Discount: <%= (discount * 100).toFixed(0) %>%
Total: $<%= total.toLocaleString('en-US', {minimumFractionDigits: 2}) %>
``` ### 6. Handle Arrays Safely Check if arrays exist and have items: ```html <% if (items && items.length > 0) { %>No items found.
<% } %> ``` ## Common Patterns ### Tables with Totals ```html| Item | Price |
|---|---|
| <%= item.name %> | $<%= item.price.toFixed(2) %> |
| Total: | $<%= total.toFixed(2) %> |
Date: <%= formattedDate %>
``` ### Multi-Page Documents ```htmlContent for first page
Content for second page
Content for last page
This certificate is awarded to
Presented this day