Skip to content

Commit 469be12

Browse files
committed
Note about PdfFormat and NativeFormat for QPrinter PDF output and embedding fonts
- Unlike the Qt issues for NativeFormat on Mac, choosing to print, then Save as PDF, embeds fonts
1 parent 72c3379 commit 469be12

File tree

1 file changed

+11
-1
lines changed

1 file changed

+11
-1
lines changed

src/core/composer/qgscomposition.cpp

+11-1
Original file line numberDiff line numberDiff line change
@@ -2428,10 +2428,20 @@ void QgsComposition::deleteAndRemoveMultiFrames()
24282428

24292429
void QgsComposition::beginPrintAsPDF( QPrinter& printer, const QString& file )
24302430
{
2431-
printer.setOutputFormat( QPrinter::PdfFormat );
24322431
printer.setOutputFileName( file );
2432+
// setOutputFormat should come after setOutputFileName, which auto-sets format to QPrinter::PdfFormat.
2433+
// [LS] This should be QPrinter::NativeFormat for Mac, otherwise fonts are not embed-able
2434+
// and text is not searchable; however, there are several bugs with <= Qt 4.8.5, 5.1.1, 5.2.0:
2435+
// https://bugreports.qt-project.org/browse/QTBUG-10094 - PDF font embedding fails
2436+
// https://bugreports.qt-project.org/browse/QTBUG-33583 - PDF output converts text to outline
2437+
// Also an issue with PDF paper size using QPrinter::NativeFormat on Mac (always outputs portrait letter-size)
2438+
printer.setOutputFormat( QPrinter::PdfFormat );
24332439
printer.setPaperSize( QSizeF( paperWidth(), paperHeight() ), QPrinter::Millimeter );
24342440

2441+
// TODO: add option for this in Composer
2442+
// May not work on Windows or non-X11 Linux. Works fine on Mac using QPrinter::NativeFormat
2443+
//printer.setFontEmbeddingEnabled( true );
2444+
24352445
QgsPaintEngineHack::fixEngineFlags( printer.paintEngine() );
24362446
}
24372447

0 commit comments

Comments
 (0)