31 QStringList QgsLayoutAtlasToPdfAlgorithmBase::tags()
 const 
   33   return QObject::tr( 
"layout,atlas,composer,composition,save" ).split( 
',' );
 
   36 QString QgsLayoutAtlasToPdfAlgorithmBase::group()
 const 
   38   return QObject::tr( 
"Cartography" );
 
   41 QString QgsLayoutAtlasToPdfAlgorithmBase::groupId()
 const 
   43   return QStringLiteral( 
"cartography" );
 
   46 QgsProcessingAlgorithm::Flags QgsLayoutAtlasToPdfAlgorithmBase::flags()
 const 
   51 void QgsLayoutAtlasToPdfAlgorithmBase::initAlgorithm( 
const QVariantMap & )
 
   56   addParameter( 
new QgsProcessingParameterExpression( QStringLiteral( 
"FILTER_EXPRESSION" ), QObject::tr( 
"Filter expression" ), QString(), QStringLiteral( 
"COVERAGE_LAYER" ), 
true ) );
 
   57   addParameter( 
new QgsProcessingParameterExpression( QStringLiteral( 
"SORTBY_EXPRESSION" ), QObject::tr( 
"Sort expression" ), QString(), QStringLiteral( 
"COVERAGE_LAYER" ), 
true ) );
 
   58   addParameter( 
new QgsProcessingParameterBoolean( QStringLiteral( 
"SORTBY_REVERSE" ), QObject::tr( 
"Reverse sort order (used when a sort expression is provided)" ), 
false, 
true ) );
 
   60   std::unique_ptr< QgsProcessingParameterMultipleLayers > layersParam = std::make_unique< QgsProcessingParameterMultipleLayers>( QStringLiteral( 
"LAYERS" ), QObject::tr( 
"Map layers to assign to unlocked map item(s)" ), 
QgsProcessing::TypeMapLayer, QVariant(), 
true );
 
   62   addParameter( layersParam.release() );
 
   64   std::unique_ptr< QgsProcessingParameterNumber > dpiParam = std::make_unique< QgsProcessingParameterNumber >( QStringLiteral( 
"DPI" ), QObject::tr( 
"DPI (leave blank for default layout DPI)" ), 
QgsProcessingParameterNumber::Double, QVariant(), 
true, 0 );
 
   66   addParameter( dpiParam.release() );
 
   68   std::unique_ptr< QgsProcessingParameterBoolean > forceVectorParam = std::make_unique< QgsProcessingParameterBoolean >( QStringLiteral( 
"FORCE_VECTOR" ), QObject::tr( 
"Always export as vectors" ), 
false );
 
   70   addParameter( forceVectorParam.release() );
 
   72   std::unique_ptr< QgsProcessingParameterBoolean > appendGeorefParam = std::make_unique< QgsProcessingParameterBoolean >( QStringLiteral( 
"GEOREFERENCE" ), QObject::tr( 
"Append georeference information" ), 
true );
 
   74   addParameter( appendGeorefParam.release() );
 
   76   std::unique_ptr< QgsProcessingParameterBoolean > exportRDFParam = std::make_unique< QgsProcessingParameterBoolean >( QStringLiteral( 
"INCLUDE_METADATA" ), QObject::tr( 
"Export RDF metadata (title, author, etc.)" ), 
true );
 
   78   addParameter( exportRDFParam.release() );
 
   80   std::unique_ptr< QgsProcessingParameterBoolean > disableTiled = std::make_unique< QgsProcessingParameterBoolean >( QStringLiteral( 
"DISABLE_TILED" ), QObject::tr( 
"Disable tiled raster layer exports" ), 
false );
 
   82   addParameter( disableTiled.release() );
 
   84   std::unique_ptr< QgsProcessingParameterBoolean > simplify = std::make_unique< QgsProcessingParameterBoolean >( QStringLiteral( 
"SIMPLIFY" ), QObject::tr( 
"Simplify geometries to reduce output file size" ), 
true );
 
   86   addParameter( simplify.release() );
 
   88   const QStringList textExportOptions
 
   90     QObject::tr( 
"Always Export Text as Paths (Recommended)" ),
 
   91     QObject::tr( 
"Always Export Text as Text Objects" )
 
   94   std::unique_ptr< QgsProcessingParameterEnum > textFormat = std::make_unique< QgsProcessingParameterEnum >( QStringLiteral( 
"TEXT_FORMAT" ), QObject::tr( 
"Text export" ), textExportOptions, 
false, 0 );
 
   96   addParameter( textFormat.release() );
 
  102   QgsPrintLayout *l = parameterAsLayout( parameters, QStringLiteral( 
"LAYOUT" ), context );
 
  104     throw QgsProcessingException( QObject::tr( 
"Cannot find layout with name \"%1\"" ).arg( parameters.value( QStringLiteral( 
"LAYOUT" ) ).toString() ) );
 
  106   std::unique_ptr< QgsPrintLayout > layout( l->
clone() );
 
  109   QString expression, error;
 
  110   QgsVectorLayer *layer = parameterAsVectorLayer( parameters, QStringLiteral( 
"COVERAGE_LAYER" ), context );
 
  116     expression = parameterAsString( parameters, QStringLiteral( 
"FILTER_EXPRESSION" ), context );
 
  119     if ( !expression.isEmpty() && !error.isEmpty() )
 
  125     expression = parameterAsString( parameters, QStringLiteral( 
"SORTBY_EXPRESSION" ), context );
 
  126     if ( !expression.isEmpty() )
 
  128       const bool sortByReverse = parameterAsBool( parameters, QStringLiteral( 
"SORTBY_REVERSE" ), context );
 
  140     throw QgsProcessingException( QObject::tr( 
"Selected layout does not have atlas functionality enabled" ) );
 
  146   if ( parameters.value( QStringLiteral( 
"DPI" ) ).isValid() )
 
  148     settings.
