π A powerful Go web service that generates template-based PDF documents on-the-fly with multi-page support, custom page sizes, automatic page breaks, PDF merge capabilities, and HTML to PDF/Image conversion.
GoPdfSuit is a flexible web service built with Go and the Gin framework. It features a custom template-based PDF generator that creates professional documents from JSON templates, supporting multiple page sizes, automatic page breaks, PDF merging, form filling, tables, borders, checkboxes, font styling (bold, italic, underline), and custom layouts without external dependencies.
New Features: HTML to PDF and Image conversion using gochromedp with web interfaces and REST APIs.
- Go
1.20+(project currently targets Go 1.23) - gochromedp
1.0+(for HTML to PDF/Image conversion) - Dependencies: Automatically managed via Go modules
For HTML to PDF/Image conversion:
# Ubuntu/Debian
sudo apt-get install chromium-browser
# macOS (with Homebrew)
brew install chromium
# Windows - Download Chrome from: https://www.google.com/chrome/Note: gochromedp uses Chromium headless for HTML conversion, so Chrome/Chromium must be installed.
git clone https://github.com/chinmay-sawant/gopdfsuit.git
cd gopdfsuitgo mod download
# Build frontend (React/Vite)
cd frontend
npm install
npm run build
cd ..# From repository root
go run ./cmd/gopdfsuitπ Server listening on: http://localhost:8080
GoPdfSuit can be easily deployed using Docker for containerized environments.
- Docker installed on your system
You can customize the Docker build using environment variables:
# Set custom version
export VERSION=1.0.0
# Set custom Docker Hub username
export DOCKERUSERNAME=yourusername
# Build with custom settings
make dockerDefault values:
VERSION=1.0.0DOCKERUSERNAME=chinmaysawant
make docker- Build and run Docker containermake dockertag- Tag and push to Docker Hubmake build- Build Go applicationmake test- Run testsmake clean- Clean build artifactsmake run- Run application locallymake fmt- Format Go codemake vet- Run Go vetmake mod- Tidy Go modulesmake pull- Pull and run Docker image from Docker Hub
-
Clone the repository (if not already done):
git clone https://github.com/chinmay-sawant/gopdfsuit.git cd gopdfsuit -
Build the Docker image:
make docker # Or manually: # docker build -f dockerfolder/Dockerfile --build-arg VERSION=1.0.0 -t gopdfsuit:1.0.0 . # docker run -d -p 8080:8080 gopdfsuit:1.0.0
-
Access the application:
- Open your browser to
http://localhost:8080
- Open your browser to
GoPdfSuit provides multiple Dockerfile options for different gochromedp compatibility needs:
docker build -f dockerfolder/Dockerfile --build-arg VERSION=1.0.0 -t gopdfsuit:1.0.0 .If you encounter issues with gochromedp or Chromium installation:
- Ensure Chromium/Chrome is installed and accessible
- Try the Ubuntu-based build (Option 2) for better compatibility
- Use the modern build (Option 3) if you don't need specific Chromium versions
- Check the standard build (Option 1) which includes multiple fallback methods
The image is available on Docker Hub:
- Repository:
chinmaysawant/gopdfsuit(configurable viaDOCKERUSERNAME) - Latest Version:
chinmaysawant/gopdfsuit:latest
docker pull chinmaysawant/gopdfsuit:latest
docker run -d -p 8080:8080 chinmaysawant/gopdfsuit:latestmake pull make docker && make dockertag- Port: 8080 (configurable via
EXPOSEin Dockerfile) - Base Images:
Dockerfile: Alpine Linux (minimal, with gochromedp and Chromium)
- Multi-stage Build: Optimized for smaller final image size
- Included Files: Web assets, LICENSE, README, and sample templates
New Feature: Interactive web-based PDF viewer and template editor.
Endpoint: GET / (Root endpoint)
Query Parameters:
file(optional): JSON template filename to load automatically
Examples:
http://localhost:8080/
http://localhost:8080/?file=temp_multiplepage.json
New Feature: Visual drag-and-drop PDF template editor.
Endpoint: GET /editor
Query Parameters:
file(optional): JSON template filename to load automatically
Examples:
http://localhost:8080/editor
http://localhost:8080/editor?file=temp_multiplepage.json
Features:
- π¨ Drag-and-Drop Interface: Visual template building with drag-and-drop components
- π Real-time JSON Generation: Live JSON template generation as you build
- π§ Component Properties: Editable properties panel for each component
- π Live PDF Preview: Generate and preview PDFs instantly
- πΎ Template Loading: Load existing templates for editing
- π± Responsive Design: Works on desktop, tablet, and mobile devices
- π¨ Theme Support: Multiple gradient themes and dark/light mode
Endpoint: GET /api/v1/template-data
Query Parameters:
file(required): JSON template filename
Security Features:
- β Path Traversal Protection: Only filenames (no directories) allowed
- β
File Extension Validation: Only
.jsonfiles accepted - β JSON Validation: Template structure validation before serving
Example:
curl "http://localhost:8080/api/v1/template-data?file=temp_multiplepage.json"Endpoint: POST /api/v1/generate/template-pdf
Headers:
Content-Type: application/json
Request Body Structure:
{
"config": {
"pageBorder": "1:1:1:1",
"page": "A4",
"pageAlignment": 1
},
"title": {
"props": "font1:24:100:center:0:0:1:0",
"text": "Multi-Page Document Title"
},
"table": [
{
"maxcolumns": 4,
"rows": [
{
"row": [
{
"props": "font1:12:100:left:1:1:1:1",
"text": "Bold Field Name:"
},
{
"props": "font1:12:000:left:1:1:1:1",
"text": "Normal Field Value"
},
{
"props": "font1:12:010:left:1:1:1:1",
"text": "Italic Text"
},
{
"props": "font1:12:111:right:1:1:1:1",
"text": "Bold+Italic+Underline"
}
]
}
]
}
],
"footer": {
"font": "font1:10:001:center",
"text": "Multi-page Footer"
}
}Template Configuration Properties:
- config.pageBorder:
"left:right:top:bottom"- Border widths for page edges - config.page: Page size specification
"A4"- 8.27 Γ 11.69 inches (595 Γ 842 points) - Default"LETTER"- 8.5 Γ 11 inches (612 Γ 792 points)"LEGAL"- 8.5 Γ 14 inches (612 Γ 1008 points)"A3"- 11.69 Γ 16.54 inches (842 Γ 1191 points)"A5"- 5.83 Γ 8.27 inches (420 Γ 595 points)
- config.pageAlignment: Page orientation
1- Portrait (vertical) - Default2- Landscape (horizontal)
- config.watermark: (optional) Text rendered diagonally (bottom-left to top-right) in light gray across every page. Automatically sized proportionally to page size.
Template Properties Explained:
- props:
"fontname:fontsize:style:alignment:left:right:top:bottom"fontname: Font identifier (font1, font2, etc.)fontsize: Font size in pointsstyle: 3-digit style code for text formatting:- First digit (Bold):
1= bold,0= normal weight - Second digit (Italic):
1= italic,0= normal style - Third digit (Underline):
1= underlined,0= no underline - Examples:
000= Normal text100= Bold text010= Italic text001= Underlined text110= Bold + Italic101= Bold + Underlined011= Italic + Underlined111= Bold + Italic + Underlined
- First digit (Bold):
alignment: left, center, or rightleft:right:top:bottom: Border widths for cell edges
- chequebox: Boolean value for checkbox state (true = checked, false = unchecked)
Automatic Page Break Features:
- β Height Tracking: Monitors content height and automatically creates new pages
- β Page Size Aware: Respects selected page dimensions for break calculations
- β Border Preservation: Page borders are drawn on every new page
- β Content Continuity: Tables and content flow seamlessly across pages
- β Page Numbering: Automatic "Page X of Y" numbering in bottom right corner
Response:
- Content-Type:
application/pdf - File:
template-pdf-<timestamp>.pdf(auto-download)
New Feature: Combine multiple PDF files into a single document with drag-and-drop interface.
Endpoint: POST /api/v1/merge
Web Interface: GET /merge
Headers:
Content-Type: multipart/form-data
Form Data Parameters:
pdf(required): One or more PDF files to merge (repeatable)
Features:
- π― Drag & Drop Interface: Intuitive file upload with visual feedback
- π File Reordering: Drag files to change merge order before processing
- ποΈ Live Preview: Preview merged PDF with page navigation
- π± Responsive Design: Works on desktop, tablet, and mobile devices
- π¨ Theme Support: Multiple gradient themes and dark/light mode
Example:
curl -X POST "http://localhost:8080/api/v1/merge" \
-F "pdf=@file1.pdf" \
-F "pdf=@file2.pdf" \
-F "pdf=@file3.pdf" \
--output merged.pdfWeb Interface Access:
http://localhost:8080/merge
New Feature: Convert HTML content or web pages to PDF using gochromedp with full control over page settings.
Endpoint: GET /htmltopdf
API Endpoint: POST /api/v1/htmltopdf
Headers: Content-Type: application/json
Request Body:
{
"html": "<!DOCTYPE html><html><body><h1>Hello World</h1></body></html>",
"url": "https://example.com",
"page_size": "A4",
"orientation": "Portrait",
"margin_top": "10mm",
"margin_right": "10mm",
"margin_bottom": "10mm",
"margin_left": "10mm",
"dpi": 300,
"grayscale": false,
"low_quality": false
}Features:
- β HTML Content: Convert raw HTML strings to PDF
- β URL Conversion: Convert web pages directly to PDF
- β Page Control: Custom page sizes (A4, Letter, Legal, A3)
- β Orientation: Portrait and Landscape modes
- β Margins: Precise margin control
- β Quality: DPI settings for high-quality output
- β Color Modes: Grayscale and color options
- β File Size: Low quality option for smaller files
Web Interface Access:
http://localhost:8080/htmltopdf
New Feature: Convert HTML content or web pages to images (PNG, JPG, SVG) using gochromedp.
Endpoint: GET /htmltoimage
API Endpoint: POST /api/v1/htmltoimage
Headers: Content-Type: application/json
Request Body:
{
"html": "<!DOCTYPE html><html><body><h1>Hello World</h1></body></html>",
"url": "https://example.com",
"format": "png",
"width": 800,
"height": 600,
"quality": 94,
"zoom": 1.0,
"crop_width": 400,
"crop_height": 300,
"crop_x": 0,
"crop_y": 0
}Features:
- β Multiple Formats: PNG, JPG, SVG output
- β Dimensions: Custom width and height
- β Quality Control: 1-100 quality settings
- β Zoom: Scale content with zoom factor
- β Cropping: Precise image cropping options
- β Real-time Preview: Live HTML preview before conversion
Web Interface Access:
http://localhost:8080/htmltoimage
Endpoint: POST /api/v1/fill
Headers:
Content-Type: multipart/form-data
Form Data Parameters:
pdf(required): The source PDF filexfdf(required): The XFDF file with field data
Example:
curl -X POST "http://localhost:8080/api/v1/fill" \
-F "pdf=@patient.pdf" \
-F "xfdf=@patient.xfdf" \
--output filled.pdf-
PDF Viewer:
http://localhost:8080/ -
Template Editor:
http://localhost:8080/editor -
PDF Merger:
http://localhost:8080/merge -
PDF Filler:
http://localhost:8080/filler -
HTML to PDF Converter:
http://localhost:8080/htmltopdf -
HTML to Image Converter:
http://localhost:8080/htmltoimage
- Navigate to:
http://localhost:8080/?file=temp_multiplepage.json - The interface will automatically load and display the template
- Click "Generate PDF" to create a multi-page healthcare form
- Use the page navigation controls to browse through pages
- Download the PDF using the download button
curl -X POST "http://localhost:8080/api/v1/generate/template-pdf" \
-H "Content-Type: application/json" \
-d '{
"config": {
"pageBorder": "2:2:2:2",
"page": "LETTER",
"pageAlignment": 1
},
"title": {
"props": "font1:20:110:center:0:0:2:0",
"text": "Patient Encounter Form - Multi Page"
},
"table": [
{
"maxcolumns": 4,
"rows": [
{
"row": [
{
"props": "font1:12:100:left:1:0:1:1",
"text": "Patient Name:"
},
{
"props": "font1:12:000:left:0:1:1:1",
"text": "John Doe"
},
{
"props": "font1:12:100:left:1:0:1:1",
"text": "DOB:"
},
{
"props": "font1:12:010:left:0:1:1:1",
"text": "01/15/1980"
}
]
}
]
}
],
"footer": {
"font": "font1:10:001:center",
"text": "Confidential Medical Document - Auto Pagination"
}
}' \
--output patient-form-multipage.pdfimport requests
import json
url = "http://localhost:8080/api/v1/generate/template-pdf"
template = {
"config": {
"pageBorder": "1:1:1:1",
"page": "A4",
"pageAlignment": 2 # Landscape orientation
},
"title": {
"props": "font1:22:111:center:0:0:2:0",
"text": "Landscape Survey Form"
},
"table": [
{
"maxcolumns": 6, # More columns fit in landscape
"rows": [
{
"row": [
{
"props": "font1:14:100:left:1:1:1:1",
"text": "Question 1:"
},
{
"props": "font1:12:000:center:1:1:1:1",
"chequebox": True
},
{
"props": "font1:12:010:left:1:1:1:1",
"text": "Excellent"
},
{
"props": "font1:12:000:center:1:1:1:1",
"chequebox": False
},
{
"props": "font1:12:010:left:1:1:1:1",
"text": "Good"
},
{
"props": "font1:12:000:left:1:1:1:1",
"text": "Average"
}
]
}
]
}
],
"footer": {
"font": "font1:10:001:right",
"text": "Landscape Page Layout"
}
}
response = requests.post(url, json=template)
with open("survey-landscape.pdf", "wb") as f:
f.write(response.content){
"config": {
"pageBorder": "1:1:1:1",
"page": "LEGAL",
"pageAlignment": 1
},
"title": {
"props": "font1:18:100:center:0:0:1:0",
"text": "Large Multi-Page Document"
},
"table": [
{
"maxcolumns": 2,
"rows": [
// Add many rows here - system will automatically create new pages
{
"row": [
{
"props": "font1:12:100:left:1:1:1:1",
"text": "Section 1: Introduction"
},
{
"props": "font1:12:000:left:1:1:1:1",
"text": "This document demonstrates automatic page breaks..."
}
]
}
// ... more rows will automatically flow to new pages
]
}
],
"footer": {
"font": "font1:10:000:center",
"text": "Document continues across multiple pages automatically"
}
}- Navigate to:
http://localhost:8080/htmltopdf - Choose input type: HTML Content or URL
- Enter your HTML or paste a URL
- Configure PDF options (page size, margins, orientation)
- Click "Convert to PDF" to download
- Use "Preview HTML" to see how it will look before conversion
- Navigate to:
http://localhost:8080/htmltoimage - Choose input type: HTML Content or URL
- Enter your HTML or paste a URL
- Configure image options (format, dimensions, quality)
- Set cropping options if needed
- Click "Convert to Image" to download
- Use "Preview HTML" to preview before conversion
curl -X POST "http://localhost:8080/api/v1/htmltopdf" \
-H "Content-Type: application/json" \
-d '{
"html": "<!DOCTYPE html><html><head><title>Sample</title></head><body><h1>Hello World</h1><p>This is a sample PDF generated from HTML.</p></body></html>",
"page_size": "A4",
"orientation": "Portrait",
"margin_top": "20mm",
"margin_bottom": "20mm",
"margin_left": "15mm",
"margin_right": "15mm",
"dpi": 300
}' \
--output sample.pdfcurl -X POST "http://localhost:8080/api/v1/htmltoimage" \
-H "Content-Type: application/json" \
-d '{
"html": "<!DOCTYPE html><html><body style=\"background: linear-gradient(45deg, #ff6b6b, #4ecdc4); color: white; text-align: center; padding: 50px;\"><h1>Beautiful Image</h1><p>Generated from HTML content</p></body></html>",
"format": "png",
"width": 800,
"height": 600,
"quality": 95,
"zoom": 1.2
}' \
--output beautiful-image.pngimport requests
import json
url = "http://localhost:8080/api/v1/htmltopdf"
data = {
"url": "https://example.com",
"page_size": "A4",
"orientation": "Portrait",
"margin_top": "10mm",
"margin_right": "10mm",
"margin_bottom": "10mm",
"margin_left": "10mm",
"dpi": 300,
"grayscale": False
}
response = requests.post(url, json=data)
with open("website.pdf", "wb") as f:
f.write(response.content)| Feature | GoPdfSuit | UniPDF | Aspose.PDF | iText |
|---|---|---|---|---|
| π° Pricing | Free (MIT License) | $3,990/dev/year | $1,999/dev/year | $3,800/dev/year |
| π Performance | Ultra Fast (179Β΅s-1.7ms) | Moderate | Moderate | Moderate |
| π¦ Deployment | Microservice/Sidecar/Docker | Library Integration | Library Integration | Library Integration |
| π§ Memory Usage | In-Memory Processing | File-based | Mixed | Mixed |
| π§ Integration | REST API (Language Agnostic) | Go Library Only | .NET/Java/C++ | Java/.NET/Python |
| π Template Engine | JSON-based Templates | Code-based | Code-based | Code-based |
| π Web Interface | Built-in Viewer/Editor | None | None | None |
| π Form Filling | XFDF Support | β Full Support | β Full Support | β Full Support |
| π PDF Merge | Drag & Drop UI | β Programmatic | β Programmatic | β Programmatic |
| π HTML to PDF/Image | gochromedp (Chromium) | Requires UniHTML product | Requires Aspose.HTML product | Requires custom integration |
| π± Multi-page Support | Auto Page Breaks | β Manual Control | β Manual Control | β Manual Control |
| π¨ Styling | Font Styles + Borders | β Advanced | β Advanced | β Advanced |
| βοΈ Interactive Elements | Checkboxes | β Full Support | β Full Support | β Full Support |
| π Page Formats | A3, A4, A5, Letter, Legal | β All Formats | β All Formats | β All Formats |
| π Security | Basic Validation | β Advanced | β Enterprise | β Enterprise |
| π³ Docker Support | β Built-in (Multi-stage, Alpine-based) | β Not Applicable (Library) | β Not Applicable (Library) | β Not Applicable (Library) |
| π οΈ Maintenance | Single Binary | Library Updates | Library Updates | Library Updates |
GoPdfSuit Performance (temp_multiplepage.json - 2 pages):
[GIN] 2025/08/28 - 00:40:18 | 200 | 697.8Β΅s | POST "/api/v1/generate/template-pdf"
[GIN] 2025/08/28 - 00:40:55 | 200 | 1.7542ms | POST "/api/v1/generate/template-pdf"
[GIN] 2025/08/28 - 00:40:57 | 200 | 179.6Β΅s | POST "/api/v1/generate/template-pdf"
[GIN] 2025/08/28 - 00:40:58 | 200 | 573.7Β΅s | POST "/api/v1/generate/template-pdf"
Key Advantages:
- π Ultra Fast: Sub-millisecond to low-millisecond response times
- π° Cost Effective: MIT license vs $2k-$4k/developer/year
- π§ Easy Deployment: Microservice architecture vs library integration
- π Language Agnostic: REST API accessible from any programming language
- π¦ Zero Dependencies: Single binary deployment
π View Detailed Comparison β
- π― Template-based: JSON-driven PDF generation
- βοΈ Modern Web Interface: React-based SPA with real-time preview
- π PDF Merge: Combine multiple PDFs with drag-and-drop interface
- ποΈ Form Filling: AcroForm/XFDF support for filling PDF forms
- π HTML to PDF: Convert HTML content or web pages to PDF with gochromedp
- πΌοΈ HTML to Image: Convert HTML content or web pages to PNG/JPG/SVG with gochromedp
- π Tables & Forms: Support for complex table layouts with automatic page breaks
- βοΈ Checkboxes: Interactive checkbox elements
- π¨ Font Styling: Bold, italic, and underline text support
- π Multi-page Support: Automatic page breaks and multi-page documents
- π’ Page Numbering: Automatic page numbering in "Page X of Y" format
- π Custom Page Sizes: A4, Letter, Legal, A3, A5 support
- π Page Orientation: Portrait and landscape orientations
- π€ Flexible Typography: Custom fonts, sizes, and alignments
- π² Border Control: Granular border configuration
- π‘οΈ Diagonal Watermark: Optional per-template watermark text across all pages
- β‘ Fast: In-memory PDF generation with height tracking
- π¦ Self-contained: Single binary deployment
- π Cross-platform: Runs on Windows, Linux, macOS
- π± Responsive: Mobile-friendly React interface with modern design
- π Secure: Path traversal protection and input validation
- π Fast: Vite-powered frontend with optimized builds
GoPdfSuit/
βββ π cmd/
β βββ π gopdfsuit/ # π― Application entrypoint
β βββ main.go
βββ π frontend/ # βοΈ React frontend (Vite)
β βββ src/
β β βββ π components/ # π§© React components
β β β βββ Navbar.jsx # π§ Navigation component
β β βββ π pages/ # π Page components
β β β βββ Home.jsx # οΏ½ Homepage with README content
β β β βββ Viewer.jsx # ποΈ PDF viewer and template processor
β β β βββ Editor.jsx # βοΈ PDF template editor
β β β βββ Merge.jsx # π PDF merge tool
β β β βββ Filler.jsx # π PDF form filler
β β β βββ HtmlToPdf.jsx # π HTML to PDF converter
β β β βββ HtmlToImage.jsx # πΌοΈ HTML to Image converter
β β βββ App.jsx # βοΈ Main app component with routing
β β βββ main.jsx # π― React entry point
β β βββ index.css # π¨ Global styles
β βββ package.json # οΏ½ Frontend dependencies
β βββ vite.config.js # βοΈ Vite configuration
β βββ index.html # π HTML template
βββ π internal/
β βββ π handlers/ # π HTTP handlers and route registration
β β βββ handlers.go
β βββ π models/ # π Template data models
β β βββ models.go
β βββ π pdf/ # π PDF generation and processing
β βββ pdf.go # π HTML to PDF/Image conversion
β βββ draw.go # π¨ Drawing utilities
β βββ generator.go # βοΈ PDF generation orchestration
β βββ merge.go # π PDF merging
β βββ pagemanager.go # π Page management
β βββ types.go # π Page size definitions
β βββ utils.go # π οΈ Helper utilities
β βββ xfdf.go # ποΈ XFDF form filling
β βββ xfdf_example_test.go # π§ͺ XFDF tests
βββ π docs/
β βββ π assets/ # ποΈ Built frontend assets (generated by Vite)
βββ π sampledata/ # π Sample data and templates
β βββ π encounter_1.7/ # π₯ Healthcare encounter samples
β β βββ us_encounter_form_data.xfdf
β β βββ us_encounter_form.pdf
β βββ π json/ # π JSON template samples
β β βββ temp_bold+italic+underline.json
β β βββ temp_multiplepage.json
β β βββ temp_og.json
β β βββ temp.json
β βββ π patient2/ # π€ Patient data samples
β β βββ filled.pdf
β β βββ jefferson_filled.pdf
β β βββ patient2_chatgpt.xfdf
β βββ π patientreg/ # π Patient registration samples
β β βββ patientreg_filled.pdf
β β βββ patientreg.pdf
β β βββ patientreg.xfdf
β βββ π pdf+xfdf/ # π PDF and XFDF sample pairs
β βββ us_hospital_encounter_acroform.pdf
β βββ us_hospital_encounter_data.xfdf
βββ π scripts/ # π οΈ Utility scripts
β βββ add_dummy_values.go # π Add dummy data script
β βββ flatten_pdf.go # π PDF flattening script
β βββ flatten_pdf.py # π Python PDF flattening script
β βββ π __pycache__/ # π Python cache
βββ π tmp/ # ποΈ Temporary files
β βββ build-errors.log # π Build error logs
βββ π go.mod # π¦ Go modules file
βββ π go.sum # π¦ Go modules checksums
βββ π temp_multiplepage.json # π Example multi-page template
βββ π xfdf_debug.log # π XFDF debugging logs
βββ π gopdfsuit.exe # π Compiled Windows binary
βββ π .gitignore # π« Git ignore rules
βββ π README.md # π This documentation
This project includes a simple AcroForm/XFDF fill feature that accepts PDF bytes and XFDF (field data) and returns a filled PDF.
Endpoints and UI
POST /api/v1/fillβ accepts multipart/form-data with two file fields:pdf(the source PDF) andxfdf(the XFDF file). Returnsapplication/pdfwith the filled document as an attachment.GET /fillerβ simple web UI where users can upload a PDF and an XFDF file and download the filled PDF (uses the/api/v1/fillendpoint).
Quick curl example (multipart file upload):
curl -X POST "http://localhost:8080/api/v1/fill" \
-F "pdf=@patient.pdf;type=application/pdf" \
-F "xfdf=@patient.xfdf;type=application/xml" \
--output filled.pdfServer-run example (UI):
- Start server from repo root:
go run ./cmd/gopdfsuit- Open
http://localhost:8080/fillerin your browser and upload PDF + XFDF.
Behaviour and limitations
- The filler uses a best-effort, byte-oriented approach implemented in the
internal/pdfpackage: it parses XFDF, searches for AcroForm field names (heuristic/T (name)), and writes or inserts/V (value)tokens into the PDF bytes. - For many simple AcroForm PDFs this works and the code sets
/NeedAppearances truein the AcroForm so viewers regenerate appearances. - Limitations: PDFs using compressed object streams, indirect references for field values, non-literal strings, or requiring generated appearance streams (
/AP) may not render values correctly in all viewers. For robust, production-grade appearance updates, integrate a PDF library (e.g., pdfcpu or unidoc) to rebuild field appearance streams.
If you'd like, I can add a library-backed implementation that guarantees visual appearances across viewers.
- π₯οΈ Web-based PDF viewer and template editor
- π Multi-page document support with automatic page breaks
- π Security features (path traversal protection, input validation)
- π§ͺ Add comprehensive unit tests
- π¨ Support for colors and advanced styling
- π Image embedding support
- π³ Docker containerization
- π Metrics and health check endpoints
- π Authentication and rate limiting
- πΎ Template storage and management
- π§ Email delivery integration
- π Template editor with validation
- π Real-time collaborative editing
# Build for current platform
go build -o bin/gopdfsuit ./cmd/gopdfsuit
# Build for different platforms
GOOS=linux GOARCH=amd64 go build -o bin/gopdfsuit-linux ./cmd/gopdfsuit
GOOS=windows GOARCH=amd64 go build -o bin/gopdfsuit.exe ./cmd/gopdfsuit# Run all tests
go test ./...
# Run tests with coverage
go test -cover ./...Page Break Logic:
- The system tracks current Y position on each page
- When content would exceed page boundaries (considering margins), a new page is automatically created
- Each new page includes configured page borders
- Content flows seamlessly from one page to the next
Supported Page Sizes:
| Page Size | Dimensions (inches) | Dimensions (points) | Best For |
|---|---|---|---|
| A4 | 8.27 Γ 11.69 | 595 Γ 842 | International standard |
| Letter | 8.5 Γ 11 | 612 Γ 792 | US standard |
| Legal | 8.5 Γ 14 | 612 Γ 1008 | Legal documents |
| A3 | 11.69 Γ 16.54 | 842 Γ 1191 | Large format |
| A5 | 5.83 Γ 8.27 | 420 Γ 595 | Small format |
β οΈ Important: The current PDF generator creates basic layouts suitable for forms and simple documents.
For production environments, consider:
- Implementing comprehensive input validation
- Adding request size limits
- Setting up proper logging and monitoring
- Implementing caching for frequently used templates
- Adding support for custom fonts and advanced layouts
- π΄ Fork the repository
- π Create a feature branch (
git checkout -b feature/amazing-feature) - π« Commit your changes (
git commit -m 'Add amazing feature') - π€ Push to the branch (
git push origin feature/amazing-feature) - π Open a Pull Request
This project is licensed under the MIT License - see the LICENSE file for details.
Made with β€οΈ and β by Chinmay Sawant
β Star this repo if you find it helpful!