[QGIS-Developer] Fwd: PyQGIS QgsLayoutExporter gives error "QPen::setWidthF: Setting a pen width that is out of range"

roberto benet rbenet71 at gmail.com
Fri Dec 15 00:46:42 PST 2023


Hello,

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

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

But If I generate the PDF with my PyQGIS app, some PDF don't generate
properly (some elements do not appear) and give error "QPen::setWidthF:
Setting a pen width that is out of range".

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

One year ago, this app works perfect.

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

I make this question in Gis StackExchange, and no one give any answer:

https://gis.stackexchange.com/questions/469644/pyqgis-qgslayoutexporter-gives-error-qpensetwidthf-setting-a-pen-width-that

Here is a part of my code:

# Generate atlas

# Es una QgsLayoutAtlas

myAtlas.beginRender()

myAtlas.next()

for i in range(0, myAtlas.count()):



    exporter = QgsLayoutExporter(myAtlas.layout())

file_name=os.path.join(dir_destiny,'Individuals')+'/'+myAtlas.currentFilename()+".pdf"



    pdf_settings=QgsLayoutExporter.PdfExportSettings()

    pdf_settings.forceVectorOutput=False

    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



    exporter.exportToPdf(file_name,pdf_settings)



Thank you In advance for your attention and help.



Kind regards,



Robert Benet
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osgeo.org/pipermail/qgis-developer/attachments/20231215/999a4a37/attachment.htm>


More information about the QGIS-Developer mailing list