dpi = parameterAsDouble( parameters, QStringLiteral( 
"DPI" ), context );
 
  150   settings.
forceVectorOutput = parameterAsBool( parameters, QStringLiteral( 
"FORCE_VECTOR" ), context );
 
  151   settings.
appendGeoreference = parameterAsBool( parameters, QStringLiteral( 
"GEOREFERENCE" ), context );
 
  152   settings.
exportMetadata = parameterAsBool( parameters, QStringLiteral( 
"INCLUDE_METADATA" ), context );
 
  153   settings.
simplifyGeometries = parameterAsBool( parameters, QStringLiteral( 
"SIMPLIFY" ), context );
 
  154   settings.
textRenderFormat = parameterAsEnum( parameters, QStringLiteral( 
"TEXT_FORMAT" ), context ) == 0 ? Qgis::TextRenderFormat::AlwaysOutlines : Qgis::TextRenderFormat::AlwaysText;
 
  156   if ( parameterAsBool( parameters, QStringLiteral( 
"DISABLE_TILED" ), context ) )
 
  163   const QList< QgsMapLayer * > layers = parameterAsLayerList( parameters, QStringLiteral( 
"LAYERS" ), context );
 
  164   if ( layers.size() > 0 )
 
  166     const QList<QGraphicsItem *> items = layout->items();
 
  167     for ( QGraphicsItem *graphicsItem : items )
 
  179   return exportAtlas( atlas, exporter, settings, parameters, context, feedback );
 
  186 QString QgsLayoutAtlasToPdfAlgorithm::name()
 const 
  188   return QStringLiteral( 
"atlaslayouttopdf" );
 
  191 QString QgsLayoutAtlasToPdfAlgorithm::displayName()
 const 
  193   return QObject::tr( 
"Export atlas layout as PDF (single file)" );
 
  196 QString QgsLayoutAtlasToPdfAlgorithm::shortDescription()
 const 
  198   return QObject::tr( 
"Exports an atlas layout as a single PDF file." );
 
  201 QString QgsLayoutAtlasToPdfAlgorithm::shortHelpString()
 const 
  203   return QObject::tr( 
"This algorithm outputs an atlas layout as a single PDF file.\n\n" 
  204                       "If a coverage layer is set, the selected layout's atlas settings exposed in this algorithm " 
  205                       "will be overwritten. In this case, an empty filter or sort by expression will turn those " 
  209 void QgsLayoutAtlasToPdfAlgorithm::initAlgorithm( 
const QVariantMap & )
 
  211   QgsLayoutAtlasToPdfAlgorithmBase::initAlgorithm();
 
  215 QgsLayoutAtlasToPdfAlgorithm *QgsLayoutAtlasToPdfAlgorithm::createInstance()
 const 
  217   return new QgsLayoutAtlasToPdfAlgorithm();
 
  225   const QString dest = parameterAsFileOutput( parameters, QStringLiteral( 
"OUTPUT" ), context );
 
  230     feedback->
pushInfo( QObject::tr( 
"Exporting %n atlas feature(s)", 
"", atlas->
count() ) );
 
  235         feedback->
pushInfo( QObject::tr( 
"Successfully exported atlas to %1" ).arg( QDir::toNativeSeparators( dest ) ) );
 
  240         throw QgsProcessingException( QObject::tr( 
"Cannot write to %1.\n\nThis file may be open in another application." ).arg( QDir::toNativeSeparators( dest ) ) );
 
  247                                       "resulted in a memory overflow.\n\n" 
  248                                       "Please try a lower resolution or a smaller paper size." ) );
 
  261     feedback->
