feat(libreoffice): add updateIndexes form field

This commit is contained in:
Julien Neuhart
2025-03-17 13:20:00 +01:00
parent 85eaef05ad
commit b31024c362
4 changed files with 13 additions and 1 deletions

View File

@@ -171,7 +171,7 @@ RUN \
apt-get update -qq &&\ apt-get update -qq &&\
apt-get upgrade -yqq &&\ apt-get upgrade -yqq &&\
DEBIAN_FRONTEND=noninteractive apt-get install -y -qq --no-install-recommends -t bookworm-backports libreoffice &&\ DEBIAN_FRONTEND=noninteractive apt-get install -y -qq --no-install-recommends -t bookworm-backports libreoffice &&\
curl -Ls https://raw.githubusercontent.com/gotenberg/unoconverter/v0.0.1/unoconv -o /usr/bin/unoconverter &&\ curl -Ls https://raw.githubusercontent.com/gotenberg/unoconverter/v0.1.1/unoconv -o /usr/bin/unoconverter &&\
chmod +x /usr/bin/unoconverter &&\ chmod +x /usr/bin/unoconverter &&\
# unoconverter will look for the Python binary, which has to be at version 3. # unoconverter will look for the Python binary, which has to be at version 3.
ln -s /usr/bin/python3 /usr/bin/python &&\ ln -s /usr/bin/python3 /usr/bin/python &&\

View File

@@ -62,6 +62,10 @@ type Options struct {
// PageRanges allows to select the pages to convert. // PageRanges allows to select the pages to convert.
PageRanges string PageRanges string
// UpdateIndexes specifies whether to update the indexes before conversion
// or not, with the risk of disabling links in documents.
UpdateIndexes bool
// ExportFormFields specifies whether form fields are exported as widgets // ExportFormFields specifies whether form fields are exported as widgets
// or only their fixed print representation is exported. // or only their fixed print representation is exported.
ExportFormFields bool ExportFormFields bool
@@ -152,6 +156,7 @@ func DefaultOptions() Options {
Password: "", Password: "",
Landscape: false, Landscape: false,
PageRanges: "", PageRanges: "",
UpdateIndexes: true,
ExportFormFields: true, ExportFormFields: true,
AllowDuplicateFieldNames: false, AllowDuplicateFieldNames: false,
ExportBookmarks: true, ExportBookmarks: true,

View File

@@ -279,6 +279,10 @@ func (p *libreOfficeProcess) pdf(ctx context.Context, logger *zap.Logger, inputP
args = append(args, "--export", fmt.Sprintf("PageRange=%s", options.PageRanges)) args = append(args, "--export", fmt.Sprintf("PageRange=%s", options.PageRanges))
} }
if !options.UpdateIndexes {
args = append(args, "--disable-update-indexes")
}
args = append(args, "--export", fmt.Sprintf("ExportFormFields=%t", options.ExportFormFields)) args = append(args, "--export", fmt.Sprintf("ExportFormFields=%t", options.ExportFormFields))
args = append(args, "--export", fmt.Sprintf("AllowDuplicateFieldNames=%t", options.AllowDuplicateFieldNames)) args = append(args, "--export", fmt.Sprintf("AllowDuplicateFieldNames=%t", options.AllowDuplicateFieldNames))
args = append(args, "--export", fmt.Sprintf("ExportBookmarks=%t", options.ExportBookmarks)) args = append(args, "--export", fmt.Sprintf("ExportBookmarks=%t", options.ExportBookmarks))

View File

@@ -39,6 +39,7 @@ func convertRoute(libreOffice libreofficeapi.Uno, engine gotenberg.PdfEngine) ap
password string password string
landscape bool landscape bool
nativePageRanges string nativePageRanges string
updateIndexes bool
exportFormFields bool exportFormFields bool
allowDuplicateFieldNames bool allowDuplicateFieldNames bool
exportBookmarks bool exportBookmarks bool
@@ -68,6 +69,7 @@ func convertRoute(libreOffice libreofficeapi.Uno, engine gotenberg.PdfEngine) ap
String("password", &password, defaultOptions.Password). String("password", &password, defaultOptions.Password).
Bool("landscape", &landscape, defaultOptions.Landscape). Bool("landscape", &landscape, defaultOptions.Landscape).
String("nativePageRanges", &nativePageRanges, defaultOptions.PageRanges). String("nativePageRanges", &nativePageRanges, defaultOptions.PageRanges).
Bool("updateIndexes", &updateIndexes, defaultOptions.UpdateIndexes).
Bool("exportFormFields", &exportFormFields, defaultOptions.ExportFormFields). Bool("exportFormFields", &exportFormFields, defaultOptions.ExportFormFields).
Bool("allowDuplicateFieldNames", &allowDuplicateFieldNames, defaultOptions.AllowDuplicateFieldNames). Bool("allowDuplicateFieldNames", &allowDuplicateFieldNames, defaultOptions.AllowDuplicateFieldNames).
Bool("exportBookmarks", &exportBookmarks, defaultOptions.ExportBookmarks). Bool("exportBookmarks", &exportBookmarks, defaultOptions.ExportBookmarks).
@@ -149,6 +151,7 @@ func convertRoute(libreOffice libreofficeapi.Uno, engine gotenberg.PdfEngine) ap
Password: password, Password: password,
Landscape: landscape, Landscape: landscape,
PageRanges: nativePageRanges, PageRanges: nativePageRanges,
UpdateIndexes: updateIndexes,
ExportFormFields: exportFormFields, ExportFormFields: exportFormFields,
AllowDuplicateFieldNames: allowDuplicateFieldNames, AllowDuplicateFieldNames: allowDuplicateFieldNames,
ExportBookmarks: exportBookmarks, ExportBookmarks: exportBookmarks,