unidoc / unipdf

Golang PDF library for creating and processing PDF files (pure go)
https://unidoc.io
Other
2.54k stars 250 forks source link

[FEATURE] Expose the "Bill to" string in invoice.go for customization #333

Closed lilith-writes-code closed 4 years ago

lilith-writes-code commented 4 years ago

Is your feature request related to a problem? Please describe. I'd like to change the "Bill to" string when using invoice.SetBuyerAddress(...) Currently it's a string buried in the implementation of invoice.generateInformationBlocks(...)

Describe the solution you'd like Any public method like, SetBuyerHeader or something that would let me set the string to be used.

gunnsth commented 4 years ago

Thanks for reporting, we will look into this as well as #332.

gunnsth commented 4 years ago

@venison please check PR #334 which addresses this.

adrg commented 4 years ago

Here's an example for setting the address heading:

invoice.SetBuyerAddress(&creator.InvoiceAddress{
    Heading:   "JANE L MILLER",
    Name:      "MILLER ASSOCIATES",
    Street:    "Suite #134569",
    Street2:   "1960 W CHELSEA AVE STE 2006R",
    City:      "ALLENTOWN",
    State:     "PA",
    Zip:       "18104",
    Separator: " ",
})

Also, added Street2 and State fields so it should address issue https://github.com/unidoc/unipdf/issues/332 as well. The Separator field is used to configure the separator between the address components (e.g. street, state, zip). By default, the separator is , in order to maintain backward compatibility.

Output invoice sample: invoice_simple.pdf.

lilith-writes-code commented 4 years ago

That looks great! Well done!