gofpdf - bold text between center aligned text

Viewed 495

I wanted to render text between center aligned text. This is what I tried

html := pdf.HTMLBasicNew()
_, lineHt := pdf.GetFontSize()
html.Write(lineHt, "<center>My name is <b>Bot<b></center>")

but only My name is is aligned to center instead of whole text My name is Bot

How can I achieve this with gofpdf or any other package in go to achieve this?

1 Answers

I created a simple program for pdf generation and inserted your code snippet into it , but I did not face the any issue ,whole text My name is Bot is aligned to center.Below is the code I have written:

package main

import (
    "github.com/jung-kurt/gofpdf"
)

func main() {
    pdf := gofpdf.New("P", "mm", "A4", "")
    pdf.AddPage()
    pdf.SetFont("Courier", "", 16)

    html := pdf.HTMLBasicNew()
    _, lineHt := pdf.GetFontSize()
    html.Write(lineHt, "<center>My name is <b>Bot<b></center>")
    err := pdf.OutputFileAndClose("myFile2.pdf")
    if err != nil {
        panic(err)
    }
}
Related