|
65 | 65 | #include "qgsreportorganizerwidget.h"
|
66 | 66 | #include "qgsreadwritecontext.h"
|
67 | 67 | #include "ui_qgssvgexportoptions.h"
|
| 68 | +#include "ui_qgspdfexportoptions.h" |
68 | 69 | #include "qgsproxyprogresstask.h"
|
69 | 70 | #include "ui_defaults.h"
|
70 | 71 |
|
@@ -2067,13 +2068,15 @@ void QgsLayoutDesignerDialog::exportToPdf()
|
2067 | 2068 |
|
2068 | 2069 | mView->setPaintingEnabled( false );
|
2069 | 2070 | QgsTemporaryCursorOverride cursorOverride( Qt::BusyCursor );
|
| 2071 | + |
| 2072 | + QgsLayoutExporter::PdfExportSettings pdfSettings; |
| 2073 | + if ( !getPdfExportSettings( pdfSettings ) ) |
| 2074 | + return; |
| 2075 | + |
2070 | 2076 | QgsProxyProgressTask *proxyTask = new QgsProxyProgressTask( tr( "Exporting “%1”" ).arg( mMasterLayout->name() ) );
|
2071 | 2077 | QgsApplication::taskManager()->addTask( proxyTask );
|
2072 | 2078 |
|
2073 |
| - QgsLayoutExporter::PdfExportSettings pdfSettings; |
2074 | 2079 | pdfSettings.rasterizeWholeImage = mLayout->customProperty( QStringLiteral( "rasterize" ), false ).toBool();
|
2075 |
| - pdfSettings.forceVectorOutput = mLayout->customProperty( QStringLiteral( "forceVector" ), false ).toBool(); |
2076 |
| - pdfSettings.textRenderFormat = mLayout->project()->labelingEngineSettings().defaultTextRenderFormat(); |
2077 | 2080 |
|
2078 | 2081 | // force a refresh, to e.g. update data defined properties, tables, etc
|
2079 | 2082 | mLayout->refresh();
|
@@ -2970,9 +2973,10 @@ void QgsLayoutDesignerDialog::exportAtlasToPdf()
|
2970 | 2973 | QgsTemporaryCursorOverride cursorOverride( Qt::BusyCursor );
|
2971 | 2974 |
|
2972 | 2975 | QgsLayoutExporter::PdfExportSettings pdfSettings;
|
| 2976 | + if ( !getPdfExportSettings( pdfSettings ) ) |
| 2977 | + return; |
| 2978 | + |
2973 | 2979 | pdfSettings.rasterizeWholeImage = mLayout->customProperty( QStringLiteral( "rasterize" ), false ).toBool();
|
2974 |
| - pdfSettings.forceVectorOutput = mLayout->customProperty( QStringLiteral( "forceVector" ), false ).toBool(); |
2975 |
| - pdfSettings.textRenderFormat = mLayout->project()->labelingEngineSettings().defaultTextRenderFormat(); |
2976 | 2980 |
|
2977 | 2981 | QString error;
|
2978 | 2982 | std::unique_ptr< QgsFeedback > feedback = qgis::make_unique< QgsFeedback >();
|
@@ -3347,17 +3351,15 @@ void QgsLayoutDesignerDialog::exportReportToPdf()
|
3347 | 3351 | QgsTemporaryCursorOverride cursorOverride( Qt::BusyCursor );
|
3348 | 3352 |
|
3349 | 3353 | bool rasterize = false;
|
3350 |
| - bool forceVectorOutput = false; |
3351 | 3354 | if ( mLayout )
|
3352 | 3355 | {
|
3353 | 3356 | rasterize = mLayout->customProperty( QStringLiteral( "rasterize" ), false ).toBool();
|
3354 |
| - forceVectorOutput = mLayout->customProperty( QStringLiteral( "forceVector" ), false ).toBool(); |
3355 | 3357 | }
|
3356 | 3358 | QgsLayoutExporter::PdfExportSettings pdfSettings;
|
3357 |
| - // TODO - show a dialog allowing users to control these settings on a per-output basis |
| 3359 | + if ( !getPdfExportSettings( pdfSettings ) ) |
| 3360 | + return; |
| 3361 | + |
3358 | 3362 | pdfSettings.rasterizeWholeImage = rasterize;
|
3359 |
| - pdfSettings.forceVectorOutput = forceVectorOutput; |
3360 |
| - pdfSettings.textRenderFormat = mLayout->project()->labelingEngineSettings().defaultTextRenderFormat(); |
3361 | 3363 |
|
3362 | 3364 | QString error;
|
3363 | 3365 | std::unique_ptr< QgsFeedback > feedback = qgis::make_unique< QgsFeedback >();
|
@@ -4049,6 +4051,55 @@ bool QgsLayoutDesignerDialog::getSvgExportSettings( QgsLayoutExporter::SvgExport
|
4049 | 4051 | return true;
|
4050 | 4052 | }
|
4051 | 4053 |
|
| 4054 | +bool QgsLayoutDesignerDialog::getPdfExportSettings( QgsLayoutExporter::PdfExportSettings &settings ) |
| 4055 | +{ |
| 4056 | + QgsRenderContext::TextRenderFormat prevTextRenderFormat = mMasterLayout->layoutProject()->labelingEngineSettings().defaultTextRenderFormat(); |
| 4057 | + bool previousForceVector = false; |
| 4058 | + bool includeMetadata = true; |
| 4059 | + if ( mLayout ) |
| 4060 | + { |
| 4061 | + mLayout->customProperty( QStringLiteral( "forceVector" ), false ).toBool(); |
| 4062 | + includeMetadata = mLayout->customProperty( QStringLiteral( "pdfIncludeMetadata" ), 1 ).toBool(); |
| 4063 | + const int prevLayoutSettingLabelsAsOutlines = mLayout->customProperty( QStringLiteral( "pdfTextFormat" ), -1 ).toInt(); |
| 4064 | + if ( prevLayoutSettingLabelsAsOutlines >= 0 ) |
| 4065 | + { |
| 4066 | + // previous layout setting takes default over project setting |
| 4067 | + prevTextRenderFormat = static_cast< QgsRenderContext::TextRenderFormat >( prevLayoutSettingLabelsAsOutlines ); |
| 4068 | + } |
| 4069 | + } |
| 4070 | + |
| 4071 | + // open options dialog |
| 4072 | + QDialog dialog; |
| 4073 | + Ui::QgsPdfExportOptionsDialog options; |
| 4074 | + options.setupUi( &dialog ); |
| 4075 | + |
| 4076 | + options.mTextRenderFormatComboBox->addItem( tr( "Always Export Text as Paths (Recommended)" ), QgsRenderContext::TextFormatAlwaysOutlines ); |
| 4077 | + options.mTextRenderFormatComboBox->addItem( tr( "Always Export Text as Text Objects" ), QgsRenderContext::TextFormatAlwaysText ); |
| 4078 | + |
| 4079 | + options.mTextRenderFormatComboBox->setCurrentIndex( options.mTextRenderFormatComboBox->findData( prevTextRenderFormat ) ); |
| 4080 | + options.mForceVectorCheckBox->setChecked( previousForceVector ); |
| 4081 | + options.mIncludeMetadataCheckbox->setChecked( includeMetadata ); |
| 4082 | + |
| 4083 | + if ( dialog.exec() != QDialog::Accepted ) |
| 4084 | + return false; |
| 4085 | + |
| 4086 | + includeMetadata = options.mIncludeMetadataCheckbox->isChecked(); |
| 4087 | + QgsRenderContext::TextRenderFormat textRenderFormat = static_cast< QgsRenderContext::TextRenderFormat >( options.mTextRenderFormatComboBox->currentData().toInt() ); |
| 4088 | + |
| 4089 | + if ( mLayout ) |
| 4090 | + { |
| 4091 | + //save dialog settings |
| 4092 | + mLayout->setCustomProperty( QStringLiteral( "pdfIncludeMetadata" ), includeMetadata ? 1 : 0 ); |
| 4093 | + mLayout->setCustomProperty( QStringLiteral( "pdfTextFormat" ), static_cast< int >( textRenderFormat ) ); |
| 4094 | + } |
| 4095 | + |
| 4096 | + settings.forceVectorOutput = options.mForceVectorCheckBox->isChecked(); |
| 4097 | + settings.exportMetadata = includeMetadata; |
| 4098 | + settings.textRenderFormat = textRenderFormat; |
| 4099 | + |
| 4100 | + return true; |
| 4101 | +} |
| 4102 | + |
4052 | 4103 | void QgsLayoutDesignerDialog::toggleAtlasControls( bool atlasEnabled )
|
4053 | 4104 | {
|
4054 | 4105 | //preview defaults to unchecked
|
|
0 commit comments