jung-kurt / gofpdf

A PDF document generator with high level support for text, drawing and images
http://godoc.org/github.com/jung-kurt/gofpdf
MIT License
4.31k stars 777 forks source link

Added full support for UTF-8 font. With MIT license. #246

Closed ArtemKor closed 5 years ago

ArtemKor commented 5 years ago

I am remastered the previous version. Removed all imports from tfpdf.php. Now we can keep the MIT license.

jung-kurt commented 5 years ago

Outstanding contribution, @ArtemKor! I will likely have questions over the next few days before I merge.

Many thanks for your excellent work and willingness to accommodate this project's license requirements.

jung-kurt commented 5 years ago

This is really an awesome contribution @ArtemKor.

Can you make a couple small changes for attribution? Please add a copyright/license prefix to utf8fontfile.go. You can use the one in htmlbasic.go as a template, but use the current year, your name and email address. Also, please place a comment next to the untypedKeyMap definition and its methods in util.go. Something like

The untypedKeyMap structure and its methods are copyrighted 2019 by <your-name-here>.

Many thanks!

Shareed2k commented 5 years ago

yo guys please merge this PR ;), i need to use this library for create reports in hebrew

jung-kurt commented 5 years ago

While this gets resolved, you can use https://github.com/ArtemKor/gofpdf

Shareed2k commented 5 years ago

While this gets resolved, you can use https://github.com/ArtemKor/gofpdf

i'm using go modules, i can't use it, it says

sh > go get github.com/ArtemKor/gofpdf@master

go: finding github.com/ArtemKor/gofpdf master
go: github.com/ArtemKor/gofpdf@v1.1.2-0.20190419140039-0d6a38d49d63: parsing go.mod: unexpected module path "github.com/jung-kurt/gofpdf"
go: error loading module requirements

sh > go get github.com/ArtemKor/gofpdf

go: github.com/ArtemKor/gofpdf@v1.1.1: parsing go.mod: unexpected module path "github.com/jung-kurt/gofpdf"
go: error loading module requirements
jung-kurt commented 5 years ago

i'm using go modules

Perfect! Clone the artemkor fork:

mkdir artmekor
cd artemkor
git clone https://github.com/ArtemKor/gofpdf.git
mkdir example
cd example

Create the following files. go.mod

module example

go 1.12

require github.com/jung-kurt/gofpdf v1.2.0

replace github.com/jung-kurt/gofpdf => ../gofpdf

example.go

package main

import (
  "fmt"
  "os"

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

func main() {
  pdf := gofpdf.New("P", "mm", "A4", "")
  pdf.AddPage()
  pdf.AddUTF8Font("dejavu", "", "../gofpdf/font/DejaVuSansCondensed.ttf")
  str := "לאכול קצת יותר אלה לחמניות צרפתית רכה לשתות תה"
  pdf.SetFont("dejavu", "", 17)
  pdf.SetXY(0, 100)
  pdf.CellFormat(210, 25, str, "", 0, "CM", false, 0, "")
  err := pdf.OutputFileAndClose("example.pdf")
  if err != nil {
    fmt.Fprintf(os.Stderr, "%s\n", err)
  }
}

Then build and run the executable:

go build -v
./example
Shareed2k commented 5 years ago

cool seem to be working, but its switch the string from rtl to ltr

Screen Shot 2019-05-02 at 14 17 43 Screen Shot 2019-05-02 at 14 27 58
jung-kurt commented 5 years ago

Hmm -- I would suggest opening an issue at github.com/ArtemKor/gofpdf but I don't see where that can be done. Is it just a matter of reversing the utf-8 runes in the string?

Shareed2k commented 5 years ago

yes you are right if i will try to revers ruins it will work as accepted

Screen Shot 2019-05-02 at 14 34 55
ArtemKor commented 5 years ago

I added copyrights and "right to left" languages support.

jung-kurt commented 5 years ago

Great work, @ArtemKor. Many thanks.

VitaliyPetroff commented 5 years ago

Good job, @ArtemKor! Awesome news for me.