Skip to content
This repository was archived by the owner on Mar 4, 2025. It is now read-only.

Creating Lists in PDF with go-pdf Library #54

Open
nnzv opened this issue Oct 7, 2023 · 0 comments
Open

Creating Lists in PDF with go-pdf Library #54

nnzv opened this issue Oct 7, 2023 · 0 comments

Comments

@nnzv
Copy link

nnzv commented Oct 7, 2023

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:

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 up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant