I have a PyQGIS app, that generates PDFs from an Atlas.

If I generate the PDF directly from QGIS all PDFs generate correctly.

But If I generate the PDF with my PyQGIS app, some PDFs don't generate properly (some elements do not appear) and give the error:

"QPen::setWidthF: Setting a pen width that is out of range".

The first PDF contains all the elements, the other PDFs are parts of the first PDF, so the elements that are missing in some PDFs are in the first.

One year ago, this app worked perfectly.

I have tried to change all PDF export options, but the error continues.

Here is a part of my code:

# Generate atlas
# Es una QgsLayoutAtlas
for i in range(0, myAtlas.count()):

    exporter = QgsLayoutExporter(myAtlas.layout())

    pdf_settings = QgsLayoutExporter.PdfExportSettings()
    pdf_settings.exportMetadata = False
    pdf_settings.appendGeoreference = False
    #pdf_settings.textRenderFormat = QgsRenderContext.TextFormatAlwaysOutlines  # For "Always Export Text as Paths"
    pdf_settings.textRenderFormat = QgsRenderContext.TextFormatAlwaysText # For "Always Export Text as Text Objects"

    pdf_settings.rasterizeWholeImage = True # For "Disable tiled raster layer exports" Hace que ocupe menos si es TRUE
    pdf_settings.simplifyGeometries = False

  • You can try to set no pen with this pdf_settings.painter = setPen(Qt.NoPen) or to get an invisible QPen with this pdf_settings.painter = setPen(QPen(Qt.NoPen))
    – Taras
    Nov 5, 2023 at 12:43
  • @Taras something is wrong. Give me this error: 'AttributeError: 'PdfExportSettings' object has no attribute 'painter''
    – RBenet
    Nov 5, 2023 at 21:19


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Browse other questions tagged or ask your own question.