To generate a full-height PDF in Go, set the page width and height explicitly when you add the page. With gofpdf, create a custom document, then call AddPageFormat with a SizeType containing your required width and height. A 3-by-12-inch receipt, for example, is a single portrait page—not an A4 document stretched after the fact.
The important distinction is whether you need one bounded, unusually tall page or a document whose content flows across normal pages. The first is straightforward with a native Go PDF API. The second is usually better handled by an HTML/CSS renderer with pagination rules.
Choose the kind of “full height” PDF you need
Before writing code, define the output shape:
- One tall page: a receipt, ticket, label, poster, or compact report with a known maximum height.
- Flowing content: an article, invoice, table, or report that can exceed one page and should continue onto additional pages.
- Web-template output: HTML and CSS already define the layout, typography, tables, and print styling.
A custom page height only defines the physical sheet. It does not automatically measure your content, remove margins, or prevent text from running beyond the bottom edge. You must calculate the available drawing area and choose wrapping or pagination behavior.
Native Go generation with gofpdf
A native API is the most predictable option for coordinate-driven layouts. You specify units, page dimensions, margins, fonts, and drawing operations directly, without starting a browser process.
The Tool Desk
Outbyte Driver Updater FREEFix the driver behind crashes, sound loss and screen glitchesFind Drivers →Outbyte PC Repair FREERepair Windows errors before they cause bigger problemsFix Now →#1 Best Overall
Install the package
Use the module path and version selected by your project. The constructor and font configuration can vary between package versions, so check the current package documentation when adapting the example.
go get github.com/go-pdf/fpdf
Complete 3-by-12-inch portrait example
This program creates one page that is 3 inches wide and 12 inches high. The 0.2-inch margins leave 2.6 inches of usable text width.
package main
import (
"log"
"github.com/go-pdf/fpdf"
)
func main() {
pdf := gofpdf.NewCustom(&gofpdf.InitType{
UnitStr: "in",
Size: gofpdf.SizeType{Wd: 3, Ht: 12},
FontDirStr: "",
})
pdf.SetMargins(0.2, 0.2, 0.2)
pdf.AddPageFormat("P", gofpdf.SizeType{Wd: 3, Ht: 12})
pdf.SetFont("Helvetica", "", 10)
text := "ReceiptnnItem A $12.00nItem B $8.50nnThank you for your purchase."
pdf.MultiCell(2.6, 0.18, text, "", "L", false)
if err := pdf.OutputFileAndClose("receipt.pdf"); err != nil {
log.Fatal(err)
}
}
NewCustom establishes the document’s unit system and default size. AddPageFormat then adds a page with the explicit orientation and dimensions. The go-pdf/fpdf documentation describes this method as adding a page with a non-default orientation or size.
Landscape and other dimensions
For a 12-by-3-inch landscape page, swap the dimensions and use landscape orientation:
Free tools Windows power users keep installed
One-click scans. No signup required.
pdf.AddPageFormat("L", gofpdf.SizeType{Wd: 12, Ht: 3})
The same pattern works with millimetres or points. Pick one unit system and convert every measurement before drawing; mixing pixels, inches, and millimetres is a common source of clipped or misaligned output.
Calculate usable space instead of guessing
Margins are part of the page geometry. If the page is 3 inches wide and both horizontal margins are 0.2 inches, usable width is:
usableWidth = pageWidth - leftMargin - rightMargin
// 3.0 - 0.2 - 0.2 = 2.6 inches
The same calculation applies vertically. For a 12-inch page with 0.2-inch top and bottom margins, only 11.6 inches are available for content. Keep a running Y position when placing blocks, and compare the next block’s height with the remaining space. For text, use wrapping primitives such as MultiCell rather than a single-line cell; wrapped lines consume additional height.
Measure variable content
A fixed height is safe only when the content is bounded. If item names, notes, or descriptions can grow, estimate or measure each wrapped block before placing it. If the measured total exceeds the chosen height, choose one of these policies:
Do these 3 things before closing this tab:
1Scan for outdated or missing drivers - takes under a minute2Repair Windows errors before they cause bigger problems3Fix the driver behind crashes, sound loss and screen glitches- Increase the page height and regenerate.
- Reduce typography or spacing within an agreed minimum.
- Start a new page.
- Reject the request with a clear “content exceeds page” error.
Do not silently draw past the bottom edge: PDF viewers may show clipped content, and printers can trim it.
One tall page versus many pages
When a single page is appropriate
Use one explicit tall page when the physical artifact must remain continuous, such as a point-of-sale receipt or a narrow label. Native placement gives you deterministic coordinates and avoids browser pagination.
When flowing pages are better
For long reports or tables with unknown length, normal page flow is safer. A “full-height” request may actually mean “include all content,” not “make one infinitely tall sheet.” PDF viewers, printers, and downstream systems handle conventional page sizes more reliably.
HTML/CSS rendering with wkhtmltopdf wrappers
If your source is already HTML, an HTML/CSS renderer can preserve web typography, tables, and print styles. The Go wkhtmltopdf wrapper documents CSS print media types, millimetre units, page options, and typed controls for page size and margins. Its documentation notes that CSS print media and millimetres can produce accurate PDF layouts.
Outdated Drivers Are Slowing You Down
One free scan finds every outdated or missing driver and matches the right update for your exact hardware.Free scan · exact hardware matchPC Slower Than It Used to Be?
A free scan shows the junk files, broken settings and background clutter dragging Windows down - then fixes them in one click.Free scan · Windows 10 & 11Set custom dimensions
wkhtmltopdf exposes --page-height and --page-width for fine-grained dimensions. A Go wrapper typically maps these options to typed page settings. Set margins explicitly as well as width and height.
There is an important limitation: the renderer uses a model in which a long document is rendered and then cut into pages. A large height therefore does not guarantee one unbroken page for arbitrarily long content. If one physical page is mandatory, calculate a bounded height from the content or use a native API where you control all placements.
Use CSS print rules deliberately
- Use physical units such as
mmfor page geometry rather than screen pixels. - Define print-specific styles with
@media print. - Set page margins in the renderer and avoid competing CSS margins unless you have measured the result.
- Control table and block breaks so headings and rows are not stranded.
- Test with content at the upper bound, not only a short sample.
Native API or HTML/CSS: decision table
| Concern | Native Go API | HTML/CSS renderer |
|---|---|---|
| Page-size control | Direct width and height through SizeType and AddPageFormat. |
Width, height, and margins are renderer options such as --page-width and --page-height. |
| Text flow | You manage coordinates, wrapping, and overflow. | Browser-style layout flows content and may paginate it. |
| Runtime | Runs as Go code without a browser process. | Requires the wkhtmltopdf executable and its runtime environment. |
| Template compatibility | Best for receipts, labels, tickets, and drawings. | Best when the source is an existing HTML/CSS template. |
| Content beyond chosen height | You can measure, resize, reject, or add pages explicitly. | Long content can be cut into additional pages; a large height is not an infinite canvas. |
Implementation checklist
- Decide whether the result is one bounded tall page or a flowing multi-page document.
- Choose inches, millimetres, or points and convert all dimensions consistently.
- Set the custom width and height before adding content.
- Set all margins and calculate usable width and height.
- Use wrapping primitives such as
MultiCellor an HTML layout engine. - Measure variable content and define an overflow policy.
- Generate the file, check the returned error, and inspect the PDF at its maximum expected content length.
Troubleshooting common failures
The output is A4 or Letter
Cause: the page was added with a default method or default size. Fix: call AddPageFormat with your explicit SizeType, and ensure the constructor’s unit and size match your calculations.
Rank #4
Content is clipped at the bottom
Cause: margins, line wrapping, or unmeasured blocks consumed more height than expected. Fix: subtract top and bottom margins, use wrapping methods, track the Y position, and either increase height or create another page.
Quick wins for a faster PC:
Scan for outdated or missing drivers - takes under a minuteDriver Scan →Clear out junk files and repair common Windows errorsFree Scan →Text runs outside the right edge
Cause: the cell width includes no allowance for margins or wrapping was not enabled. Fix: calculate usable width and use MultiCell or an equivalent layout primitive.
HTML output unexpectedly has several pages
Cause: the renderer paginates long content after layout. Fix: treat custom height as a bounded page setting, compute a height that fits the content, or switch to a native API for a guaranteed single page.
The generated file is empty or fails to open
Cause: the output error was ignored, the renderer executable is unavailable, or a font/resource path is invalid. Fix: handle the returned error, verify runtime dependencies, and use an absolute, readable font directory when the selected package requires one.
Independent reader supportYour contribution helps us test, update, and keep practical guides available for everyone.Performance, reliability, and cost considerations
No workload-specific benchmark establishes that either approach is faster. Native generation generally has fewer moving parts because it does not launch a browser process; HTML/CSS is often more convenient when a tested web template already exists. Reliability depends on your content: native code makes overflow decisions explicit, while HTML rendering can be affected by pagination and external resource loading. Keep fonts and assets available locally or through controlled paths, and test the exact dimensions in the PDF viewer and print workflow you will use.
What’s actually slowing this PC down?
Pick the symptom - the matching free tool is one click away.
Best Value
Or skip the browser setup
If your “PDF” source is a web page, ScreenshotNeo can return a PDF from one API request without you installing or driving a browser. It accepts the cookie or consent banner like a visitor, then removes more than 60 known consent platforms, newsletter popups, and chat widgets before capture; each cleanup step can be disabled. Bot checks, CAPTCHAs, blank pages, timeouts, failed loads, and cache hits are not billed, and the response identifies the result with X-Page-Verdict and X-Billed headers. An MCP server provides take_screenshot, get_page_info, and capture_pdf tools for Claude, Cursor, and other MCP clients.
See the ScreenshotNeo API documentation for options including PDF paper size, margins, landscape mode, page ranges, custom CSS and JavaScript, waits, headers, cookies, user agents, geolocation, caching, and asynchronous jobs.
cURL
curl -G "https://api.screenshotneo.com/v1/shot" -d access_key=YOUR_API_KEY --data-urlencode url=https://stripe.com -o shot.webp
Python
import requests
r = requests.get("https://api.screenshotneo.com/v1/shot", params={"access_key": "YOUR_API_KEY", "url": "https://stripe.com"}, timeout=90)
open("shot.webp", "wb").write(r.content)
Node.js
const q = new URLSearchParams({ access_key: 'YOUR_API_KEY', url: 'https://stripe.com' });
const res = await fetch(`https://api.screenshotneo.com/v1/shot?${q}`);
ScreenshotNeo includes 1,000 shots per month free with no card; paid plans start at $5 for 3,000 shots. Create a free ScreenshotNeo account.
Frequently Asked Questions
Can I make an infinitely tall PDF page?
No. A PDF page must have finite dimensions. For unbounded content, generate multiple pages or calculate a finite height after measuring the content.
Should I use inches or millimetres in Go?
Either works. Select one unit in the constructor and convert every page, margin, font, and spacing measurement into that unit.
Does a larger wkhtmltopdf page height force one page?
No. Long HTML can still be laid out and cut into multiple pages. A single page requires a bounded height that fits the content or a native placement API.
Quick Recap
Product prices and availability are accurate as of the date/time indicated and are subject to change. Any price and availability information displayed on Amazon at the time of purchase will apply.




