filter/source/pdf/pdfexport.cxx | 11 ++++++++++- filter/source/pdf/pdfexport.hxx | 1 + 2 files changed, 11 insertions(+), 1 deletion(-)
New commits: commit 481bb66b2e12a2a885b1d963f719aa84069dc270 Author: Miklos Vajna <vmik...@collabora.com> AuthorDate: Wed Nov 23 13:39:40 2022 +0100 Commit: Miklos Vajna <vmik...@collabora.com> CommitDate: Wed Dec 7 07:40:01 2022 +0000 Related: tdf#54053 PDF export: add UNO API to customize the watermark font name The font name of the watermark text is currently hardwired to Helvetica, a sans-serif font. The problem is that this looks bad in case your document uses serif or monospace fonts. Or perhaps your document uses a single font and you want to make sure that the watermark uses exactly the same font. Fix the problem by adding a new "WatermarkFontName" PDF export filter option to specify the font name explicitly. Example cmdline usage: soffice --convert-to pdf:writer_pdf_Export:'{"Watermark":{"type":"string","value":"draft"}, "WatermarkFontName":{"type":"string","value":"Times"}}' test.odt (cherry picked from commit d1dd9b9733511ff451e264169537c08fa14c574f) Conflicts: filter/qa/pdf.cxx Change-Id: I2f065e1517236695b0a95369bdcd803125018587 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/143711 Tested-by: Jenkins CollaboraOffice <jenkinscollaboraoff...@gmail.com> Reviewed-by: Miklos Vajna <vmik...@collabora.com> diff --git a/filter/source/pdf/pdfexport.cxx b/filter/source/pdf/pdfexport.cxx index af21c7b1a9c8..0be005e1434c 100644 --- a/filter/source/pdf/pdfexport.cxx +++ b/filter/source/pdf/pdfexport.cxx @@ -107,6 +107,7 @@ PDFExport::PDFExport( const Reference< XComponent >& rxSrcDoc, mbIsRedactMode ( false ), maWatermarkColor ( COL_LIGHTGREEN ), + maWatermarkFontName ( "Helvetica" ), mbHideViewerToolbar ( false ), mbHideViewerMenubar ( false ), @@ -549,6 +550,14 @@ bool PDFExport::Export( const OUString& rFile, const Sequence< PropertyValue >& moWatermarkFontHeight = nFontHeight; } } + else if (rProp.Name == "WatermarkFontName") + { + OUString aFontName{}; + if (rProp.Value >>= aFontName) + { + maWatermarkFontName = aFontName; + } + } else if ( rProp.Name == "TiledWatermark" ) rProp.Value >>= msTiledWatermark; // now all the security related properties... @@ -1135,7 +1144,7 @@ void PDFExport::ImplExportPage( vcl::PDFWriter& rWriter, vcl::PDFExtOutDevData& void PDFExport::ImplWriteWatermark( vcl::PDFWriter& rWriter, const Size& rPageSize ) { - vcl::Font aFont( "Helvetica", Size( 0, moWatermarkFontHeight ? *moWatermarkFontHeight : 3*rPageSize.Height()/4 ) ); + vcl::Font aFont( maWatermarkFontName, Size( 0, moWatermarkFontHeight ? *moWatermarkFontHeight : 3*rPageSize.Height()/4 ) ); aFont.SetItalic( ITALIC_NONE ); aFont.SetWidthType( WIDTH_NORMAL ); aFont.SetWeight( WEIGHT_NORMAL ); diff --git a/filter/source/pdf/pdfexport.hxx b/filter/source/pdf/pdfexport.hxx index 489c3ec2e7a1..6fc98f6acd47 100644 --- a/filter/source/pdf/pdfexport.hxx +++ b/filter/source/pdf/pdfexport.hxx @@ -80,6 +80,7 @@ private: OUString msWatermark; Color maWatermarkColor; std::optional<sal_Int32> moWatermarkFontHeight; + OUString maWatermarkFontName; OUString msTiledWatermark; // these variable are here only to have a location in filter/pdf to set the default