#recipe
Posts tagged "recipe"
Nov 12, 2026
How do I show "Page X of Y" in a gpdf footer?
Put document.PageNumberPlaceholder and TotalPagesPlaceholder inside one c.Text string. gpdf v1.0.14+ fills both in and keeps the line aligned.
recipetutorialtemplatesNov 10, 2026
How do I set a custom paper size in gpdf?
Build a document.Size in points — document.Mm(100).Resolve(0, 0) converts — and pass it to WithPageSize. Labels, receipts, JIS B5, and the traps.
recipetutorialtemplatesSep 2, 2026
How do I align a gpdf column to the right edge of a row?
Two things need to happen: a filler Col to push the column to the right edge, and template.AlignRight() on the text inside it. Here's the gpdf code.
recipetutorialtemplatesMay 16, 2026
How do I nest a Row inside a Col in gpdf?
You can't — ColBuilder has no Row method in gpdf. The 12-column grid is flat by design. Here are the three idioms that replace nested rows.
recipetutorialtemplatesMay 12, 2026
How do I make a table span multiple pages?
You don't do anything. Feed gpdf a table with more rows than fit, and it paginates the body and repeats the header on every page automatically.
recipetutorialtemplatesMay 11, 2026
How do I mix two fonts in the same paragraph in gpdf?
To mix fonts in one paragraph in gpdf, call c.RichText and set template.FontFamily on each span — c.Text only styles the whole string at once.
recipetutorialcjkMay 5, 2026
How do I scale an image proportionally to fit a column?
gpdf already does it. c.Image(bytes) fills the column width and preserves aspect ratio. Use FitWidth or FitHeight for explicit bounds, WithFitMode for the non-default behaviors.
recipetutorialMay 4, 2026
How do I create striped (zebra) table rows?
Pass template.TableStripe to a table call. gpdf paints the alternate body rows with the color you give it. No row-loop, no manual cell styling.
recipetutorialtemplatesApr 30, 2026
How do I add a custom TrueType font to gpdf?
Load TTF bytes, register with gpdf.WithFont, then reference the family name. Works for any TrueType — Inter, Roboto, icon fonts, brand fonts.
recipetutorialApr 28, 2026
How do I set column widths in a gpdf table?
Pass template.ColumnWidths(...) to c.Table. Values are percentages of the parent column's width. Sum to 100; trailing missing values auto-distribute.
recipetutorialApr 28, 2026
How do I embed a PNG with transparency in gpdf?
Pass the PNG bytes directly to c.Image. gpdf decodes the alpha channel into a PDF SMask so transparent backgrounds render correctly.
recipetutorialApr 23, 2026
How do I use bold and italic together in gpdf?
Bold and italic on the same span work via template.Bold() and template.Italic(). For TrueType fonts you must register all four variants or the BoldItalic lookup silently falls back to the base family.
recipetutorialApr 19, 2026
How do I use Source Han Sans JP with gpdf?
Register the TTF variant of Source Han Sans JP from Adobe's GitHub release with gpdf.WithFont. Seven weights, SIL OFL, same glyphs as Noto Sans JP.
recipecjktutorialApr 17, 2026
Why does my PDF show tofu boxes for Japanese?
Empty rectangles instead of Japanese characters mean your PDF couldn't find glyphs for those codepoints. Here are the four causes and the fixes.
recipetroubleshootingcjkApr 17, 2026
How do I use IPAex Gothic in gpdf?
Register ipaexg.ttf with gpdf.WithFont. IPAex Gothic ships a single Regular weight under the IPA Font License — bold emphasis has to be synthesized or paired.
recipecjktutorialApr 16, 2026
How does the 12-column grid work in gpdf?
gpdf's 12-column grid uses r.Col(span, fn) where span is 1–12. Column width is (span/12) of the row. No breakpoints, no gutters, predictable by design.
recipetutorialtemplatesApr 15, 2026
How do I embed a Japanese font in gpdf?
Register a Japanese TrueType font with gpdf.WithFont at document construction. Three lines, subset embedding happens automatically, no CGO.
recipecjktutorialApr 15, 2026
How do I use Noto Sans JP with gpdf?
Register the static NotoSansJP-Regular.ttf with gpdf.WithFont. Skip the variable font — gpdf's pure-Go parser does not read fvar tables. Subsetting lands around 30 KB.
recipecjktutorial