mirror of
https://github.com/gotenberg/gotenberg.git
synced 2026-08-17 12:42:16 +01:00
feat(libreoffice): add exportNotesInMargin form field (#904)
* ExportNotesInMargin allows to export comments in margin https://help.libreoffice.org/latest/en-US/text/shared/guide/pdf_params.html * Resolve requested changes Move ExportNotesInMargin above LosslessImageCompression Remove overhead ExportNotes=true
This commit is contained in:
@@ -59,6 +59,10 @@ type Options struct {
|
|||||||
// Optional
|
// Optional
|
||||||
SinglePageSheets bool
|
SinglePageSheets bool
|
||||||
|
|
||||||
|
// ExportNotesInMargin allows to export comments in margin.
|
||||||
|
// Optional
|
||||||
|
ExportNotesInMargin bool
|
||||||
|
|
||||||
// LosslessImageCompression allows turning lossless compression on or off
|
// LosslessImageCompression allows turning lossless compression on or off
|
||||||
// to tweak image conversion performance.
|
// to tweak image conversion performance.
|
||||||
// Optional
|
// Optional
|
||||||
|
|||||||
@@ -281,6 +281,10 @@ func (p *libreOfficeProcess) pdf(ctx context.Context, logger *zap.Logger, inputP
|
|||||||
args = append(args, "--export", "SinglePageSheets=true")
|
args = append(args, "--export", "SinglePageSheets=true")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if options.ExportNotesInMargin {
|
||||||
|
args = append(args, "--export", "ExportNotesInMargin=true")
|
||||||
|
}
|
||||||
|
|
||||||
if options.LosslessImageCompression {
|
if options.LosslessImageCompression {
|
||||||
args = append(args, "--export", "UseLosslessCompression=true")
|
args = append(args, "--export", "UseLosslessCompression=true")
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -451,6 +451,35 @@ func TestLibreOfficeProcess_pdf(t *testing.T) {
|
|||||||
start: true,
|
start: true,
|
||||||
expectError: false,
|
expectError: false,
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
scenario: "success ExportNotesInMargin",
|
||||||
|
libreOffice: newLibreOfficeProcess(
|
||||||
|
libreOfficeArguments{
|
||||||
|
binPath: os.Getenv("LIBREOFFICE_BIN_PATH"),
|
||||||
|
unoBinPath: os.Getenv("UNOCONVERTER_BIN_PATH"),
|
||||||
|
startTimeout: 5 * time.Second,
|
||||||
|
},
|
||||||
|
),
|
||||||
|
fs: func() *gotenberg.FileSystem {
|
||||||
|
fs := gotenberg.NewFileSystem()
|
||||||
|
|
||||||
|
err := os.MkdirAll(fs.WorkingDirPath(), 0o755)
|
||||||
|
if err != nil {
|
||||||
|
t.Fatalf(fmt.Sprintf("expected no error but got: %v", err))
|
||||||
|
}
|
||||||
|
|
||||||
|
err = os.WriteFile(fmt.Sprintf("%s/document.txt", fs.WorkingDirPath()), []byte("ExportNotesInMargin"), 0o755)
|
||||||
|
if err != nil {
|
||||||
|
t.Fatalf("expected no error but got: %v", err)
|
||||||
|
}
|
||||||
|
|
||||||
|
return fs
|
||||||
|
}(),
|
||||||
|
options: Options{ExportNotesInMargin: true},
|
||||||
|
cancelledCtx: false,
|
||||||
|
start: true,
|
||||||
|
expectError: false,
|
||||||
|
},
|
||||||
{
|
{
|
||||||
scenario: "success LosslessImageCompression",
|
scenario: "success LosslessImageCompression",
|
||||||
libreOffice: newLibreOfficeProcess(
|
libreOffice: newLibreOfficeProcess(
|
||||||
|
|||||||
@@ -30,6 +30,7 @@ func convertRoute(libreOffice libreofficeapi.Uno, engine gotenberg.PdfEngine) ap
|
|||||||
nativePageRanges string
|
nativePageRanges string
|
||||||
exportFormFields bool
|
exportFormFields bool
|
||||||
singlePageSheets bool
|
singlePageSheets bool
|
||||||
|
exportNotesInMargin bool
|
||||||
losslessImageCompression bool
|
losslessImageCompression bool
|
||||||
reduceImageResolution bool
|
reduceImageResolution bool
|
||||||
pdfa string
|
pdfa string
|
||||||
@@ -45,6 +46,7 @@ func convertRoute(libreOffice libreofficeapi.Uno, engine gotenberg.PdfEngine) ap
|
|||||||
String("nativePageRanges", &nativePageRanges, "").
|
String("nativePageRanges", &nativePageRanges, "").
|
||||||
Bool("exportFormFields", &exportFormFields, true).
|
Bool("exportFormFields", &exportFormFields, true).
|
||||||
Bool("singlePageSheets", &singlePageSheets, false).
|
Bool("singlePageSheets", &singlePageSheets, false).
|
||||||
|
Bool("exportNotesInMargin", &exportNotesInMargin, false).
|
||||||
Bool("losslessImageCompression", &losslessImageCompression, false).
|
Bool("losslessImageCompression", &losslessImageCompression, false).
|
||||||
Bool("reduceImageResolution", &reduceImageResolution, true).
|
Bool("reduceImageResolution", &reduceImageResolution, true).
|
||||||
String("pdfa", &pdfa, "").
|
String("pdfa", &pdfa, "").
|
||||||
@@ -79,6 +81,7 @@ func convertRoute(libreOffice libreofficeapi.Uno, engine gotenberg.PdfEngine) ap
|
|||||||
PageRanges: nativePageRanges,
|
PageRanges: nativePageRanges,
|
||||||
ExportFormFields: exportFormFields,
|
ExportFormFields: exportFormFields,
|
||||||
SinglePageSheets: singlePageSheets,
|
SinglePageSheets: singlePageSheets,
|
||||||
|
ExportNotesInMargin: exportNotesInMargin,
|
||||||
LosslessImageCompression: losslessImageCompression,
|
LosslessImageCompression: losslessImageCompression,
|
||||||
ReduceImageResolution: reduceImageResolution,
|
ReduceImageResolution: reduceImageResolution,
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user