reportError( QObject::tr( 
"No atlas features found" ) );
 
  267   outputs.insert( QStringLiteral( 
"OUTPUT" ), dest );
 
  275 QString QgsLayoutAtlasToMultiplePdfAlgorithm::name()
 const 
  277   return QStringLiteral( 
"atlaslayouttomultiplepdf" );
 
  280 QString QgsLayoutAtlasToMultiplePdfAlgorithm::displayName()
 const 
  282   return QObject::tr( 
"Export atlas layout as PDF (multiple files)" );
 
  285 QString QgsLayoutAtlasToMultiplePdfAlgorithm::shortDescription()
 const 
  287   return QObject::tr( 
"Exports an atlas layout to multiple PDF files." );
 
  290 QString QgsLayoutAtlasToMultiplePdfAlgorithm::shortHelpString()
 const 
  292   return QObject::tr( 
"This algorithm outputs an atlas layout to multiple PDF files.\n\n" 
  293                       "If a coverage layer is set, the selected layout's atlas settings exposed in this algorithm " 
  294                       "will be overwritten. In this case, an empty filter or sort by expression will turn those " 
  299 void QgsLayoutAtlasToMultiplePdfAlgorithm::initAlgorithm( 
const QVariantMap & )
 
  301   QgsLayoutAtlasToPdfAlgorithmBase::initAlgorithm();
 
  302   addParameter( 
new QgsProcessingParameterExpression( QStringLiteral( 
"OUTPUT_FILENAME" ), QObject::tr( 
"Output filename" ), QString(), QStringLiteral( 
"COVERAGE_LAYER" ), 
true ) );
 
  306 QgsLayoutAtlasToMultiplePdfAlgorithm *QgsLayoutAtlasToMultiplePdfAlgorithm::createInstance()
 const 
  308   return new QgsLayoutAtlasToMultiplePdfAlgorithm();
 
  318   const QString filename = parameterAsString( parameters, QStringLiteral( 
"OUTPUT_FILENAME" ), context );
 
  319   const QString destFolder = parameterAsFile( parameters, QStringLiteral( 
"OUTPUT_FOLDER" ), context );
 
  322   const QString dest = QStringLiteral( 
"%1/atlas.pdf" ).arg( destFolder );
 
  326     feedback->
pushInfo( QObject::tr( 
"Exporting %n atlas feature(s)", 
"", atlas->
count() ) );
 
  333     else if ( !filename.isEmpty() )
 
  337         throw QgsProcessingException( QObject::tr( 
"Output file name expression is not valid: %1" ).arg( error ) );
 
  347         feedback->
pushInfo( QObject::tr( 
"Successfully exported atlas to %1" ).arg( QDir::toNativeSeparators( destFolder ) ) );
 
  352         throw QgsProcessingException( QObject::tr( 
"Cannot write to %1.\n\nThis file may be open in another application." ).arg( QDir::toNativeSeparators( dest ) ) );
 
  359                                       "resulted in a memory overflow.\n\n" 
  360                                       "Please try a lower resolution or a smaller paper size." ) );
 
  373     feedback->
reportError( QObject::tr( 
"No atlas features found" ) );
 
  379   outputs.insert( QStringLiteral( 
"OUTPUT_FOLDER" ), destFolder );