mirror of
https://github.com/gotenberg/gotenberg.git
synced 2026-08-08 16:42:15 +01:00
fix(pdfengines): only preserve filenames in zip archive
This commit is contained in:
@@ -158,7 +158,12 @@ func convertRoute(engine gotenberg.PdfEngine) api.Route {
|
||||
outputPaths := make([]string, len(inputPaths))
|
||||
|
||||
for i, inputPath := range inputPaths {
|
||||
outputPaths[i] = ctx.GeneratePath(strings.TrimSuffix(filepath.Base(inputPath), filepath.Ext(inputPath)), ".pdf")
|
||||
if len(outputPaths) > 1 {
|
||||
// If .zip archive, keep the original filenames.
|
||||
outputPaths[i] = ctx.GeneratePath(strings.TrimSuffix(filepath.Base(inputPath), filepath.Ext(inputPath)), ".pdf")
|
||||
} else {
|
||||
outputPaths[i] = ctx.GeneratePath("", ".pdf")
|
||||
}
|
||||
|
||||
err = engine.Convert(ctx, ctx.Log(), pdfFormats, inputPath, outputPaths[i])
|
||||
if err != nil {
|
||||
|
||||
@@ -418,7 +418,6 @@ func TestConvertHandler(t *testing.T) {
|
||||
expectError: false,
|
||||
expectHttpError: false,
|
||||
expectOutputPathsCount: 1,
|
||||
expectOutputPaths: []string{"/file.pdf"},
|
||||
},
|
||||
{
|
||||
scenario: "success with PDF/A & PDF/UA form fields (many files)",
|
||||
|
||||
Reference in New Issue
Block a user