3
25
Fork
You've already forked fpdf
10

Creating Lists in PDF with go-pdf Library #54

Open
opened 2023年10月07日 12:26:29 +02:00 by nnzv · 0 comments
nnzv commented 2023年10月07日 12:26:29 +02:00 (Migrated from github.com)
Copy link

Hi,

I'm using the go-pdf library to make PDF files, and I want to know if it can make lists like bullet points or numbered lists in a simple way. Currently, I'm using this code:

packagemainimport("github.com/go-pdf/fpdf""log")funcmain(){pdf:=fpdf.New("P","mm","A4","")pdf.AddPage()pdf.SetFont("Arial","B",12)for_,i:=range[]string{"1","2","3"}{pdf.MultiCell(0,10,"- "+i,"","L",false)}err:=pdf.OutputFileAndClose("list.pdf")iferr!=nil{log.Fatal(err)}}

It generates a PDF that looks like this:

- 1
- 2
- 3

Is there an easier way to create lists in go-pdf? Since it's inspired by PHP fpdf, I referred to the official PHP example at http://www.fpdf.org/en/script/script56.php for list formatting. I aim to achieve a similar result where lists look standard, with proper spacing between items and aligned lines when they break.

Am I missing any information in go-pdf's documentation regarding list creation? Is there a specific function for this purpose?

Thanks.

Hi, I'm using the go-pdf library to make PDF files, and I want to know if it can make lists like bullet points or numbered lists in a simple way. Currently, I'm using this code: ```go package main import ( "github.com/go-pdf/fpdf" "log" ) func main() { pdf := fpdf.New("P", "mm", "A4", "") pdf.AddPage() pdf.SetFont("Arial", "B", 12) for _, i := range []string{"1","2","3"} { pdf.MultiCell(0, 10, "- "+i, "", "L", false) } err := pdf.OutputFileAndClose("list.pdf") if err != nil { log.Fatal(err) } } ``` It generates a PDF that looks like this: ``` - 1 - 2 - 3 ``` Is there an easier way to create lists in go-pdf? Since it's inspired by PHP fpdf, I referred to the official PHP example at http://www.fpdf.org/en/script/script56.php for list formatting. I aim to achieve a similar result where lists look standard, with proper spacing between items and aligned lines when they break. Am I missing any information in go-pdf's documentation regarding list creation? Is there a specific function for this purpose? Thanks.
Sign in to join this conversation.
No Branch/Tag specified
main
v0.12.0
v0.11.1
v0.10.0
v0.11.0
v0.9.0
v0.8.0
v0.7.0
v0.6.0
v0.5.0
v1.4.3
v0.4.1
v0.4.0
v0.3.1
v0.3.0
v0.2.0
v0.1.0
Milestone
Clear milestone
No items
No milestone
Projects
Clear projects
No items
No project
Assignees
Clear assignees
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
go-pdf/fpdf#54
Reference in a new issue
go-pdf/fpdf
No description provided.
Delete branch "%!s()"

Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?