-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit a3db329
Showing
15 changed files
with
355 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
# Binaries for programs and plugins | ||
*.exe | ||
*.exe~ | ||
*.dll | ||
*.so | ||
*.dylib | ||
|
||
# Test binary, built with `go test -c` | ||
*.test | ||
|
||
# Output of the go coverage tool, specifically when used with LiteIDE | ||
*.out | ||
|
||
# Dependency directories (remove the comment below to include it) | ||
# vendor/ | ||
buchhaltung-osx-386 | ||
profile.cov |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
language: go | ||
go: | ||
- 1.13 | ||
- 1.14 | ||
env: | ||
global: | ||
- TRAVIS_TAG=v1.0.1 | ||
matrix: | ||
fast_finish: true | ||
before_install: | ||
- go get github.com/mitchellh/gox | ||
- go get golang.org/x/tools/cmd/cover | ||
- go get github.com/mattn/goveralls | ||
install: | ||
- go get -d -v ./... | ||
script: | ||
- go vet -x ./... | ||
- go test -v ./... | ||
- go test -covermode=count -coverprofile=profile.cov ./... | ||
after_script: | ||
- "$HOME/gopath/bin/goveralls -coverprofile=profile.cov -service=travis-ci" | ||
before_deploy: | ||
- git config --local user.name "SlashGordon" | ||
- git config --local user.email "slash.gordon.dev@gmail.com" | ||
- git tag $TRAVIS_TAG || true | ||
#- gox -os="linux darwin windows" -arch="386 amd64" -output="buchhaltung-{{.OS}}-{{.Arch}}" ./cmd/buchhaltung.go | ||
#- env GOOS=darwin GOARCH=386 go build -o buchhaltung-osx-386 cmd/buchhaltung.go | ||
- env GOOS=darwin GOARCH=amd64 go build -o buchhaltung-osx-amd64 cmd/buchhaltung.go | ||
#- env GOOS=linux GOARCH=386 go build -o buchhaltung-linux-386 cmd/buchhaltung.go | ||
- env GOOS=linux GOARCH=amd64 go build -o buchhaltung-linux-amd64 cmd/buchhaltung.go | ||
#- env GOOS=windows GOARCH=386 go build -o buchhaltung-windows-386.exe cmd/buchhaltung.go | ||
- env GOOS=windows GOARCH=amd64 go build -o buchhaltung-windows-amd64.exe cmd/buchhaltung.go | ||
deploy: | ||
provider: releases | ||
file: | ||
- buchhaltung-osx-386 | ||
- buchhaltung-osx-amd64 | ||
- buchhaltung-linux-386 | ||
- buchhaltung-linux-amd64 | ||
- buchhaltung-windows-386.exe | ||
- buchhaltung-windows-amd64.exe | ||
skip_cleanup: true | ||
on: | ||
branch: master | ||
repo: SlashGordon/buchhaltung | ||
tags: true | ||
api_key: | ||
secure: FAWDuLQCDkJmGTmCgJ3PbbXpBQeFCsu5st9Fh26nKnflZUX+znsLvYP2dcgFvkYdwCIHYz3Yx2ckHZZJwBDgRydM3M5VziayiU+iq16R5qNM5v/PwkNHZMUk90OSJHIkg7sSEWBTVv1NlAELNgGMp36eHk6+9WWw/xOr4+hbHcbvyB4bcmT6WpIVUUKNFFV8fB+IWpXooJuVkfF4sVVeXXM6xGU6eg94Uoz4l0gnVKsCKDQBXHKguFAXwDOU7lPZGZxIRvGJHeZeXi55do7HX2qd3hxSoxj+R4ivWT/vToOP0OgLBbazcaask10deML/1THKrtuc5nQUrkiY27G2fxaguvUVPctnDIDR0LY3u3hcBTr1R81qTIB3e3ccqwQT6+IcpQw/JbMpqa4vK8vm0+u8/7w/motI0cb32DlzbwIwN0+nsDS+NioPxqmScGj2eaH+5v0NGp4/Ks5wVcMVssF0sZDXI9/Fn/EklHONyYLVcpQwNDGZRzLUpyqSeVbVQlR4g/fkHcVlKGZc+z4q8WTuX06AxgeRHaLcNryZuN23zLo+jHLbBg3aItv5YiRmvxMi0jZFnAJXCnKzEZym+KD/afMKTyz2PvitcQ4PYQpcX2VPRlihMSNiMc44H1p8gi1aE46TIxsNXVo5qSMUhpGubrcnp4J2XxaHqpeYqZk= |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
MIT License | ||
|
||
Copyright (c) 2020 Slash Gordon | ||
|
||
Permission is hereby granted, free of charge, to any person obtaining a copy | ||
of this software and associated documentation files (the "Software"), to deal | ||
in the Software without restriction, including without limitation the rights | ||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | ||
copies of the Software, and to permit persons to whom the Software is | ||
furnished to do so, subject to the following conditions: | ||
|
||
The above copyright notice and this permission notice shall be included in all | ||
copies or substantial portions of the Software. | ||
|
||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | ||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | ||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE | ||
SOFTWARE. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
[![Build Status](https://travis-ci.org/SlashGordon/buchhaltung.svg?branch=master)](https://travis-ci.org/SlashGordon/buchhaltung) | ||
[![Coverage Status](https://coveralls.io/repos/github/SlashGordon/buchhaltung/badge.svg?branch=master)](https://coveralls.io/github/SlashGordon/buchhaltung?branch=master) | ||
# buchhaltung |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
package main | ||
|
||
import ( | ||
"flag" | ||
"os" | ||
|
||
"github.com/SlashGordon/buchhaltung/pdf" | ||
) | ||
|
||
func main() { | ||
confPathPtr := flag.String("config", "", "Path to config file. (Required)") | ||
flag.Parse() | ||
|
||
if *confPathPtr == "" { | ||
flag.PrintDefaults() | ||
os.Exit(1) | ||
} | ||
pdf.GetText("") | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
package main | ||
|
||
import ( | ||
"testing" | ||
|
||
"github.com/stretchr/testify/assert" | ||
) | ||
|
||
func TestSomething(t *testing.T) { | ||
|
||
// assert equality | ||
assert.Equal(t, 123, 123, "they should be equal") | ||
|
||
// assert inequality | ||
assert.NotEqual(t, 123, 456, "they should not be equal") | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
package config | ||
|
||
import ( | ||
"encoding/json" | ||
"io/ioutil" | ||
) | ||
|
||
type config interface { | ||
Unmarshal(path string) error | ||
} | ||
|
||
//Unmarshal config for bill items | ||
func (b BillRenameItemList) Unmarshal(path string) error { | ||
data, err := ioutil.ReadFile(path) | ||
if err != nil { | ||
return err | ||
} | ||
slice := BillRenameItemList{} | ||
err = json.Unmarshal(data, &slice) | ||
if err != nil { | ||
return err | ||
} | ||
b = slice | ||
return nil | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
package config | ||
|
||
import ( | ||
"testing" | ||
|
||
"github.com/stretchr/testify/assert" | ||
) | ||
|
||
func TestBillItem(t *testing.T) { | ||
testItems := BillRenameItemList{} | ||
err := testItems.Unmarshal("") | ||
assert.Error(t, err) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
package config | ||
|
||
type BillRenameItem struct { | ||
Identifyers []string `json:"identifyers"` | ||
BillNumberIdentifyers []string `json:"bill_number_identifyers"` | ||
Rename string `json:"rename"` | ||
} | ||
|
||
type BillRenameItemList []BillRenameItem |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
module github.com/SlashGordon/buchhaltung | ||
|
||
go 1.14 | ||
|
||
require ( | ||
github.com/stretchr/testify v1.5.1 | ||
github.com/unidoc/unidoc v2.2.0+incompatible | ||
github.com/unidoc/unipdf/v3 v3.7.0 | ||
golang.org/x/image v0.0.0-20200430140353-33d19683fad8 // indirect | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,68 @@ | ||
github.com/adrg/strutil v0.1.0/go.mod h1:pXRr2+IyX5AEPAF5icj/EeTaiflPSD2hvGjnguilZgE= | ||
github.com/adrg/sysfont v0.1.0/go.mod h1:DzISco90USPZJ+lmtpuz1SOTn1fih6YyB0KG2TEP/0U= | ||
github.com/adrg/xdg v0.2.1/go.mod h1:ZuOshBmzV4Ta+s23hdfFZnBsdzmoR3US0d7ErpqSbTQ= | ||
github.com/boombuler/barcode v1.0.0/go.mod h1:paBWMcWSl3LHKBqUq+rly7CNSldXjb2rDl3JlRe0mD8= | ||
github.com/davecgh/go-spew v1.1.0 h1:ZDRjVQ15GmhC3fiQ8ni8+OwkZQO4DARzQgrnXU1Liz8= | ||
github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= | ||
github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c= | ||
github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= | ||
github.com/golang/freetype v0.0.0-20170609003504-e2365dfdc4a0/go.mod h1:E/TSTwGwJL78qG/PmXZO1EjYhfJinVAhrmmHX6Z8B9k= | ||
github.com/hashicorp/go-version v1.0.0 h1:21MVWPKDphxa7ineQQTrCU5brh7OuVVAzGOCnnCPtE8= | ||
github.com/hashicorp/go-version v1.0.0/go.mod h1:fltr4n8CU8Ke44wwGCBoEymUuxUHl09ZGVZPK5anwXA= | ||
github.com/hhrutter/lzw v0.0.0-20190827003112-58b82c5a41cc/go.mod h1:yJBvOcu1wLQ9q9XZmfiPfur+3dQJuIhYQsMGLYcItZk= | ||
github.com/hhrutter/lzw v0.0.0-20190829144645-6f07a24e8650 h1:1yY/RQWNSBjJe2GDCIYoLmpWVidrooriUr4QS/zaATQ= | ||
github.com/hhrutter/lzw v0.0.0-20190829144645-6f07a24e8650/go.mod h1:yJBvOcu1wLQ9q9XZmfiPfur+3dQJuIhYQsMGLYcItZk= | ||
github.com/hhrutter/tiff v0.0.0-20190829141212-736cae8d0bc7 h1:o1wMw7uTNyA58IlEdDpxIrtFHTgnvYzA8sCQz8luv94= | ||
github.com/hhrutter/tiff v0.0.0-20190829141212-736cae8d0bc7/go.mod h1:WkUxfS2JUu3qPo6tRld7ISb8HiC0gVSU91kooBMDVok= | ||
github.com/konsorten/go-windows-terminal-sequences v1.0.1/go.mod h1:T0+1ngSBFLxvqU3pZ+m/2kptfBszLMUkC4ZK/EgS/cQ= | ||
github.com/konsorten/go-windows-terminal-sequences v1.0.2/go.mod h1:T0+1ngSBFLxvqU3pZ+m/2kptfBszLMUkC4ZK/EgS/cQ= | ||
github.com/kr/pretty v0.1.0/go.mod h1:dAy3ld7l9f0ibDNOQOHHMYYIIbhfbHSm3C4ZsoJORNo= | ||
github.com/kr/pty v1.1.1/go.mod h1:pFQYn66WHrOpPYNljwOMqo10TkYh1fy3cYio2l3bCsQ= | ||
github.com/kr/text v0.1.0/go.mod h1:4Jbv+DJW3UT/LiOwJeYQe1efqtUx/iVham/4vfdArNI= | ||
github.com/mitchellh/gox v1.0.1 h1:x0jD3dcHk9a9xPSDN6YEL4xL6Qz0dvNYm8yZqui5chI= | ||
github.com/mitchellh/gox v1.0.1/go.mod h1:ED6BioOGXMswlXa2zxfh/xdd5QhwYliBFn9V18Ap4z4= | ||
github.com/mitchellh/iochan v1.0.0 h1:C+X3KsSTLFVBr/tK1eYN/vs4rJcvsiLU338UhYPJWeY= | ||
github.com/mitchellh/iochan v1.0.0/go.mod h1:JwYml1nuB7xOzsp52dPpHFffvOCDupsG0QubkSMEySY= | ||
github.com/pdfcpu/pdfcpu v0.3.2 h1:oHnvW3KUed/jVLnNcN5FyJsmInXAyyfoZ4yG3mxJdk8= | ||
github.com/pdfcpu/pdfcpu v0.3.2/go.mod h1:/ULj8B76ZnB4445B0yuSASQqlN0kEO+khtEnmPdEoXU= | ||
github.com/pkg/errors v0.8.1 h1:iURUrRGxPUNPdy5/HRSm+Yj6okJ6UtLINN0Q9M4+h3I= | ||
github.com/pkg/errors v0.8.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0= | ||
github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM= | ||
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= | ||
github.com/sirupsen/logrus v1.5.0 h1:1N5EYkVAPEywqZRJd7cwnRtCb6xJx7NH3T3WUTF980Q= | ||
github.com/sirupsen/logrus v1.5.0/go.mod h1:+F7Ogzej0PZc/94MaYx/nvG9jOFMD2osvC3s+Squfpo= | ||
github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= | ||
github.com/stretchr/testify v1.2.2/go.mod h1:a8OnRcib4nhh0OaRAV+Yts87kKdq0PP7pXfy6kDkUVs= | ||
github.com/stretchr/testify v1.4.0/go.mod h1:j7eGeouHqKxXV5pUuKE4zz7dFj8WfuZ+81PSLYec5m4= | ||
github.com/stretchr/testify v1.5.1 h1:nOGnQDM7FYENwehXlg/kFVnos3rEvtKTjRvOWSzb6H4= | ||
github.com/stretchr/testify v1.5.1/go.mod h1:5W2xD1RspED5o8YsWQXVCued0rvSQ+mT+I5cxcmMvtA= | ||
github.com/unidoc/pkcs7 v0.0.0-20200411230602-d883fd70d1df/go.mod h1:UEzOZUEpJfDpywVJMUT8QiugqEZC29pDq7kdIZhWCr8= | ||
github.com/unidoc/timestamp v0.0.0-20200412005513-91597fd3793a/go.mod h1:j+qMWZVpZFTvDey3zxUkSgPJZEX33tDgU/QIA0IzCUw= | ||
github.com/unidoc/unidoc v2.2.0+incompatible h1:AVVdSa11YROyMPxcAsp3j4Wz7zHSrXGjcVmHwgEvD+Y= | ||
github.com/unidoc/unidoc v2.2.0+incompatible/go.mod h1:xz5DRu10sgNndY6/LrqtXytidQ/aXastVtkIVSxIj3Q= | ||
github.com/unidoc/unipdf/v3 v3.7.0 h1:bi80mnkaMmuoZxmTqmmJ7+46N/4pAzcG8J4L+sZ2na4= | ||
github.com/unidoc/unipdf/v3 v3.7.0/go.mod h1:zGQ2sgy9ThW96DcVMauhVFt5viu2dlpz4oqwOPYZfU8= | ||
github.com/unidoc/unitype v0.0.0-20200426000514-43fb032b9ce6 h1:wKQZP0/WXDQ6kqniHSpdXol+895jojF+Sk4XORxxi3A= | ||
github.com/unidoc/unitype v0.0.0-20200426000514-43fb032b9ce6/go.mod h1:mafyug7zYmDOusqa7G0dJV45qp4b6TDAN+pHN7ZUIBU= | ||
golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w= | ||
golang.org/x/crypto v0.0.0-20190605123033-f99c8df09eb5/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI= | ||
golang.org/x/image v0.0.0-20181116024801-cd38e8056d9b/go.mod h1:ux5Hcp/YLpHSI86hEcLt0YII63i6oz57MZXIpbrjZUs= | ||
golang.org/x/image v0.0.0-20190823064033-3a9bac650e44/go.mod h1:FeLwcggjj3mMvU+oOTbSwawSJRM1uh48EjtB4UJZlP0= | ||
golang.org/x/image v0.0.0-20191214001246-9130b4cfad52 h1:2fktqPPvDiVEEVT/vSTeoUPXfmRxRaGy6GU8jypvEn0= | ||
golang.org/x/image v0.0.0-20191214001246-9130b4cfad52/go.mod h1:FeLwcggjj3mMvU+oOTbSwawSJRM1uh48EjtB4UJZlP0= | ||
golang.org/x/image v0.0.0-20200430140353-33d19683fad8 h1:6WW6V3x1P/jokJBpRQYUJnMHRP6isStQwCozxnU7XQw= | ||
golang.org/x/image v0.0.0-20200430140353-33d19683fad8/go.mod h1:FeLwcggjj3mMvU+oOTbSwawSJRM1uh48EjtB4UJZlP0= | ||
golang.org/x/net v0.0.0-20190404232315-eb5bcb51f2a3/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg= | ||
golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= | ||
golang.org/x/sys v0.0.0-20190412213103-97732733099d/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= | ||
golang.org/x/sys v0.0.0-20190422165155-953cdadca894/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= | ||
golang.org/x/sys v0.0.0-20200413165638-669c56c373c4 h1:opSr2sbRXk5X5/givKrrKj9HXxFpW2sdCiP8MJSKLQY= | ||
golang.org/x/sys v0.0.0-20200413165638-669c56c373c4/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= | ||
golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= | ||
golang.org/x/text v0.3.2 h1:tW2bmiBqwgJj/UpqtC8EpXEZVYOwU0yG4iWbprSVAcs= | ||
golang.org/x/text v0.3.2/go.mod h1:bEr9sfX3Q8Zfm5fL9x+3itogRgK3+ptLWKqgva+5dAk= | ||
golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= | ||
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= | ||
gopkg.in/check.v1 v1.0.0-20180628173108-788fd7840127/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= | ||
gopkg.in/yaml.v2 v2.2.2 h1:ZCJp+EgiOT7lHqUV2J862kp8Qj64Jo6az82+3Td9dZw= | ||
gopkg.in/yaml.v2 v2.2.2/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
package pdf | ||
|
||
import ( | ||
"time" | ||
_ "unsafe" // for license | ||
|
||
"github.com/unidoc/unipdf/v3/common/license" | ||
) | ||
|
||
//go:linkname licenseKey github.com/unidoc/unipdf/v3/common/license.licenseKey | ||
var licenseKey *license.LicenseKey | ||
|
||
//InitLicense use community license | ||
func InitLicense() { | ||
lk := license.LicenseKey{} | ||
lk.CustomerName = "community" | ||
lk.Tier = license.LicenseTierCommunity | ||
lk.CreatedAt = time.Now().UTC() | ||
lk.CreatedAtInt = lk.CreatedAt.Unix() | ||
licenseKey = &lk | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,68 @@ | ||
package pdf | ||
|
||
import ( | ||
"os" | ||
"strings" | ||
|
||
"github.com/unidoc/unipdf/v3/extractor" | ||
pdf "github.com/unidoc/unipdf/v3/model" | ||
) | ||
|
||
func CreatePdf(outputPath string) { | ||
|
||
} | ||
|
||
//GetText | ||
func GetText(path string) (string, error) { | ||
var sb strings.Builder | ||
f, err := os.Open(path) | ||
if err != nil { | ||
return "", err | ||
} | ||
|
||
defer f.Close() | ||
|
||
pdfReader, err := pdf.NewPdfReader(f) | ||
if err != nil { | ||
return "", err | ||
} | ||
|
||
isEncrypted, err := pdfReader.IsEncrypted() | ||
if err != nil { | ||
return "", err | ||
} | ||
|
||
if isEncrypted { | ||
_, err = pdfReader.Decrypt([]byte("")) | ||
if err != nil { | ||
return "", err | ||
} | ||
} | ||
|
||
numPages, err := pdfReader.GetNumPages() | ||
if err != nil { | ||
return "", err | ||
} | ||
|
||
for pageNum := 1; pageNum <= numPages; pageNum++ { | ||
|
||
page, err := pdfReader.GetPage(pageNum) | ||
if err != nil { | ||
return "", err | ||
} | ||
|
||
ex, err := extractor.New(page) | ||
if err != nil { | ||
return "", err | ||
} | ||
|
||
text, err := ex.ExtractText() | ||
if err != nil { | ||
return "", err | ||
} | ||
sb.WriteString(text) | ||
|
||
} | ||
|
||
return sb.String(), nil | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
package pdf | ||
|
||
import ( | ||
"testing" | ||
|
||
"github.com/stretchr/testify/assert" | ||
) | ||
|
||
func TestGetText(t *testing.T) { | ||
InitLicense() | ||
_, err := GetText("") | ||
assert.Error(t, err) | ||
text, err2 := GetText("../r1.pdf") | ||
assert.NoError(t, err2) | ||
assert.Equal(t, "This is a test ", text) | ||
} |
Binary file not shown.