Skip to content

Commit

Permalink
Small fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
nyalldawson committed Aug 17, 2019
1 parent ed077f9 commit b3d4faa
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 0 deletions.
2 changes: 2 additions & 0 deletions src/core/layout/qgslayoutexporter.cpp
Expand Up @@ -531,6 +531,8 @@ QgsLayoutExporter::ExportResult QgsLayoutExporter::exportToPdf( const QString &f

mLayout->renderContext().setFlag( QgsLayoutRenderContext::FlagForceVectorOutput, settings.forceVectorOutput );

mLayout->renderContext().setFlag( QgsLayoutRenderContext::FlagRenderLabelsByMapLayer, true );

mLayout->renderContext().setTextRenderFormat( settings.textRenderFormat );

ExportResult result = Success;
Expand Down
15 changes: 15 additions & 0 deletions src/core/layout/qgslayoutgeopdfexporter.cpp
Expand Up @@ -263,13 +263,28 @@ QString QgsLayoutGeoPdfExporter::createCompositionXml( const QList<ComponentLaye
// layertree
QDomElement layerTree = doc.createElement( QStringLiteral( "LayerTree" ) );
//layerTree.setAttribute( QStringLiteral("displayOnlyOnVisiblePages"), QStringLiteral("true"));
QSet< QString > createdLayerIds;
for ( const VectorComponentDetail &component : qgis::as_const( mVectorComponents ) )
{
QDomElement layer = doc.createElement( QStringLiteral( "Layer" ) );
layer.setAttribute( QStringLiteral( "id" ), component.mapLayerId );
layer.setAttribute( QStringLiteral( "name" ), component.name );
layer.setAttribute( QStringLiteral( "initiallyVisible" ), QStringLiteral( "true" ) );
layerTree.appendChild( layer );
createdLayerIds.insert( component.mapLayerId );
}
// some PDF components may not be linked to vector components - e.g. layers with labels but no features
for ( const ComponentLayerDetail &component : components )
{
if ( component.mapLayerId.isEmpty() || createdLayerIds.contains( component.mapLayerId ) )
continue;

QDomElement layer = doc.createElement( QStringLiteral( "Layer" ) );
layer.setAttribute( QStringLiteral( "id" ), component.mapLayerId );
layer.setAttribute( QStringLiteral( "name" ), component.name );
layer.setAttribute( QStringLiteral( "initiallyVisible" ), QStringLiteral( "true" ) );
layerTree.appendChild( layer );
createdLayerIds.insert( component.mapLayerId );
}
compositionElem.appendChild( layerTree );

Expand Down

0 comments on commit b3d4faa

Please sign in to comment.