Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ go 1.20

require (
github.com/spf13/cobra v1.9.1
github.com/unidoc/unipdf/v3 v3.67.0
github.com/unidoc/unipdf/v4 v4.0.0
)

require (
Expand All @@ -22,7 +22,7 @@ require (
github.com/unidoc/freetype v0.2.3 // indirect
github.com/unidoc/pkcs7 v0.2.0 // indirect
github.com/unidoc/timestamp v0.0.0-20200412005513-91597fd3793a // indirect
github.com/unidoc/unichart v0.3.0 // indirect
github.com/unidoc/unichart v0.4.0 // indirect
github.com/unidoc/unitype v0.5.1 // indirect
golang.org/x/crypto v0.33.0 // indirect
golang.org/x/image v0.24.0 // indirect
Expand Down
8 changes: 4 additions & 4 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -44,10 +44,10 @@ github.com/unidoc/pkcs7 v0.2.0 h1:0Y0RJR5Zu7OuD+/l7bODXARn6b8Ev2G4A8lI4rzy9kg=
github.com/unidoc/pkcs7 v0.2.0/go.mod h1:UEzOZUEpJfDpywVJMUT8QiugqEZC29pDq7kdIZhWCr8=
github.com/unidoc/timestamp v0.0.0-20200412005513-91597fd3793a h1:RLtvUhe4DsUDl66m7MJ8OqBjq8jpWBXPK6/RKtqeTkc=
github.com/unidoc/timestamp v0.0.0-20200412005513-91597fd3793a/go.mod h1:j+qMWZVpZFTvDey3zxUkSgPJZEX33tDgU/QIA0IzCUw=
github.com/unidoc/unichart v0.3.0 h1:VX1j5yzhjrR3f2flC03Yat6/WF3h7Z+DLEvJLoTGhoc=
github.com/unidoc/unichart v0.3.0/go.mod h1:8JnLNKSOl8yQt1jXewNgYFHhFm5M6/ZiaydncFDpakA=
github.com/unidoc/unipdf/v3 v3.67.0 h1:t1ZkNX5iFhGLDPN/68MQOPAq4iXK4tTi7ePpSUBWkdo=
github.com/unidoc/unipdf/v3 v3.67.0/go.mod h1:S5BLo/oBIxAaQtB0Lw3wFqPFOY3U1oU+NISbjX9xEBA=
github.com/unidoc/unichart v0.4.0 h1:uXk9ZjbqzKb8Lt2Qv2oM9D2ftNRXvezPevgxQhsTQys=
github.com/unidoc/unichart v0.4.0/go.mod h1:9QsE8RbS0fE7ndHNroeCEFkRPqqk47Qsoj6QSAtcwN0=
github.com/unidoc/unipdf/v4 v4.0.0 h1:XxrrOMGLJ6HD7VBO6GpZL5wfoRDmLxawV+wkMXTuPeM=
github.com/unidoc/unipdf/v4 v4.0.0/go.mod h1:SbSYFUoutyBR+hLlsHyNiCzzcSVVuG10S5Xu8RIJ6EY=
github.com/unidoc/unitype v0.5.1 h1:UwTX15K6bktwKocWVvLoijIeu4JAVEAIeFqMOjvxqQs=
github.com/unidoc/unitype v0.5.1/go.mod h1:3dxbRL+f1otNqFQIRHho8fxdg3CcUKrqS8w1SXTsqcI=
golang.org/x/crypto v0.33.0 h1:IOBPskki6Lysi0lo9qQvbxiQ+FvsCC/YWOecCHAixus=
Expand Down
6 changes: 3 additions & 3 deletions internal/cli/const.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,9 @@ import (
"errors"
"strings"

unicommon "github.com/unidoc/unipdf/v3/common"
unisecurity "github.com/unidoc/unipdf/v3/core/security"
unipdf "github.com/unidoc/unipdf/v3/model"
unicommon "github.com/unidoc/unipdf/v4/common"
unisecurity "github.com/unidoc/unipdf/v4/core/security"
unipdf "github.com/unidoc/unipdf/v4/model"
)

var encryptAlgoMap = map[string]unipdf.EncryptionAlgorithm{
Expand Down
2 changes: 1 addition & 1 deletion internal/cli/extract_images.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import (
"github.com/spf13/cobra"
"github.com/unidoc/unipdf-cli/pkg/pdf"

uniextractor "github.com/unidoc/unipdf/v3/extractor"
uniextractor "github.com/unidoc/unipdf/v4/extractor"
)

const extractImagesCmdDesc = `Extracts PDF images.
Expand Down
2 changes: 1 addition & 1 deletion internal/cli/root.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import (

"github.com/spf13/cobra"
"github.com/unidoc/unipdf-cli/pkg/pdf"
unicommon "github.com/unidoc/unipdf/v3/common"
unicommon "github.com/unidoc/unipdf/v4/common"
)

const appName = "unipdf"
Expand Down
2 changes: 1 addition & 1 deletion pkg/pdf/decrypt.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

package pdf

import unipdf "github.com/unidoc/unipdf/v3/model"
import unipdf "github.com/unidoc/unipdf/v4/model"

// Decrypt decrypts the PDF file specified by the inputPath parameter,
// using the specified password and saves the result to the destination
Expand Down
4 changes: 2 additions & 2 deletions pkg/pdf/encrypt.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@
package pdf

import (
unisecurity "github.com/unidoc/unipdf/v3/core/security"
unipdf "github.com/unidoc/unipdf/v3/model"
unisecurity "github.com/unidoc/unipdf/v4/core/security"
unipdf "github.com/unidoc/unipdf/v4/model"
)

// EncryptOpts contains settings for encrypting a PDF file.
Expand Down
2 changes: 1 addition & 1 deletion pkg/pdf/explode.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import (
"path/filepath"
"strings"

unipdf "github.com/unidoc/unipdf/v3/model"
unipdf "github.com/unidoc/unipdf/v4/model"
)

// Explode splits the PDF file specified by the inputPath parameter into single
Expand Down
2 changes: 1 addition & 1 deletion pkg/pdf/extract.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ import (
"strings"
"time"

uniextractor "github.com/unidoc/unipdf/v3/extractor"
uniextractor "github.com/unidoc/unipdf/v4/extractor"
)

// ExtractText returns all text content from the PDF file specified by the
Expand Down
8 changes: 4 additions & 4 deletions pkg/pdf/form.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,10 @@
package pdf

import (
"github.com/unidoc/unipdf/v3/annotator"
"github.com/unidoc/unipdf/v3/fdf"
"github.com/unidoc/unipdf/v3/fjson"
unipdf "github.com/unidoc/unipdf/v3/model"
"github.com/unidoc/unipdf/v4/annotator"
"github.com/unidoc/unipdf/v4/fdf"
"github.com/unidoc/unipdf/v4/fjson"
unipdf "github.com/unidoc/unipdf/v4/model"
)

// FormExport exports all form field values from the PDF file specified
Expand Down
28 changes: 14 additions & 14 deletions pkg/pdf/grayscale.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,11 @@ import (
"errors"
"fmt"

unicommon "github.com/unidoc/unipdf/v3/common"
unicontent "github.com/unidoc/unipdf/v3/contentstream"
unicore "github.com/unidoc/unipdf/v3/core"
unipdf "github.com/unidoc/unipdf/v3/model"
"github.com/unidoc/unipdf/v3/ps"
unicommon "github.com/unidoc/unipdf/v4/common"
unicontent "github.com/unidoc/unipdf/v4/contentstream"
unicore "github.com/unidoc/unipdf/v4/core"
unipdf "github.com/unidoc/unipdf/v4/model"
"github.com/unidoc/unipdf/v4/ps"
)

// Grayscale converts the pages of the PDF file specified by the inputPath
Expand Down Expand Up @@ -82,7 +82,7 @@ func convertPageToGrayscale(page *unipdf.PdfPage) error {
}
page.SetContentStreams([]string{string(grayContent)}, unicore.NewFlateEncoder())

//fmt.Printf("Processed contents: %s\n", grayContent)
// fmt.Printf("Processed contents: %s\n", grayContent)

return nil
}
Expand Down Expand Up @@ -464,7 +464,7 @@ func transformContentStreamToGrayscale(contents string, resources *unipdf.PdfPag

_, xtype := resources.GetXObjectByName(*name)
if xtype == unipdf.XObjectTypeImage {
//fmt.Printf(" XObject Image: %s\n", *name)
// fmt.Printf(" XObject Image: %s\n", *name)

ximg, err := resources.GetXObjectImageByName(*name)
if err != nil {
Expand Down Expand Up @@ -520,7 +520,7 @@ func transformContentStreamToGrayscale(contents string, resources *unipdf.PdfPag
return err
}
} else if xtype == unipdf.XObjectTypeForm {
//fmt.Printf(" XObject Form: %s\n", *name)
// fmt.Printf(" XObject Form: %s\n", *name)

// Go through the XObject Form content stream.
xform, err := resources.GetXObjectFormByName(*name)
Expand Down Expand Up @@ -567,14 +567,14 @@ func transformContentStreamToGrayscale(contents string, resources *unipdf.PdfPag

// For debug purposes: (high level logging).
//
//fmt.Printf("=== Unprocessed - Full list\n")
//for idx, op := range operations {
// fmt.Printf("=== Unprocessed - Full list\n")
// for idx, op := range operations {
// fmt.Printf("U. Operation %d: %s - Params: %v\n", idx+1, op.Operand, op.Params)
//}
//fmt.Printf("=== Processed - Full list\n")
//for idx, op := range *processedOperations {
// }
// fmt.Printf("=== Processed - Full list\n")
// for idx, op := range *processedOperations {
// fmt.Printf("P. Operation %d: %s - Params: %v\n", idx+1, op.Operand, op.Params)
//}
// }

return processedOperations.Bytes(), nil
}
Expand Down
6 changes: 3 additions & 3 deletions pkg/pdf/merge.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,9 @@ package pdf
import (
"fmt"

unicommon "github.com/unidoc/unipdf/v3/common"
unicore "github.com/unidoc/unipdf/v3/core"
unipdf "github.com/unidoc/unipdf/v3/model"
unicommon "github.com/unidoc/unipdf/v4/common"
unicore "github.com/unidoc/unipdf/v4/core"
unipdf "github.com/unidoc/unipdf/v4/model"
)

// Merge merges all the PDF files specified by the inputPaths parameter and
Expand Down
4 changes: 2 additions & 2 deletions pkg/pdf/optimize.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@ import (
"os"
"time"

unipdf "github.com/unidoc/unipdf/v3/model"
unioptimize "github.com/unidoc/unipdf/v3/model/optimize"
unipdf "github.com/unidoc/unipdf/v4/model"
unioptimize "github.com/unidoc/unipdf/v4/model/optimize"
)

// OptimizeOpts represents the options used for optimizing PDF files.
Expand Down
6 changes: 3 additions & 3 deletions pkg/pdf/organize.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@
package pdf

import (
"github.com/unidoc/unipdf/v3/common"
unipdf "github.com/unidoc/unipdf/v3/model"
"github.com/unidoc/unipdf/v4/common"
unipdf "github.com/unidoc/unipdf/v4/model"
)

// Organize extracts the provided page list from PDF file specified by the
Expand Down Expand Up @@ -130,7 +130,7 @@ func Organize(inputPath, outputPath, password string, pages []int) error {
}
}

// Copy StructTreeRoot dictionary.
// Copy StructTreeRoot dictionary.
structTreeRoot, found := pdfReader.GetCatalogStructTreeRoot()
if found {
err := pdfWriter.SetCatalogStructTreeRoot(structTreeRoot)
Expand Down
2 changes: 1 addition & 1 deletion pkg/pdf/passwd.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
package pdf

import (
unipdf "github.com/unidoc/unipdf/v3/model"
unipdf "github.com/unidoc/unipdf/v4/model"
)

// Passwd changes the owner and user password of an encrypted PDF file.
Expand Down
4 changes: 2 additions & 2 deletions pkg/pdf/pdf.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@ import (
"fmt"
"os"

unicommon "github.com/unidoc/unipdf/v3/common"
unilicense "github.com/unidoc/unipdf/v3/common/license"
unicommon "github.com/unidoc/unipdf/v4/common"
unilicense "github.com/unidoc/unipdf/v4/common/license"
)

// SetLicense sets the license for using the UniDoc library.
Expand Down
2 changes: 1 addition & 1 deletion pkg/pdf/render.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ import (
"path/filepath"
"strings"

"github.com/unidoc/unipdf/v3/render"
"github.com/unidoc/unipdf/v4/render"
)

// RenderOpts represents the options used for rendering PDF pages to images.
Expand Down
10 changes: 5 additions & 5 deletions pkg/pdf/replace.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,11 @@ package pdf
import (
"strings"

"github.com/unidoc/unipdf/v3/common"
"github.com/unidoc/unipdf/v3/contentstream"
"github.com/unidoc/unipdf/v3/core"
"github.com/unidoc/unipdf/v3/model"
unipdf "github.com/unidoc/unipdf/v3/model"
"github.com/unidoc/unipdf/v4/common"
"github.com/unidoc/unipdf/v4/contentstream"
"github.com/unidoc/unipdf/v4/core"
"github.com/unidoc/unipdf/v4/model"
unipdf "github.com/unidoc/unipdf/v4/model"
)

type textChunk struct {
Expand Down
2 changes: 1 addition & 1 deletion pkg/pdf/rotate.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import (
"path/filepath"
"strings"

unicreator "github.com/unidoc/unipdf/v3/creator"
unicreator "github.com/unidoc/unipdf/v4/creator"
)

// Rotate rotates the pages of the PDF file specified by the inputPath
Expand Down
2 changes: 1 addition & 1 deletion pkg/pdf/search.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ package pdf
import (
"strings"

uniextractor "github.com/unidoc/unipdf/v3/extractor"
uniextractor "github.com/unidoc/unipdf/v4/extractor"
)

// SearchResult contains information about a found search term inside a PDF page.
Expand Down
2 changes: 1 addition & 1 deletion pkg/pdf/split.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
package pdf

import (
unipdf "github.com/unidoc/unipdf/v3/model"
unipdf "github.com/unidoc/unipdf/v4/model"
)

// Split extracts the provided page list from PDF file specified by the
Expand Down
6 changes: 3 additions & 3 deletions pkg/pdf/utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,9 @@ import (
"os"
"path/filepath"

unisecurity "github.com/unidoc/unipdf/v3/core/security"
unicreator "github.com/unidoc/unipdf/v3/creator"
unipdf "github.com/unidoc/unipdf/v3/model"
unisecurity "github.com/unidoc/unipdf/v4/core/security"
unicreator "github.com/unidoc/unipdf/v4/creator"
unipdf "github.com/unidoc/unipdf/v4/model"
)

func readPDF(filename, password string) (*unipdf.PdfReader, int, bool, unisecurity.Permissions, error) {
Expand Down
4 changes: 2 additions & 2 deletions pkg/pdf/version.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@
package pdf

import (
unicommon "github.com/unidoc/unipdf/v3/common"
unilicense "github.com/unidoc/unipdf/v3/common/license"
unicommon "github.com/unidoc/unipdf/v4/common"
unilicense "github.com/unidoc/unipdf/v4/common/license"
)

// VersionInfo contains version and license information
Expand Down
2 changes: 1 addition & 1 deletion pkg/pdf/watermark.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
package pdf

import (
unicreator "github.com/unidoc/unipdf/v3/creator"
unicreator "github.com/unidoc/unipdf/v4/creator"
)

// Watermark adds the watermark image specified by the watermarkPath parameter
Expand Down