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

rbenet71 at gmail.com rbenet71 at gmail.com
Mon Jan 15 14:59:53 PST 2024


Hi Nyall,
 
                Thank you so much for your answer.
 
                    I put in yellow myAtlas.beginRender()
                 myAtlas.next()
 
                In my app there are more code obviously, but not affect, to generate the picture/PDF.
 
                For mi the problem is inside this order:
exporter.exportToPdf(file_name,pdf_settings)
 
                Something inside this order give the error.
 
                If I generate the picture with Qgis desktop program all works perfect, but if I do with “exporter.exportToPdf(file_name,pdf_settings)” then some elements not appear.
 
                Here you have and example.
 
                General Map have a lot of elements, I write a box where I make zoom.

                In Zoon_Map, you can see elements. Some of this elements not appear if I create the map with my code.
 

                I write a circle around and element.
 
                Thank you so much for your attention in advance.
 
Kind regards,
 
 
Robert Benet
De: Nyall Dawson <nyall.dawson at gmail.com> 
Enviado el: lunes, 15 de enero de 2024 7:57
Para: Roberto Benet <rbenet71 at gmail.com>
CC: qgis-developer <qgis-developer at lists.osgeo.org>
Asunto: Re: [QGIS-Developer] RV: PyQGIS QgsLayoutExporter gives error "QPen::setWidthF: Setting a pen width that is out of range"
 
 
On Sun, 14 Jan 2024, 6:35 pm Robert via QGIS-Developer, <qgis-developer at lists.osgeo.org <mailto:qgis-developer at lists.osgeo.org> > wrote:
 
# 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.
 
Have you stripped code out of this loop? Eg I can't see any call to atlas.next() within the loop.
 
In any case what you have looks generally ok. You'd need to share more of your code or project to diagnose further.
 
Nyall
 
Kind regards,
 
Robert Benet
 
_______________________________________________
QGIS-Developer mailing list
QGIS-Developer at lists.osgeo.org <mailto:QGIS-Developer at lists.osgeo.org> 
List info: https://lists.osgeo.org/mailman/listinfo/qgis-developer
Unsubscribe: https://lists.osgeo.org/mailman/listinfo/qgis-developer

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osgeo.org/pipermail/qgis-developer/attachments/20240115/4c21acb8/attachment-0001.htm>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: image001.png
Type: image/png
Size: 692698 bytes
Desc: not available
URL: <http://lists.osgeo.org/pipermail/qgis-developer/attachments/20240115/4c21acb8/attachment-0004.png>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: image002.png
Type: image/png
Size: 1677794 bytes
Desc: not available
URL: <http://lists.osgeo.org/pipermail/qgis-developer/attachments/20240115/4c21acb8/attachment-0005.png>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: General_Map.PNG
Type: image/png
Size: 692698 bytes
Desc: not available
URL: <http://lists.osgeo.org/pipermail/qgis-developer/attachments/20240115/4c21acb8/attachment-0006.png>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: Zoom_Map.PNG
Type: image/png
Size: 1677794 bytes
Desc: not available
URL: <http://lists.osgeo.org/pipermail/qgis-developer/attachments/20240115/4c21acb8/attachment-0007.png>


More information about the QGIS-Developer mailing list