<div dir="ltr"><div class="gmail_quote"><div dir="ltr"><div class="gmail_quote"><div><div lang="ES" link="#0563C1" vlink="#954F72" style="word-wrap:break-word"><div><p style="margin-right:0cm;margin-bottom:12.0pt;margin-left:0cm;background:white"><span lang="EN-US" style="font-size:10.5pt;font-family:"Segoe UI",sans-serif;color:#1f2328">Hello,<u></u><u></u></span></p><p style="margin-right:0cm;margin-bottom:12.0pt;margin-left:0cm;background:white"><span lang="EN-US" style="font-size:10.5pt;font-family:"Segoe UI",sans-serif;color:#1f2328">I have a <span>PyQGIS</span> app, that generates a PDFs from an Atlas.<u></u><u></u></span></p><p style="margin-right:0cm;margin-bottom:12.0pt;margin-left:0cm;background:white;box-sizing:border-box;font-variant-ligatures:normal;font-variant-caps:normal;text-align:start;text-decoration-style:initial;text-decoration-color:initial;word-spacing:0px"><span lang="EN-US" style="font-size:10.5pt;font-family:"Segoe UI",sans-serif;color:#1f2328">If I generate the PDF directly from QGIS Desktop all PDF generate correctly.<u></u><u></u></span></p><p style="margin-right:0cm;margin-bottom:12.0pt;margin-left:0cm;background:white;box-sizing:border-box;font-variant-ligatures:normal;font-variant-caps:normal;text-align:start;text-decoration-style:initial;text-decoration-color:initial;word-spacing:0px"><span lang="EN-US" style="font-size:10.5pt;font-family:"Segoe UI",sans-serif;color:#1f2328">But If I generate the PDF with my <span>PyQGIS</span> app, some PDF don't generate properly (some elements do not appear) and give error "<span>QPen</span>::<span>setWidthF</span>: Setting a pen width that is out of range".<u></u><u></u></span></p><p style="margin-right:0cm;margin-bottom:12.0pt;margin-left:0cm;background:white;box-sizing:border-box;font-variant-ligatures:normal;font-variant-caps:normal;text-align:start;text-decoration-style:initial;text-decoration-color:initial;word-spacing:0px"><span lang="EN-US" style="font-size:10.5pt;font-family:"Segoe UI",sans-serif;color:#1f2328">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.<u></u><u></u></span></p><p style="margin-right:0cm;margin-bottom:12.0pt;margin-left:0cm;background:white;box-sizing:border-box;font-variant-ligatures:normal;font-variant-caps:normal;text-align:start;text-decoration-style:initial;text-decoration-color:initial;word-spacing:0px"><span lang="EN-US" style="font-size:10.5pt;font-family:"Segoe UI",sans-serif;color:#1f2328">One year ago, this app works perfect.<u></u><u></u></span></p><p style="margin-right:0cm;margin-bottom:12.0pt;margin-left:0cm;background:white;box-sizing:border-box;font-variant-ligatures:normal;font-variant-caps:normal;text-align:start;text-decoration-style:initial;text-decoration-color:initial;word-spacing:0px"><span lang="EN-US" style="font-size:10.5pt;font-family:"Segoe UI",sans-serif;color:#1f2328">I have tried to change all PDF export options, but the error continues.<u></u><u></u></span></p><p style="margin-right:0cm;margin-bottom:12.0pt;margin-left:0cm;background:white;box-sizing:border-box;font-variant-ligatures:normal;font-variant-caps:normal;text-align:start;text-decoration-style:initial;text-decoration-color:initial;word-spacing:0px"><span lang="EN-US" style="font-size:10.5pt;font-family:"Segoe UI",sans-serif;color:#1f2328">I make this question in <span>Gis</span> <span>StackExchange</span>, and no one give any answer:<u></u><u></u></span></p><p style="margin-right:0cm;margin-bottom:12.0pt;margin-left:0cm;background:white;box-sizing:border-box;font-variant-ligatures:normal;font-variant-caps:normal;text-align:start;text-decoration-style:initial;text-decoration-color:initial;word-spacing:0px"><span style="font-size:10.5pt;font-family:"Segoe UI",sans-serif;color:#1f2328"><a href="https://gis.stackexchange.com/questions/469644/pyqgis-qgslayoutexporter-gives-error-qpensetwidthf-setting-a-pen-width-that" target="_blank"><span lang="EN-US">https://gis.stackexchange.com/questions/469644/pyqgis-qgslayoutexporter-gives-error-qpensetwidthf-setting-a-pen-width-that</span></a></span><span lang="EN-US" style="font-size:10.5pt;font-family:"Segoe UI",sans-serif;color:#1f2328"><u></u><u></u></span></p><p style="margin-right:0cm;margin-bottom:12.0pt;margin-left:0cm;background:white;box-sizing:border-box;font-variant-ligatures:normal;font-variant-caps:normal;text-align:start;text-decoration-style:initial;text-decoration-color:initial;word-spacing:0px"><span lang="EN-US" style="font-size:10.5pt;font-family:"Segoe UI",sans-serif;color:#1f2328">Here is a part of my code:<u></u><u></u></span></p><pre style="background:white;box-sizing:border-box;color:var(--fgColor-default,var(--color-fg-default));background-color:var(--bgColor-muted,var(--color-canvas-subtle));border-radius:6px;overflow:auto"><code><span lang="EN-US" style="font-size:9.0pt;font-family:Consolas;color:#1f2328;border:none windowtext 1.0pt;padding:0cm"># Generate atlas</span></code><code><span lang="EN-US" style="font-size:9.0pt;font-family:Consolas;border:none windowtext 1.0pt;padding:0cm"><u></u><u></u></span></code></pre><pre style="background:white"><code><span lang="EN-US" style="font-size:9.0pt;font-family:Consolas;color:#1f2328;border:none windowtext 1.0pt;padding:0cm"># Es <span>una</span> <span>QgsLayoutAtlas</span><u></u><u></u></span></code></pre><pre style="background:white"><span><code><span lang="EN-US" style="font-size:9.0pt;font-family:Consolas;color:#1f2328;border:none windowtext 1.0pt;padding:0cm">myAtlas.beginRender</span></code></span><code><span lang="EN-US" style="font-size:9.0pt;font-family:Consolas;color:#1f2328;border:none windowtext 1.0pt;padding:0cm">()<u></u><u></u></span></code></pre><pre style="background:white"><span><code><span lang="EN-US" style="font-size:9.0pt;font-family:Consolas;color:#1f2328;border:none windowtext 1.0pt;padding:0cm">myAtlas.next</span></code></span><code><span lang="EN-US" style="font-size:9.0pt;font-family:Consolas;color:#1f2328;border:none windowtext 1.0pt;padding:0cm">()<u></u><u></u></span></code></pre><pre style="background:white"><code><span lang="EN-US" style="font-size:9.0pt;font-family:Consolas;color:#1f2328;border:none windowtext 1.0pt;padding:0cm">for <span>i</span> in range(0, <span>myAtlas.count</span>()):<u></u><u></u></span></code></pre><pre style="background:white"><code><span lang="EN-US" style="font-size:9.0pt;font-family:Consolas;color:#1f2328;border:none windowtext 1.0pt;padding:0cm"><u></u> <u></u></span></code></pre><pre style="background:white"><code><span lang="EN-US" style="font-size:9.0pt;font-family:Consolas;color:#1f2328;border:none windowtext 1.0pt;padding:0cm"><span>    </span>exporter = <span>QgsLayoutExporter</span>(<span>myAtlas.layout</span>())<u></u><u></u></span></code></pre><pre style="background:white"><code><span lang="EN-US" style="font-size:9.0pt;font-family:Consolas;color:#1f2328;border:none windowtext 1.0pt;padding:0cm">file_name=os.path.join(dir_destiny,'Individuals')+'/'+myAtlas.currentFilename()+".pdf"<span>   </span><u></u><u></u></span></code></pre><pre style="background:white"><code><span lang="EN-US" style="font-size:9.0pt;font-family:Consolas;color:#1f2328;border:none windowtext 1.0pt;padding:0cm"><u></u> <u></u></span></code></pre><pre style="background:white"><code><span lang="EN-US" style="font-size:9.0pt;font-family:Consolas;color:#1f2328;border:none windowtext 1.0pt;padding:0cm"><span>    </span><span>pdf_settings</span>=<span>QgsLayoutExporter.PdfExportSettings</span>()<u></u><u></u></span></code></pre><pre style="background:white"><code><span lang="EN-US" style="font-size:9.0pt;font-family:Consolas;color:#1f2328;border:none windowtext 1.0pt;padding:0cm"><span>    </span><span>pdf_settings.forceVectorOutput</span>=False<u></u><u></u></span></code></pre><pre style="background:white"><code><span lang="EN-US" style="font-size:9.0pt;font-family:Consolas;color:#1f2328;border:none windowtext 1.0pt;padding:0cm"><span>    </span><span>pdf_settings.exportMetadata</span> = False<u></u><u></u></span></code></pre><pre style="background:white"><code><span lang="EN-US" style="font-size:9.0pt;font-family:Consolas;color:#1f2328;border:none windowtext 1.0pt;padding:0cm"><span>    </span><span>pdf_settings.appendGeoreference</span> = False<u></u><u></u></span></code></pre><pre style="background:white"><code><span lang="EN-US" style="font-size:9.0pt;font-family:Consolas;color:#1f2328;border:none windowtext 1.0pt;padding:0cm"><span>    </span><u></u><u></u></span></code></pre><pre style="background:white"><code><span lang="EN-US" style="font-size:9.0pt;font-family:Consolas;color:#1f2328;border:none windowtext 1.0pt;padding:0cm"><span>    </span>#pdf_settings.textRenderFormat = <span><span>QgsRenderContext.TextFormatAlwaysOutlines</span></span><span><span>  </span>#</span> For "Always Export Text as Paths"<u></u><u></u></span></code></pre><pre style="background:white"><code><span lang="EN-US" style="font-size:9.0pt;font-family:Consolas;color:#1f2328;border:none windowtext 1.0pt;padding:0cm"><span>    </span><span>pdf_settings.textRenderFormat</span> = <span>QgsRenderContext.TextFormatAlwaysText</span> # For "Always Export Text as Text Objects"<u></u><u></u></span></code></pre><pre style="background:white"><code><span lang="EN-US" style="font-size:9.0pt;font-family:Consolas;color:#1f2328;border:none windowtext 1.0pt;padding:0cm"><u></u> <u></u></span></code></pre><pre style="background:white"><code><span lang="EN-US" style="font-size:9.0pt;font-family:Consolas;color:#1f2328;border:none windowtext 1.0pt;padding:0cm"><span>    </span><span>pdf_settings.rasterizeWholeImage</span> = True # For "Disable tiled raster layer exports" <span>Hace</span> que <span>ocupe</span> <span>menos</span> <span>si</span> es TRUE<u></u><u></u></span></code></pre><pre style="background:white"><code><span lang="EN-US" style="font-size:9.0pt;font-family:Consolas;color:#1f2328;border:none windowtext 1.0pt;padding:0cm"><span>    </span><span>pdf_settings.simplifyGeometries</span> = False<u></u><u></u></span></code></pre><pre style="background:white"><code><span lang="EN-US" style="font-size:9.0pt;font-family:Consolas;color:#1f2328;border:none windowtext 1.0pt;padding:0cm"><u></u> <u></u></span></code></pre><pre style="background:white"><code><span lang="EN-US" style="font-size:9.0pt;font-family:Consolas;color:#1f2328;border:none windowtext 1.0pt;padding:0cm"><span>    </span><span>exporter.exportToPdf</span>(<span>file_name,pdf_settings</span>)</span></code><span lang="EN-US"><u></u><u></u></span></pre><p class="MsoNormal"><span lang="EN-US"><u></u> <u></u></span></p><p class="MsoNormal"><span lang="EN-US">Thank you In advance for your attention and help.<u></u><u></u></span></p><p class="MsoNormal"><span lang="EN-US"><u></u> <u></u></span></p><p class="MsoNormal"><span lang="EN-US">Kind regards,<u></u><u></u></span></p><p class="MsoNormal"><span lang="EN-US"><u></u> <u></u></span></p><p class="MsoNormal"><span lang="EN-US">Robert Benet<u></u><u></u></span></p><p class="MsoNormal"><span><u></u> <u></u></span></p></div></div></div></div></div>
</div></div>