[{"data":1,"prerenderedAt":2132},["ShallowReactive",2],{"blog-en-align-column-right-edge":3},{"id":4,"title":5,"author":6,"body":10,"date":2096,"description":2097,"draft":2098,"extension":2099,"howTo":2100,"image":2122,"meta":2123,"navigation":264,"path":2124,"seo":2125,"stem":2126,"tags":2127,"updated":2122,"__hash__":2131},"blog/blog/028.align-column-right-edge.md","How do I align a gpdf column to the right edge of a row?",{"name":7,"url":8,"avatar":9},"Taiki Noda","https://nadai.dev/en/about","https://nadai.dev/og-default.png",{"type":11,"value":12,"toc":2085},"minimark",[13,18,35,39,67,240,244,247,1295,1299,1302,1313,1433,1488,1494,1501,1517,1521,1524,1615,1623,1644,1648,1651,1794,1813,1817,1820,1989,1992,2006,2010,2045,2049,2052,2069,2081],[14,15,17],"h2",{"id":16},"the-question-in-other-words","The question, in other words",[19,20,21,22,26,27,34],"p",{},"You wrote a row with a single ",[23,24,25],"code",{},"r.Col(4, ...)"," in it, expecting the column to land on the right side of the page. It rendered on the left, taking up a third of the width, with a big empty gap to its right. Or you got the column onto the right but the text inside it still hugs the left. What's the actual idiom in ",[28,29,33],"a",{"href":30,"rel":31},"https://github.com/gpdf-dev/gpdf",[32],"nofollow","gpdf","?",[14,36,38],{"id":37},"tldr","TL;DR",[19,40,41,42,45,46,49,50,53,54,66],{},"There is no ",[23,43,44],{},"Offset",", no ",[23,47,48],{},"Push",", and no row-level ",[23,51,52],{},"Justify"," in gpdf. ",[55,56,57,58,61,62,65],"strong",{},"You push a column right with an empty filler ",[23,59,60],{},"Col",", and you align the text inside it with ",[23,63,64],{},"template.AlignRight()","."," These are two different things and you almost always need both.",[68,69,74],"pre",{"className":70,"code":71,"language":72,"meta":73,"style":73},"language-go shiki shiki-themes material-theme-lighter material-theme material-theme-palenight","page.AutoRow(func(r *template.RowBuilder) {\n    r.Col(8, func(c *template.ColBuilder) {}) // filler\n    r.Col(4, func(c *template.ColBuilder) {\n        c.Text(\"Total: $25,575.00\", template.AlignRight())\n    })\n})\n","go","",[23,75,76,117,161,193,228,234],{"__ignoreMap":73},[77,78,81,85,88,92,95,99,102,106,108,111,114],"span",{"class":79,"line":80},"line",1,[77,82,84],{"class":83},"sTEyZ","page",[77,86,65],{"class":87},"sMK4o",[77,89,91],{"class":90},"s2Zo4","AutoRow",[77,93,94],{"class":87},"(func(",[77,96,98],{"class":97},"sHdIc","r",[77,100,101],{"class":87}," *",[77,103,105],{"class":104},"sBMFI","template",[77,107,65],{"class":87},[77,109,110],{"class":104},"RowBuilder",[77,112,113],{"class":87},")",[77,115,116],{"class":87}," {\n",[77,118,120,123,125,127,130,134,137,140,143,145,147,149,152,154,157],{"class":79,"line":119},2,[77,121,122],{"class":83},"    r",[77,124,65],{"class":87},[77,126,60],{"class":90},[77,128,129],{"class":87},"(",[77,131,133],{"class":132},"sbssI","8",[77,135,136],{"class":87},",",[77,138,139],{"class":87}," func(",[77,141,142],{"class":97},"c",[77,144,101],{"class":87},[77,146,105],{"class":104},[77,148,65],{"class":87},[77,150,151],{"class":104},"ColBuilder",[77,153,113],{"class":87},[77,155,156],{"class":87}," {})",[77,158,160],{"class":159},"sHwdD"," // filler\n",[77,162,164,166,168,170,172,175,177,179,181,183,185,187,189,191],{"class":79,"line":163},3,[77,165,122],{"class":83},[77,167,65],{"class":87},[77,169,60],{"class":90},[77,171,129],{"class":87},[77,173,174],{"class":132},"4",[77,176,136],{"class":87},[77,178,139],{"class":87},[77,180,142],{"class":97},[77,182,101],{"class":87},[77,184,105],{"class":104},[77,186,65],{"class":87},[77,188,151],{"class":104},[77,190,113],{"class":87},[77,192,116],{"class":87},[77,194,196,199,201,204,206,209,213,215,217,220,222,225],{"class":79,"line":195},4,[77,197,198],{"class":83},"        c",[77,200,65],{"class":87},[77,202,203],{"class":90},"Text",[77,205,129],{"class":87},[77,207,208],{"class":87},"\"",[77,210,212],{"class":211},"sfazB","Total: $25,575.00",[77,214,208],{"class":87},[77,216,136],{"class":87},[77,218,219],{"class":83}," template",[77,221,65],{"class":87},[77,223,224],{"class":90},"AlignRight",[77,226,227],{"class":87},"())\n",[77,229,231],{"class":79,"line":230},5,[77,232,233],{"class":87},"    })\n",[77,235,237],{"class":79,"line":236},6,[77,238,239],{"class":87},"})\n",[14,241,243],{"id":242},"the-code","The code",[19,245,246],{},"A complete program — the invoice-header shape that sends most people looking for this:",[68,248,250],{"className":70,"code":249,"language":72,"meta":73,"style":73},"package main\n\nimport (\n    \"log\"\n    \"os\"\n\n    \"github.com/gpdf-dev/gpdf/document\"\n    \"github.com/gpdf-dev/gpdf/pdf\"\n    \"github.com/gpdf-dev/gpdf/template\"\n)\n\nfunc main() {\n    doc := template.New(\n        template.WithPageSize(document.A4),\n        template.WithMargins(document.UniformEdges(document.Mm(20))),\n    )\n\n    page := doc.AddPage()\n\n    // Left block and right block in one row: 8 + 4 = 12.\n    page.AutoRow(func(r *template.RowBuilder) {\n        r.Col(8, func(c *template.ColBuilder) {\n            c.Text(\"Acme Inc.\", template.Bold(), template.FontSize(16))\n            c.Text(\"1-2-3 Shibuya, Tokyo\", template.TextColor(pdf.Gray(0.4)))\n        })\n        r.Col(4, func(c *template.ColBuilder) {\n            c.Text(\"INVOICE #1042\", template.AlignRight(), template.Bold())\n            c.Text(\"Issued 2026-09-02\", template.AlignRight(),\n                template.TextColor(pdf.Gray(0.4)))\n        })\n    })\n\n    page.AutoRow(func(r *template.RowBuilder) {\n        r.Col(12, func(c *template.ColBuilder) {\n            c.Spacer(document.Mm(10))\n        })\n    })\n\n    // Totals block: 8 spans of nothing, then 4 spans hard against the margin.\n    page.AutoRow(func(r *template.RowBuilder) {\n        r.Col(8, func(c *template.ColBuilder) {})\n        r.Col(4, func(c *template.ColBuilder) {\n            c.Text(\"Subtotal:    $23,250.00\", template.AlignRight())\n            c.Text(\"Tax (10%):    $2,325.00\", template.AlignRight())\n            c.Spacer(document.Mm(2))\n            c.Line(template.LineThickness(document.Pt(1)))\n            c.Spacer(document.Mm(2))\n            c.Text(\"Total:       $25,575.00\", template.AlignRight(),\n                template.Bold(), template.FontSize(14))\n        })\n    })\n\n    data, err := doc.Generate()\n    if err != nil {\n        log.Fatal(err)\n    }\n    if err := os.WriteFile(\"right_aligned.pdf\", data, 0o644); err != nil {\n        log.Fatal(err)\n    }\n}\n",[23,251,252,260,266,275,286,295,299,309,319,329,335,340,354,373,397,433,439,444,463,468,474,500,532,578,623,629,660,696,725,749,754,759,764,789,821,846,851,856,861,867,892,924,955,983,1011,1035,1070,1093,1121,1145,1150,1155,1160,1182,1198,1216,1222,1269,1284,1289],{"__ignoreMap":73},[77,253,254,257],{"class":79,"line":80},[77,255,256],{"class":87},"package",[77,258,259],{"class":104}," main\n",[77,261,262],{"class":79,"line":119},[77,263,265],{"emptyLinePlaceholder":264},true,"\n",[77,267,268,272],{"class":79,"line":163},[77,269,271],{"class":270},"s7zQu","import",[77,273,274],{"class":87}," (\n",[77,276,277,280,283],{"class":79,"line":195},[77,278,279],{"class":87},"    \"",[77,281,282],{"class":104},"log",[77,284,285],{"class":87},"\"\n",[77,287,288,290,293],{"class":79,"line":230},[77,289,279],{"class":87},[77,291,292],{"class":104},"os",[77,294,285],{"class":87},[77,296,297],{"class":79,"line":236},[77,298,265],{"emptyLinePlaceholder":264},[77,300,302,304,307],{"class":79,"line":301},7,[77,303,279],{"class":87},[77,305,306],{"class":104},"github.com/gpdf-dev/gpdf/document",[77,308,285],{"class":87},[77,310,312,314,317],{"class":79,"line":311},8,[77,313,279],{"class":87},[77,315,316],{"class":104},"github.com/gpdf-dev/gpdf/pdf",[77,318,285],{"class":87},[77,320,322,324,327],{"class":79,"line":321},9,[77,323,279],{"class":87},[77,325,326],{"class":104},"github.com/gpdf-dev/gpdf/template",[77,328,285],{"class":87},[77,330,332],{"class":79,"line":331},10,[77,333,334],{"class":87},")\n",[77,336,338],{"class":79,"line":337},11,[77,339,265],{"emptyLinePlaceholder":264},[77,341,343,346,349,352],{"class":79,"line":342},12,[77,344,345],{"class":87},"func",[77,347,348],{"class":90}," main",[77,350,351],{"class":87},"()",[77,353,116],{"class":87},[77,355,357,360,363,365,367,370],{"class":79,"line":356},13,[77,358,359],{"class":83},"    doc ",[77,361,362],{"class":87},":=",[77,364,219],{"class":83},[77,366,65],{"class":87},[77,368,369],{"class":90},"New",[77,371,372],{"class":87},"(\n",[77,374,376,379,381,384,386,389,391,394],{"class":79,"line":375},14,[77,377,378],{"class":83},"        template",[77,380,65],{"class":87},[77,382,383],{"class":90},"WithPageSize",[77,385,129],{"class":87},[77,387,388],{"class":83},"document",[77,390,65],{"class":87},[77,392,393],{"class":83},"A4",[77,395,396],{"class":87},"),\n",[77,398,400,402,404,407,409,411,413,416,418,420,422,425,427,430],{"class":79,"line":399},15,[77,401,378],{"class":83},[77,403,65],{"class":87},[77,405,406],{"class":90},"WithMargins",[77,408,129],{"class":87},[77,410,388],{"class":83},[77,412,65],{"class":87},[77,414,415],{"class":90},"UniformEdges",[77,417,129],{"class":87},[77,419,388],{"class":83},[77,421,65],{"class":87},[77,423,424],{"class":90},"Mm",[77,426,129],{"class":87},[77,428,429],{"class":132},"20",[77,431,432],{"class":87},"))),\n",[77,434,436],{"class":79,"line":435},16,[77,437,438],{"class":87},"    )\n",[77,440,442],{"class":79,"line":441},17,[77,443,265],{"emptyLinePlaceholder":264},[77,445,447,450,452,455,457,460],{"class":79,"line":446},18,[77,448,449],{"class":83},"    page ",[77,451,362],{"class":87},[77,453,454],{"class":83}," doc",[77,456,65],{"class":87},[77,458,459],{"class":90},"AddPage",[77,461,462],{"class":87},"()\n",[77,464,466],{"class":79,"line":465},19,[77,467,265],{"emptyLinePlaceholder":264},[77,469,471],{"class":79,"line":470},20,[77,472,473],{"class":159},"    // Left block and right block in one row: 8 + 4 = 12.\n",[77,475,477,480,482,484,486,488,490,492,494,496,498],{"class":79,"line":476},21,[77,478,479],{"class":83},"    page",[77,481,65],{"class":87},[77,483,91],{"class":90},[77,485,94],{"class":87},[77,487,98],{"class":97},[77,489,101],{"class":87},[77,491,105],{"class":104},[77,493,65],{"class":87},[77,495,110],{"class":104},[77,497,113],{"class":87},[77,499,116],{"class":87},[77,501,503,506,508,510,512,514,516,518,520,522,524,526,528,530],{"class":79,"line":502},22,[77,504,505],{"class":83},"        r",[77,507,65],{"class":87},[77,509,60],{"class":90},[77,511,129],{"class":87},[77,513,133],{"class":132},[77,515,136],{"class":87},[77,517,139],{"class":87},[77,519,142],{"class":97},[77,521,101],{"class":87},[77,523,105],{"class":104},[77,525,65],{"class":87},[77,527,151],{"class":104},[77,529,113],{"class":87},[77,531,116],{"class":87},[77,533,535,538,540,542,544,546,549,551,553,555,557,560,563,565,567,570,572,575],{"class":79,"line":534},23,[77,536,537],{"class":83},"            c",[77,539,65],{"class":87},[77,541,203],{"class":90},[77,543,129],{"class":87},[77,545,208],{"class":87},[77,547,548],{"class":211},"Acme Inc.",[77,550,208],{"class":87},[77,552,136],{"class":87},[77,554,219],{"class":83},[77,556,65],{"class":87},[77,558,559],{"class":90},"Bold",[77,561,562],{"class":87},"(),",[77,564,219],{"class":83},[77,566,65],{"class":87},[77,568,569],{"class":90},"FontSize",[77,571,129],{"class":87},[77,573,574],{"class":132},"16",[77,576,577],{"class":87},"))\n",[77,579,581,583,585,587,589,591,594,596,598,600,602,605,607,610,612,615,617,620],{"class":79,"line":580},24,[77,582,537],{"class":83},[77,584,65],{"class":87},[77,586,203],{"class":90},[77,588,129],{"class":87},[77,590,208],{"class":87},[77,592,593],{"class":211},"1-2-3 Shibuya, Tokyo",[77,595,208],{"class":87},[77,597,136],{"class":87},[77,599,219],{"class":83},[77,601,65],{"class":87},[77,603,604],{"class":90},"TextColor",[77,606,129],{"class":87},[77,608,609],{"class":83},"pdf",[77,611,65],{"class":87},[77,613,614],{"class":90},"Gray",[77,616,129],{"class":87},[77,618,619],{"class":132},"0.4",[77,621,622],{"class":87},")))\n",[77,624,626],{"class":79,"line":625},25,[77,627,628],{"class":87},"        })\n",[77,630,632,634,636,638,640,642,644,646,648,650,652,654,656,658],{"class":79,"line":631},26,[77,633,505],{"class":83},[77,635,65],{"class":87},[77,637,60],{"class":90},[77,639,129],{"class":87},[77,641,174],{"class":132},[77,643,136],{"class":87},[77,645,139],{"class":87},[77,647,142],{"class":97},[77,649,101],{"class":87},[77,651,105],{"class":104},[77,653,65],{"class":87},[77,655,151],{"class":104},[77,657,113],{"class":87},[77,659,116],{"class":87},[77,661,663,665,667,669,671,673,676,678,680,682,684,686,688,690,692,694],{"class":79,"line":662},27,[77,664,537],{"class":83},[77,666,65],{"class":87},[77,668,203],{"class":90},[77,670,129],{"class":87},[77,672,208],{"class":87},[77,674,675],{"class":211},"INVOICE #1042",[77,677,208],{"class":87},[77,679,136],{"class":87},[77,681,219],{"class":83},[77,683,65],{"class":87},[77,685,224],{"class":90},[77,687,562],{"class":87},[77,689,219],{"class":83},[77,691,65],{"class":87},[77,693,559],{"class":90},[77,695,227],{"class":87},[77,697,699,701,703,705,707,709,712,714,716,718,720,722],{"class":79,"line":698},28,[77,700,537],{"class":83},[77,702,65],{"class":87},[77,704,203],{"class":90},[77,706,129],{"class":87},[77,708,208],{"class":87},[77,710,711],{"class":211},"Issued 2026-09-02",[77,713,208],{"class":87},[77,715,136],{"class":87},[77,717,219],{"class":83},[77,719,65],{"class":87},[77,721,224],{"class":90},[77,723,724],{"class":87},"(),\n",[77,726,728,731,733,735,737,739,741,743,745,747],{"class":79,"line":727},29,[77,729,730],{"class":83},"                template",[77,732,65],{"class":87},[77,734,604],{"class":90},[77,736,129],{"class":87},[77,738,609],{"class":83},[77,740,65],{"class":87},[77,742,614],{"class":90},[77,744,129],{"class":87},[77,746,619],{"class":132},[77,748,622],{"class":87},[77,750,752],{"class":79,"line":751},30,[77,753,628],{"class":87},[77,755,757],{"class":79,"line":756},31,[77,758,233],{"class":87},[77,760,762],{"class":79,"line":761},32,[77,763,265],{"emptyLinePlaceholder":264},[77,765,767,769,771,773,775,777,779,781,783,785,787],{"class":79,"line":766},33,[77,768,479],{"class":83},[77,770,65],{"class":87},[77,772,91],{"class":90},[77,774,94],{"class":87},[77,776,98],{"class":97},[77,778,101],{"class":87},[77,780,105],{"class":104},[77,782,65],{"class":87},[77,784,110],{"class":104},[77,786,113],{"class":87},[77,788,116],{"class":87},[77,790,792,794,796,798,800,803,805,807,809,811,813,815,817,819],{"class":79,"line":791},34,[77,793,505],{"class":83},[77,795,65],{"class":87},[77,797,60],{"class":90},[77,799,129],{"class":87},[77,801,802],{"class":132},"12",[77,804,136],{"class":87},[77,806,139],{"class":87},[77,808,142],{"class":97},[77,810,101],{"class":87},[77,812,105],{"class":104},[77,814,65],{"class":87},[77,816,151],{"class":104},[77,818,113],{"class":87},[77,820,116],{"class":87},[77,822,824,826,828,831,833,835,837,839,841,844],{"class":79,"line":823},35,[77,825,537],{"class":83},[77,827,65],{"class":87},[77,829,830],{"class":90},"Spacer",[77,832,129],{"class":87},[77,834,388],{"class":83},[77,836,65],{"class":87},[77,838,424],{"class":90},[77,840,129],{"class":87},[77,842,843],{"class":132},"10",[77,845,577],{"class":87},[77,847,849],{"class":79,"line":848},36,[77,850,628],{"class":87},[77,852,854],{"class":79,"line":853},37,[77,855,233],{"class":87},[77,857,859],{"class":79,"line":858},38,[77,860,265],{"emptyLinePlaceholder":264},[77,862,864],{"class":79,"line":863},39,[77,865,866],{"class":159},"    // Totals block: 8 spans of nothing, then 4 spans hard against the margin.\n",[77,868,870,872,874,876,878,880,882,884,886,888,890],{"class":79,"line":869},40,[77,871,479],{"class":83},[77,873,65],{"class":87},[77,875,91],{"class":90},[77,877,94],{"class":87},[77,879,98],{"class":97},[77,881,101],{"class":87},[77,883,105],{"class":104},[77,885,65],{"class":87},[77,887,110],{"class":104},[77,889,113],{"class":87},[77,891,116],{"class":87},[77,893,895,897,899,901,903,905,907,909,911,913,915,917,919,921],{"class":79,"line":894},41,[77,896,505],{"class":83},[77,898,65],{"class":87},[77,900,60],{"class":90},[77,902,129],{"class":87},[77,904,133],{"class":132},[77,906,136],{"class":87},[77,908,139],{"class":87},[77,910,142],{"class":97},[77,912,101],{"class":87},[77,914,105],{"class":104},[77,916,65],{"class":87},[77,918,151],{"class":104},[77,920,113],{"class":87},[77,922,923],{"class":87}," {})\n",[77,925,927,929,931,933,935,937,939,941,943,945,947,949,951,953],{"class":79,"line":926},42,[77,928,505],{"class":83},[77,930,65],{"class":87},[77,932,60],{"class":90},[77,934,129],{"class":87},[77,936,174],{"class":132},[77,938,136],{"class":87},[77,940,139],{"class":87},[77,942,142],{"class":97},[77,944,101],{"class":87},[77,946,105],{"class":104},[77,948,65],{"class":87},[77,950,151],{"class":104},[77,952,113],{"class":87},[77,954,116],{"class":87},[77,956,958,960,962,964,966,968,971,973,975,977,979,981],{"class":79,"line":957},43,[77,959,537],{"class":83},[77,961,65],{"class":87},[77,963,203],{"class":90},[77,965,129],{"class":87},[77,967,208],{"class":87},[77,969,970],{"class":211},"Subtotal:    $23,250.00",[77,972,208],{"class":87},[77,974,136],{"class":87},[77,976,219],{"class":83},[77,978,65],{"class":87},[77,980,224],{"class":90},[77,982,227],{"class":87},[77,984,986,988,990,992,994,996,999,1001,1003,1005,1007,1009],{"class":79,"line":985},44,[77,987,537],{"class":83},[77,989,65],{"class":87},[77,991,203],{"class":90},[77,993,129],{"class":87},[77,995,208],{"class":87},[77,997,998],{"class":211},"Tax (10%):    $2,325.00",[77,1000,208],{"class":87},[77,1002,136],{"class":87},[77,1004,219],{"class":83},[77,1006,65],{"class":87},[77,1008,224],{"class":90},[77,1010,227],{"class":87},[77,1012,1014,1016,1018,1020,1022,1024,1026,1028,1030,1033],{"class":79,"line":1013},45,[77,1015,537],{"class":83},[77,1017,65],{"class":87},[77,1019,830],{"class":90},[77,1021,129],{"class":87},[77,1023,388],{"class":83},[77,1025,65],{"class":87},[77,1027,424],{"class":90},[77,1029,129],{"class":87},[77,1031,1032],{"class":132},"2",[77,1034,577],{"class":87},[77,1036,1038,1040,1042,1045,1047,1049,1051,1054,1056,1058,1060,1063,1065,1068],{"class":79,"line":1037},46,[77,1039,537],{"class":83},[77,1041,65],{"class":87},[77,1043,1044],{"class":90},"Line",[77,1046,129],{"class":87},[77,1048,105],{"class":83},[77,1050,65],{"class":87},[77,1052,1053],{"class":90},"LineThickness",[77,1055,129],{"class":87},[77,1057,388],{"class":83},[77,1059,65],{"class":87},[77,1061,1062],{"class":90},"Pt",[77,1064,129],{"class":87},[77,1066,1067],{"class":132},"1",[77,1069,622],{"class":87},[77,1071,1073,1075,1077,1079,1081,1083,1085,1087,1089,1091],{"class":79,"line":1072},47,[77,1074,537],{"class":83},[77,1076,65],{"class":87},[77,1078,830],{"class":90},[77,1080,129],{"class":87},[77,1082,388],{"class":83},[77,1084,65],{"class":87},[77,1086,424],{"class":90},[77,1088,129],{"class":87},[77,1090,1032],{"class":132},[77,1092,577],{"class":87},[77,1094,1096,1098,1100,1102,1104,1106,1109,1111,1113,1115,1117,1119],{"class":79,"line":1095},48,[77,1097,537],{"class":83},[77,1099,65],{"class":87},[77,1101,203],{"class":90},[77,1103,129],{"class":87},[77,1105,208],{"class":87},[77,1107,1108],{"class":211},"Total:       $25,575.00",[77,1110,208],{"class":87},[77,1112,136],{"class":87},[77,1114,219],{"class":83},[77,1116,65],{"class":87},[77,1118,224],{"class":90},[77,1120,724],{"class":87},[77,1122,1124,1126,1128,1130,1132,1134,1136,1138,1140,1143],{"class":79,"line":1123},49,[77,1125,730],{"class":83},[77,1127,65],{"class":87},[77,1129,559],{"class":90},[77,1131,562],{"class":87},[77,1133,219],{"class":83},[77,1135,65],{"class":87},[77,1137,569],{"class":90},[77,1139,129],{"class":87},[77,1141,1142],{"class":132},"14",[77,1144,577],{"class":87},[77,1146,1148],{"class":79,"line":1147},50,[77,1149,628],{"class":87},[77,1151,1153],{"class":79,"line":1152},51,[77,1154,233],{"class":87},[77,1156,1158],{"class":79,"line":1157},52,[77,1159,265],{"emptyLinePlaceholder":264},[77,1161,1163,1166,1168,1171,1173,1175,1177,1180],{"class":79,"line":1162},53,[77,1164,1165],{"class":83},"    data",[77,1167,136],{"class":87},[77,1169,1170],{"class":83}," err ",[77,1172,362],{"class":87},[77,1174,454],{"class":83},[77,1176,65],{"class":87},[77,1178,1179],{"class":90},"Generate",[77,1181,462],{"class":87},[77,1183,1185,1188,1190,1193,1196],{"class":79,"line":1184},54,[77,1186,1187],{"class":270},"    if",[77,1189,1170],{"class":83},[77,1191,1192],{"class":87},"!=",[77,1194,1195],{"class":87}," nil",[77,1197,116],{"class":87},[77,1199,1201,1204,1206,1209,1211,1214],{"class":79,"line":1200},55,[77,1202,1203],{"class":83},"        log",[77,1205,65],{"class":87},[77,1207,1208],{"class":90},"Fatal",[77,1210,129],{"class":87},[77,1212,1213],{"class":83},"err",[77,1215,334],{"class":87},[77,1217,1219],{"class":79,"line":1218},56,[77,1220,1221],{"class":87},"    }\n",[77,1223,1225,1227,1229,1231,1234,1236,1239,1241,1243,1246,1248,1250,1253,1255,1258,1261,1263,1265,1267],{"class":79,"line":1224},57,[77,1226,1187],{"class":270},[77,1228,1170],{"class":83},[77,1230,362],{"class":87},[77,1232,1233],{"class":83}," os",[77,1235,65],{"class":87},[77,1237,1238],{"class":90},"WriteFile",[77,1240,129],{"class":87},[77,1242,208],{"class":87},[77,1244,1245],{"class":211},"right_aligned.pdf",[77,1247,208],{"class":87},[77,1249,136],{"class":87},[77,1251,1252],{"class":83}," data",[77,1254,136],{"class":87},[77,1256,1257],{"class":132}," 0o644",[77,1259,1260],{"class":87},");",[77,1262,1170],{"class":83},[77,1264,1192],{"class":87},[77,1266,1195],{"class":87},[77,1268,116],{"class":87},[77,1270,1272,1274,1276,1278,1280,1282],{"class":79,"line":1271},58,[77,1273,1203],{"class":83},[77,1275,65],{"class":87},[77,1277,1208],{"class":90},[77,1279,129],{"class":87},[77,1281,1213],{"class":83},[77,1283,334],{"class":87},[77,1285,1287],{"class":79,"line":1286},59,[77,1288,1221],{"class":87},[77,1290,1292],{"class":79,"line":1291},60,[77,1293,1294],{"class":87},"}\n",[14,1296,1298],{"id":1297},"why-the-filler-column-is-required","Why the filler column is required",[19,1300,1301],{},"This is worth understanding rather than memorising, because it explains a handful of other gpdf layout surprises at the same time.",[19,1303,1304,1305,1308,1309,1312],{},"A row is a horizontal box. ",[23,1306,1307],{},"RowBuilder.build"," walks ",[23,1310,1311],{},"r.cols"," in order and emits one child box per column, and the only style it sets on that child is a width:",[68,1314,1316],{"className":70,"code":1315,"language":72,"meta":73,"style":73},"colBox := &document.Box{\n    Content: cb.buildNodes(),\n    BoxStyle: document.BoxStyle{\n        Width: document.Pct(float64(col.span) / float64(gridColumns) * 100),\n    },\n}\n",[23,1317,1318,1338,1356,1373,1424,1429],{"__ignoreMap":73},[77,1319,1320,1323,1325,1328,1330,1332,1335],{"class":79,"line":80},[77,1321,1322],{"class":83},"colBox ",[77,1324,362],{"class":87},[77,1326,1327],{"class":87}," &",[77,1329,388],{"class":104},[77,1331,65],{"class":87},[77,1333,1334],{"class":104},"Box",[77,1336,1337],{"class":87},"{\n",[77,1339,1340,1343,1346,1349,1351,1354],{"class":79,"line":119},[77,1341,1342],{"class":83},"    Content",[77,1344,1345],{"class":87},":",[77,1347,1348],{"class":83}," cb",[77,1350,65],{"class":87},[77,1352,1353],{"class":90},"buildNodes",[77,1355,724],{"class":87},[77,1357,1358,1361,1363,1366,1368,1371],{"class":79,"line":163},[77,1359,1360],{"class":83},"    BoxStyle",[77,1362,1345],{"class":87},[77,1364,1365],{"class":104}," document",[77,1367,65],{"class":87},[77,1369,1370],{"class":104},"BoxStyle",[77,1372,1337],{"class":87},[77,1374,1375,1378,1380,1382,1384,1387,1389,1393,1395,1398,1400,1402,1404,1407,1410,1412,1415,1417,1419,1422],{"class":79,"line":195},[77,1376,1377],{"class":83},"        Width",[77,1379,1345],{"class":87},[77,1381,1365],{"class":83},[77,1383,65],{"class":87},[77,1385,1386],{"class":90},"Pct",[77,1388,129],{"class":87},[77,1390,1392],{"class":1391},"spNyl","float64",[77,1394,129],{"class":87},[77,1396,1397],{"class":83},"col",[77,1399,65],{"class":87},[77,1401,77],{"class":83},[77,1403,113],{"class":87},[77,1405,1406],{"class":87}," /",[77,1408,1409],{"class":1391}," float64",[77,1411,129],{"class":87},[77,1413,1414],{"class":83},"gridColumns",[77,1416,113],{"class":87},[77,1418,101],{"class":87},[77,1420,1421],{"class":132}," 100",[77,1423,396],{"class":87},[77,1425,1426],{"class":79,"line":230},[77,1427,1428],{"class":87},"    },\n",[77,1430,1431],{"class":79,"line":236},[77,1432,1294],{"class":87},[19,1434,1435,1437,1438,1441,1442,1445,1446,1449,1450,1453,1454,1453,1457,1453,1460,1453,1463,1453,1466,1453,1469,1453,1472,1453,1475,1453,1478,1453,1481,1453,1484,1487],{},[23,1436,1414],{}," is 12. So ",[23,1439,1440],{},"Col(4)"," is literally \"a box that is 33.33% of the row's width\", nothing more. The row lays its children out left to right and stops when it runs out of children. It has no concept of the leftover space, because ",[23,1443,1444],{},"document.BoxStyle"," has no ",[23,1447,1448],{},"JustifyContent"," field — grep the whole repo and you will not find one. The fields are ",[23,1451,1452],{},"Width",", ",[23,1455,1456],{},"Height",[23,1458,1459],{},"MinWidth",[23,1461,1462],{},"MaxWidth",[23,1464,1465],{},"MinHeight",[23,1467,1468],{},"MaxHeight",[23,1470,1471],{},"Margin",[23,1473,1474],{},"Padding",[23,1476,1477],{},"Border",[23,1479,1480],{},"Background",[23,1482,1483],{},"Direction",[23,1485,1486],{},"Position",". That's the entire vocabulary.",[19,1489,1490,1491,1493],{},"So a lone ",[23,1492,1440],{}," produces a row containing exactly one 33.33%-wide box, positioned at the start of the horizontal flow. The remaining 66.67% isn't \"empty space to the right of your column\" — it's nothing at all. There is no element there to push against.",[19,1495,1496,1497,1500],{},"The filler ",[23,1498,1499],{},"Col(8)"," gives the layout engine something to occupy that space. It costs one empty box in the tree and renders nothing.",[19,1502,1503,1504,1506,1507,1510,1511,1510,1514,1516],{},"Which also means ",[23,1505,1499],{}," is not special. ",[23,1508,1509],{},"Col(6)"," + ",[23,1512,1513],{},"Col(3)",[23,1515,1513],{}," right-aligns the last block just as well, and you can hang content off the fillers later without restructuring anything.",[14,1518,1520],{"id":1519},"the-trap-right-column-left-text","The trap: right column, left text",[19,1522,1523],{},"The mistake that eats the most time:",[68,1525,1527],{"className":70,"code":1526,"language":72,"meta":73,"style":73},"r.Col(8, func(c *template.ColBuilder) {})\nr.Col(4, func(c *template.ColBuilder) {\n    c.Text(\"Total: $25,575.00\") // ← no AlignRight\n})\n",[23,1528,1529,1559,1589,1611],{"__ignoreMap":73},[77,1530,1531,1533,1535,1537,1539,1541,1543,1545,1547,1549,1551,1553,1555,1557],{"class":79,"line":80},[77,1532,98],{"class":83},[77,1534,65],{"class":87},[77,1536,60],{"class":90},[77,1538,129],{"class":87},[77,1540,133],{"class":132},[77,1542,136],{"class":87},[77,1544,139],{"class":87},[77,1546,142],{"class":97},[77,1548,101],{"class":87},[77,1550,105],{"class":104},[77,1552,65],{"class":87},[77,1554,151],{"class":104},[77,1556,113],{"class":87},[77,1558,923],{"class":87},[77,1560,1561,1563,1565,1567,1569,1571,1573,1575,1577,1579,1581,1583,1585,1587],{"class":79,"line":119},[77,1562,98],{"class":83},[77,1564,65],{"class":87},[77,1566,60],{"class":90},[77,1568,129],{"class":87},[77,1570,174],{"class":132},[77,1572,136],{"class":87},[77,1574,139],{"class":87},[77,1576,142],{"class":97},[77,1578,101],{"class":87},[77,1580,105],{"class":104},[77,1582,65],{"class":87},[77,1584,151],{"class":104},[77,1586,113],{"class":87},[77,1588,116],{"class":87},[77,1590,1591,1594,1596,1598,1600,1602,1604,1606,1608],{"class":79,"line":163},[77,1592,1593],{"class":83},"    c",[77,1595,65],{"class":87},[77,1597,203],{"class":90},[77,1599,129],{"class":87},[77,1601,208],{"class":87},[77,1603,212],{"class":211},[77,1605,208],{"class":87},[77,1607,113],{"class":87},[77,1609,1610],{"class":159}," // ← no AlignRight\n",[77,1612,1613],{"class":79,"line":195},[77,1614,239],{"class":87},[19,1616,1617,1618,1622],{},"The column is where you wanted it. The text is not. It starts at the column's left boundary — 66.67% across the page — so it looks ",[1619,1620,1621],"em",{},"sort of"," right-aligned, and if all your numbers happen to be the same width you may not notice until a three-digit total lands next to a five-digit one and the decimal points stop lining up.",[19,1624,1625,1627,1628,1631,1632,1635,1636,1639,1640,1643],{},[23,1626,64],{}," is a ",[23,1629,1630],{},"TextOption"," (",[23,1633,1634],{},"func(*document.Style)"," setting ",[23,1637,1638],{},"TextAlign","), so it goes on the individual ",[23,1641,1642],{},"c.Text"," call. There is no way to set it once for a whole column. Repeat it on every line in the block.",[14,1645,1647],{"id":1646},"tables-images-page-numbers","Tables, images, page numbers",[19,1649,1650],{},"Text options don't reach inside other elements. Each one has its own alignment door:",[68,1652,1654],{"className":70,"code":1653,"language":72,"meta":73,"style":73},"// Table: per-column alignment, positionally matched to the header slice.\nc.Table(header, rows, template.ColumnAlign(\n    document.AlignLeft, document.AlignRight, document.AlignRight,\n))\n\n// Image: alignment within its containing column.\nc.Image(logoBytes, template.WithAlign(document.AlignRight))\n\n// Page numbers take TextOptions, so AlignRight works directly.\nc.PageNumber(template.AlignRight())\n",[23,1655,1656,1661,1691,1720,1724,1728,1733,1766,1770,1775],{"__ignoreMap":73},[77,1657,1658],{"class":79,"line":80},[77,1659,1660],{"class":159},"// Table: per-column alignment, positionally matched to the header slice.\n",[77,1662,1663,1665,1667,1670,1672,1675,1677,1680,1682,1684,1686,1689],{"class":79,"line":119},[77,1664,142],{"class":83},[77,1666,65],{"class":87},[77,1668,1669],{"class":90},"Table",[77,1671,129],{"class":87},[77,1673,1674],{"class":83},"header",[77,1676,136],{"class":87},[77,1678,1679],{"class":83}," rows",[77,1681,136],{"class":87},[77,1683,219],{"class":83},[77,1685,65],{"class":87},[77,1687,1688],{"class":90},"ColumnAlign",[77,1690,372],{"class":87},[77,1692,1693,1696,1698,1701,1703,1705,1707,1709,1711,1713,1715,1717],{"class":79,"line":163},[77,1694,1695],{"class":83},"    document",[77,1697,65],{"class":87},[77,1699,1700],{"class":83},"AlignLeft",[77,1702,136],{"class":87},[77,1704,1365],{"class":83},[77,1706,65],{"class":87},[77,1708,224],{"class":83},[77,1710,136],{"class":87},[77,1712,1365],{"class":83},[77,1714,65],{"class":87},[77,1716,224],{"class":83},[77,1718,1719],{"class":87},",\n",[77,1721,1722],{"class":79,"line":195},[77,1723,577],{"class":87},[77,1725,1726],{"class":79,"line":230},[77,1727,265],{"emptyLinePlaceholder":264},[77,1729,1730],{"class":79,"line":236},[77,1731,1732],{"class":159},"// Image: alignment within its containing column.\n",[77,1734,1735,1737,1739,1742,1744,1747,1749,1751,1753,1756,1758,1760,1762,1764],{"class":79,"line":301},[77,1736,142],{"class":83},[77,1738,65],{"class":87},[77,1740,1741],{"class":90},"Image",[77,1743,129],{"class":87},[77,1745,1746],{"class":83},"logoBytes",[77,1748,136],{"class":87},[77,1750,219],{"class":83},[77,1752,65],{"class":87},[77,1754,1755],{"class":90},"WithAlign",[77,1757,129],{"class":87},[77,1759,388],{"class":83},[77,1761,65],{"class":87},[77,1763,224],{"class":83},[77,1765,577],{"class":87},[77,1767,1768],{"class":79,"line":311},[77,1769,265],{"emptyLinePlaceholder":264},[77,1771,1772],{"class":79,"line":321},[77,1773,1774],{"class":159},"// Page numbers take TextOptions, so AlignRight works directly.\n",[77,1776,1777,1779,1781,1784,1786,1788,1790,1792],{"class":79,"line":331},[77,1778,142],{"class":83},[77,1780,65],{"class":87},[77,1782,1783],{"class":90},"PageNumber",[77,1785,129],{"class":87},[77,1787,105],{"class":83},[77,1789,65],{"class":87},[77,1791,224],{"class":90},[77,1793,227],{"class":87},[19,1795,1796,1798,1799,1802,1803,1805,1806,1809,1810,1812],{},[23,1797,1688],{}," takes ",[23,1800,1801],{},"document.TextAlign"," values, not ",[23,1804,1630],{}," values — ",[23,1807,1808],{},"document.AlignRight",", not ",[23,1811,64],{},". Easy to mix up, and the compiler will tell you immediately.",[14,1814,1816],{"id":1815},"when-the-row-cant-help-you","When the row can't help you",[19,1818,1819],{},"For something pinned to a coordinate regardless of what else is on the page — a PAID stamp, a diagonal watermark, a corner mark — leave the grid:",[68,1821,1823],{"className":70,"code":1822,"language":72,"meta":73,"style":73},"page.Absolute(document.Mm(140), document.Mm(60),\n    func(c *template.ColBuilder) {\n        c.Text(\"PAID\", template.AlignRight(), template.Bold(),\n            template.FontSize(28), template.TextColor(pdf.RGBHex(0xC62828)))\n    },\n    template.AbsoluteWidth(document.Mm(50)),\n)\n",[23,1824,1825,1863,1882,1917,1955,1959,1985],{"__ignoreMap":73},[77,1826,1827,1829,1831,1834,1836,1838,1840,1842,1844,1847,1850,1852,1854,1856,1858,1861],{"class":79,"line":80},[77,1828,84],{"class":83},[77,1830,65],{"class":87},[77,1832,1833],{"class":90},"Absolute",[77,1835,129],{"class":87},[77,1837,388],{"class":83},[77,1839,65],{"class":87},[77,1841,424],{"class":90},[77,1843,129],{"class":87},[77,1845,1846],{"class":132},"140",[77,1848,1849],{"class":87},"),",[77,1851,1365],{"class":83},[77,1853,65],{"class":87},[77,1855,424],{"class":90},[77,1857,129],{"class":87},[77,1859,1860],{"class":132},"60",[77,1862,396],{"class":87},[77,1864,1865,1868,1870,1872,1874,1876,1878,1880],{"class":79,"line":119},[77,1866,1867],{"class":87},"    func(",[77,1869,142],{"class":97},[77,1871,101],{"class":87},[77,1873,105],{"class":104},[77,1875,65],{"class":87},[77,1877,151],{"class":104},[77,1879,113],{"class":87},[77,1881,116],{"class":87},[77,1883,1884,1886,1888,1890,1892,1894,1897,1899,1901,1903,1905,1907,1909,1911,1913,1915],{"class":79,"line":163},[77,1885,198],{"class":83},[77,1887,65],{"class":87},[77,1889,203],{"class":90},[77,1891,129],{"class":87},[77,1893,208],{"class":87},[77,1895,1896],{"class":211},"PAID",[77,1898,208],{"class":87},[77,1900,136],{"class":87},[77,1902,219],{"class":83},[77,1904,65],{"class":87},[77,1906,224],{"class":90},[77,1908,562],{"class":87},[77,1910,219],{"class":83},[77,1912,65],{"class":87},[77,1914,559],{"class":90},[77,1916,724],{"class":87},[77,1918,1919,1922,1924,1926,1928,1931,1933,1935,1937,1939,1941,1943,1945,1948,1950,1953],{"class":79,"line":195},[77,1920,1921],{"class":83},"            template",[77,1923,65],{"class":87},[77,1925,569],{"class":90},[77,1927,129],{"class":87},[77,1929,1930],{"class":132},"28",[77,1932,1849],{"class":87},[77,1934,219],{"class":83},[77,1936,65],{"class":87},[77,1938,604],{"class":90},[77,1940,129],{"class":87},[77,1942,609],{"class":83},[77,1944,65],{"class":87},[77,1946,1947],{"class":90},"RGBHex",[77,1949,129],{"class":87},[77,1951,1952],{"class":132},"0xC62828",[77,1954,622],{"class":87},[77,1956,1957],{"class":79,"line":230},[77,1958,1428],{"class":87},[77,1960,1961,1964,1966,1969,1971,1973,1975,1977,1979,1982],{"class":79,"line":236},[77,1962,1963],{"class":83},"    template",[77,1965,65],{"class":87},[77,1967,1968],{"class":90},"AbsoluteWidth",[77,1970,129],{"class":87},[77,1972,388],{"class":83},[77,1974,65],{"class":87},[77,1976,424],{"class":90},[77,1978,129],{"class":87},[77,1980,1981],{"class":132},"50",[77,1983,1984],{"class":87},")),\n",[77,1986,1987],{"class":79,"line":301},[77,1988,334],{"class":87},[19,1990,1991],{},"That's the escape hatch, not the idiom. If you find yourself computing x-coordinates for ordinary content, the filler column was the answer.",[19,1993,1994,1995,1997,1998,2001,2002,2005],{},"One last thing worth knowing: ",[23,1996,60],{}," clamps an individual span to 1–12, but nothing checks the ",[1619,1999,2000],{},"total",". Three ",[23,2003,2004],{},"Col(5)"," calls in one row give you percentage widths summing to 125%, and the third column overflows the right margin instead of wrapping. gpdf won't warn you. Count your spans.",[14,2007,2009],{"id":2008},"related-recipes","Related recipes",[2011,2012,2013,2021,2028,2038],"ul",{},[2014,2015,2016,2020],"li",{},[28,2017,2019],{"href":2018},"/blog/12-column-grid","How does the 12-column grid work in gpdf?"," — the grid in full",[2014,2022,2023,2027],{},[28,2024,2026],{"href":2025},"/blog/nest-row-in-col","How do I nest a Row inside a Col?"," — the other flat-grid question",[2014,2029,2030,2034,2035],{},[28,2031,2033],{"href":2032},"/blog/table-column-widths","How do I set column widths in a table?"," — widths and alignment inside ",[23,2036,2037],{},"c.Table",[2014,2039,2040,2044],{},[28,2041,2043],{"href":2042},"/blog/invoice-pdf-go-under-50-lines","Generate an invoice PDF in Go in under 50 lines"," — this pattern in a whole document",[14,2046,2048],{"id":2047},"try-gpdf","Try gpdf",[19,2050,2051],{},"gpdf is a Go library for generating PDFs. MIT licensed, zero external dependencies, native CJK support.",[68,2053,2057],{"className":2054,"code":2055,"language":2056,"meta":73,"style":73},"language-bash shiki shiki-themes material-theme-lighter material-theme material-theme-palenight","go get github.com/gpdf-dev/gpdf\n","bash",[23,2058,2059],{"__ignoreMap":73},[77,2060,2061,2063,2066],{"class":79,"line":80},[77,2062,72],{"class":104},[77,2064,2065],{"class":211}," get",[77,2067,2068],{"class":211}," github.com/gpdf-dev/gpdf\n",[19,2070,2071,2075,2076],{},[28,2072,2074],{"href":30,"rel":2073},[32],"⭐ Star on GitHub"," · ",[28,2077,2080],{"href":2078,"rel":2079},"https://gpdf.dev/docs/quickstart",[32],"Read the docs",[2082,2083,2084],"style",{},"html pre.shiki code .sTEyZ, html code.shiki .sTEyZ{--shiki-light:#90A4AE;--shiki-default:#EEFFFF;--shiki-dark:#BABED8}html pre.shiki code .sMK4o, html code.shiki .sMK4o{--shiki-light:#39ADB5;--shiki-default:#89DDFF;--shiki-dark:#89DDFF}html pre.shiki code .s2Zo4, html code.shiki .s2Zo4{--shiki-light:#6182B8;--shiki-default:#82AAFF;--shiki-dark:#82AAFF}html pre.shiki code .sHdIc, html code.shiki .sHdIc{--shiki-light:#90A4AE;--shiki-light-font-style:italic;--shiki-default:#EEFFFF;--shiki-default-font-style:italic;--shiki-dark:#BABED8;--shiki-dark-font-style:italic}html pre.shiki code .sBMFI, html code.shiki .sBMFI{--shiki-light:#E2931D;--shiki-default:#FFCB6B;--shiki-dark:#FFCB6B}html pre.shiki code .sbssI, html code.shiki .sbssI{--shiki-light:#F76D47;--shiki-default:#F78C6C;--shiki-dark:#F78C6C}html pre.shiki code .sHwdD, html code.shiki .sHwdD{--shiki-light:#90A4AE;--shiki-light-font-style:italic;--shiki-default:#546E7A;--shiki-default-font-style:italic;--shiki-dark:#676E95;--shiki-dark-font-style:italic}html pre.shiki code .sfazB, html code.shiki .sfazB{--shiki-light:#91B859;--shiki-default:#C3E88D;--shiki-dark:#C3E88D}html .light .shiki span {color: var(--shiki-light);background: var(--shiki-light-bg);font-style: var(--shiki-light-font-style);font-weight: var(--shiki-light-font-weight);text-decoration: var(--shiki-light-text-decoration);}html.light .shiki span {color: var(--shiki-light);background: var(--shiki-light-bg);font-style: var(--shiki-light-font-style);font-weight: var(--shiki-light-font-weight);text-decoration: var(--shiki-light-text-decoration);}html .default .shiki span {color: var(--shiki-default);background: var(--shiki-default-bg);font-style: var(--shiki-default-font-style);font-weight: var(--shiki-default-font-weight);text-decoration: var(--shiki-default-text-decoration);}html .shiki span {color: var(--shiki-default);background: var(--shiki-default-bg);font-style: var(--shiki-default-font-style);font-weight: var(--shiki-default-font-weight);text-decoration: var(--shiki-default-text-decoration);}html .dark .shiki span {color: var(--shiki-dark);background: var(--shiki-dark-bg);font-style: var(--shiki-dark-font-style);font-weight: var(--shiki-dark-font-weight);text-decoration: var(--shiki-dark-text-decoration);}html.dark .shiki span {color: var(--shiki-dark);background: var(--shiki-dark-bg);font-style: var(--shiki-dark-font-style);font-weight: var(--shiki-dark-font-weight);text-decoration: var(--shiki-dark-text-decoration);}html pre.shiki code .s7zQu, html code.shiki .s7zQu{--shiki-light:#39ADB5;--shiki-light-font-style:italic;--shiki-default:#89DDFF;--shiki-default-font-style:italic;--shiki-dark:#89DDFF;--shiki-dark-font-style:italic}html pre.shiki code .spNyl, html code.shiki .spNyl{--shiki-light:#9C3EDA;--shiki-default:#C792EA;--shiki-dark:#C792EA}",{"title":73,"searchDepth":119,"depth":119,"links":2086},[2087,2088,2089,2090,2091,2092,2093,2094,2095],{"id":16,"depth":119,"text":17},{"id":37,"depth":119,"text":38},{"id":242,"depth":119,"text":243},{"id":1297,"depth":119,"text":1298},{"id":1519,"depth":119,"text":1520},{"id":1646,"depth":119,"text":1647},{"id":1815,"depth":119,"text":1816},{"id":2008,"depth":119,"text":2009},{"id":2047,"depth":119,"text":2048},"2026-09-02","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.",false,"md",{"name":2101,"totalTime":2102,"tools":2103,"steps":2106},"Align a column to the right edge of a row in gpdf","PT10M",[2104,2105],"Go 1.22+","github.com/gpdf-dev/gpdf",[2107,2110,2113,2116,2119],{"name":2108,"text":2109},"Decide which right you mean","Positioning the column box at the right edge of the row and aligning the text inside that column are two separate problems with two separate fixes. Most layouts need both.",{"name":2111,"text":2112},"Add a filler Col so the spans sum to 12","Call r.Col with an empty callback before the column you want on the right. r.Col(8, func(c *template.ColBuilder) {}) followed by r.Col(4, ...) puts the 4-span column flush against the right margin.",{"name":2114,"text":2115},"Pass AlignRight to the text options","Add template.AlignRight() to every c.Text call inside that column. Without it the text sits at the left edge of a column that is itself on the right, which is the single most common mistake here.",{"name":2117,"text":2118},"Use the element-specific option for tables and images","Text alignment options do not reach into a Table or an Image. Use template.ColumnAlign(document.AlignRight) on a table and template.WithAlign(document.AlignRight) on an image.",{"name":2120,"text":2121},"Reach for page.Absolute only when the row cannot help","page.Absolute(x, y, fn, template.AbsoluteWidth(w)) places content at fixed coordinates outside the grid. Use it for stamps and watermarks, not for ordinary right-aligned content.",null,{},"/blog/align-column-right-edge",{"title":5,"description":2097},"blog/028.align-column-right-edge",[2128,2129,2130],"recipe","tutorial","templates","eGC51SF36wJTd7O16t6DBh-P5Mo5NclV0-Ycnt_jFXI",1788360635454]