mirror of
https://github.com/gotenberg/gotenberg.git
synced 2026-08-18 05:02:15 +01:00
chore(deps): update pdfcpu to v0.12.0 (#1537)
This commit is contained in:
@@ -11,7 +11,7 @@ ARG GOLANG_VERSION=1.26.0
|
|||||||
FROM golang:$GOLANG_VERSION AS pdfcpu-binary-stage
|
FROM golang:$GOLANG_VERSION AS pdfcpu-binary-stage
|
||||||
|
|
||||||
# See https://github.com/pdfcpu/pdfcpu/releases.
|
# See https://github.com/pdfcpu/pdfcpu/releases.
|
||||||
ARG PDFCPU_VERSION=v0.11.1
|
ARG PDFCPU_VERSION=v0.12.0
|
||||||
ENV CGO_ENABLED=0
|
ENV CGO_ENABLED=0
|
||||||
|
|
||||||
# Define the working directory outside of $GOPATH (we're using go modules).
|
# Define the working directory outside of $GOPATH (we're using go modules).
|
||||||
@@ -24,7 +24,7 @@ RUN curl -Ls "https://github.com/pdfcpu/pdfcpu/archive/refs/tags/$PDFCPU_VERSION
|
|||||||
RUN go mod download \
|
RUN go mod download \
|
||||||
&& go mod verify
|
&& go mod verify
|
||||||
|
|
||||||
RUN go build -o pdfcpu -ldflags "-s -w -X 'main.version=$PDFCPU_VERSION' -X 'github.com/pdfcpu/pdfcpu/pkg/pdfcpu.VersionStr=$PDFCPU_VERSION' -X main.builtBy=gotenberg" ./cmd/pdfcpu \
|
RUN go build -o pdfcpu -ldflags "-s -w -X 'main.version=$PDFCPU_VERSION' -X 'github.com/pdfcpu/pdfcpu/pkg/pdfcpu/model.VersionStr=$PDFCPU_VERSION' -X main.builtBy=gotenberg" ./cmd/pdfcpu \
|
||||||
# Verify installation.
|
# Verify installation.
|
||||||
&& ./pdfcpu version
|
&& ./pdfcpu version
|
||||||
|
|
||||||
|
|||||||
@@ -142,14 +142,14 @@ func (engine *PdfCpu) Split(ctx context.Context, logger *slog.Logger, mode goten
|
|||||||
|
|
||||||
switch mode.Mode {
|
switch mode.Mode {
|
||||||
case gotenberg.SplitModeIntervals:
|
case gotenberg.SplitModeIntervals:
|
||||||
args = append(args, "split", "-mode", "span", inputPath, outputDirPath, mode.Span)
|
args = append(args, "split", "--mode", "span", inputPath, outputDirPath, mode.Span)
|
||||||
case gotenberg.SplitModePages:
|
case gotenberg.SplitModePages:
|
||||||
if mode.Unify {
|
if mode.Unify {
|
||||||
outputPath := fmt.Sprintf("%s/%s", outputDirPath, filepath.Base(inputPath))
|
outputPath := fmt.Sprintf("%s/%s", outputDirPath, filepath.Base(inputPath))
|
||||||
args = append(args, "trim", "-pages", mode.Span, inputPath, outputPath)
|
args = append(args, "trim", "--pages", mode.Span, inputPath, outputPath)
|
||||||
break
|
break
|
||||||
}
|
}
|
||||||
args = append(args, "extract", "-mode", "page", "-pages", mode.Span, inputPath, outputDirPath)
|
args = append(args, "extract", "--mode", "page", "--pages", mode.Span, inputPath, outputDirPath)
|
||||||
default:
|
default:
|
||||||
err := fmt.Errorf("split PDFs using mode '%s' with pdfcpu: %w", mode.Mode, gotenberg.ErrPdfSplitModeNotSupported)
|
err := fmt.Errorf("split PDFs using mode '%s' with pdfcpu: %w", mode.Mode, gotenberg.ErrPdfSplitModeNotSupported)
|
||||||
span.RecordError(err)
|
span.RecordError(err)
|
||||||
@@ -426,7 +426,7 @@ func (engine *PdfCpu) WriteBookmarks(ctx context.Context, logger *slog.Logger, i
|
|||||||
}
|
}
|
||||||
}()
|
}()
|
||||||
|
|
||||||
args := []string{"bookmarks", "import", "-replace", inputPath, tmpPath, inputPath}
|
args := []string{"bookmarks", "import", "--replace", inputPath, tmpPath, inputPath}
|
||||||
cmd, err := gotenberg.CommandContext(ctx, logger, engine.binPath, args...)
|
cmd, err := gotenberg.CommandContext(ctx, logger, engine.binPath, args...)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
err = fmt.Errorf("create command: %w", err)
|
err = fmt.Errorf("create command: %w", err)
|
||||||
@@ -513,10 +513,10 @@ func (engine *PdfCpu) Encrypt(ctx context.Context, logger *slog.Logger, inputPat
|
|||||||
|
|
||||||
args := make([]string, 0, 11)
|
args := make([]string, 0, 11)
|
||||||
args = append(args, "encrypt")
|
args = append(args, "encrypt")
|
||||||
args = append(args, "-mode", "aes")
|
args = append(args, "--mode", "aes")
|
||||||
args = append(args, "-upw", userPassword)
|
args = append(args, "--upw", userPassword)
|
||||||
args = append(args, "-opw", ownerPassword)
|
args = append(args, "--opw", ownerPassword)
|
||||||
args = append(args, "-perm", "all")
|
args = append(args, "--perm", "all")
|
||||||
args = append(args, inputPath, inputPath)
|
args = append(args, inputPath, inputPath)
|
||||||
|
|
||||||
cmd, err := gotenberg.CommandContext(ctx, logger, engine.binPath, args...)
|
cmd, err := gotenberg.CommandContext(ctx, logger, engine.binPath, args...)
|
||||||
@@ -587,7 +587,7 @@ func (engine *PdfCpu) Rotate(ctx context.Context, logger *slog.Logger, inputPath
|
|||||||
|
|
||||||
args := []string{"rotate"}
|
args := []string{"rotate"}
|
||||||
if pages != "" {
|
if pages != "" {
|
||||||
args = append(args, "-pages", pages)
|
args = append(args, "--pages", pages)
|
||||||
}
|
}
|
||||||
args = append(args, "--", inputPath, strconv.Itoa(angle), inputPath)
|
args = append(args, "--", inputPath, strconv.Itoa(angle), inputPath)
|
||||||
|
|
||||||
@@ -631,10 +631,10 @@ func (engine *PdfCpu) applyStampOrWatermark(ctx context.Context, logger *slog.Lo
|
|||||||
}
|
}
|
||||||
description := strings.Join(descParts, ", ")
|
description := strings.Join(descParts, ", ")
|
||||||
|
|
||||||
args := []string{command, "add", "-mode", mode}
|
args := []string{command, "add", "--mode", mode}
|
||||||
|
|
||||||
if stamp.Pages != "" {
|
if stamp.Pages != "" {
|
||||||
args = append(args, "-pages", stamp.Pages)
|
args = append(args, "--pages", stamp.Pages)
|
||||||
}
|
}
|
||||||
|
|
||||||
args = append(args, "--", stamp.Expression, description, inputPath, inputPath)
|
args = append(args, "--", stamp.Expression, description, inputPath, inputPath)
|
||||||
|
|||||||
Reference in New Issue
Block a user