<div dir="ltr">I just tested the method shown in the Python Cookbook [1] instead of the exportAsPDF method, which also segfault my QGIS 2.4 (ubuntu) when the render method is called :<br><br><br>printer = QPrinter()<br>printer.setOutputFormat(QPrinter.PdfFormat)<br>
printer.setOutputFileName("/tmp/out.pdf")<br>printer.setPaperSize(QSizeF(c.paperWidth(), c.paperHeight()), QPrinter.Millimeter)<br>printer.setFullPage(True)<br>printer.setColorMode(QPrinter.Color)<br>printer.setResolution(c.printResolution())<br>
pdfPainter = QPainter(printer)<br>paperRectMM = printer.pageRect(QPrinter.Millimeter)<br>paperRectPixel = printer.pageRect(QPrinter.DevicePixel)<br><br>c.render(pdfPainter, paperRectPixel, paperRectMM)<br><br><br><br>[1] <a href="http://docs.qgis.org/testing/en/docs/pyqgis_developer_cookbook/composer.html#output-to-pdf">http://docs.qgis.org/testing/en/docs/pyqgis_developer_cookbook/composer.html#output-to-pdf</a><br>
<br><br></div><div class="gmail_extra"><br><br><div class="gmail_quote">2014-07-07 19:20 GMT+02:00 kimaidou <span dir="ltr"><<a href="mailto:kimaidou@gmail.com" target="_blank">kimaidou@gmail.com</a>></span>:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<div dir="ltr"><div><div><div><div><div>Hi all,<br><br></div>I would like to share an issue I am having while trying to simply export a composition as PDF.<br><br></div>Under QGIS 2.2, I had no problem, but QGIS 2.4 Segfault with the simple steps :<br>

<br></div>c = QgsComposition( QgsMapSettings() )<br>c.setPaperSize( 290, 210 )<br>c.setPrintResolution( 100 )<br>c.setSnapGridOffsetX( 3.5 )<br>c.setSnapGridOffsetY( 0 )<br>c.setSnapGridResolution( 2.5 )<br>c.setNumPages( 1 )<br>

<br>cl = QgsComposerLabel( c )<br>cl.setItemPosition( 0, 10, 100, 100 )<br>content = 'test'<br>cl.setText( content )<br>cl.setFrameEnabled( False )<br>c.addItem( cl )<br><br>c.exportAsPDF( '/tmp/test.pdf' )<br>

</div><br></div><div>NB: I just discoverd that QgsComposition( QgsMapRenderer() ) is deprecated since QGIS 2.4 as explained here: <a href="http://www2.qgis.org/api/deprecated.html" target="_blank">http://www2.qgis.org/api/deprecated.html</a><br>

</div><div>But using it or the new instanciation does not change the problem.<br><br></div><div>Has anyone any hint on this issue ?<br><br>Thanks in advance<br>Michael<br></div><br></div>
</blockquote></div><br></div>