[Qgis-user] Segfault when using QgsComposition::exportAsPDF with QGIS 2.4 and python

kimaidou kimaidou at gmail.com
Mon Jul 7 10:46:46 PDT 2014


Last test : No segfault if I save an image with the method2 method :

https://gist.github.com/mdouchin/6d7408980f737959075b

It seems my segfault is related to the use of the PDF printer in my Ubuntu
box.

Any help appreciated.

Regards,
Michael


2014-07-07 19:38 GMT+02:00 kimaidou <kimaidou at gmail.com>:

> 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 :
>
>
> printer = QPrinter()
> printer.setOutputFormat(QPrinter.PdfFormat)
> printer.setOutputFileName("/tmp/out.pdf")
> printer.setPaperSize(QSizeF(c.paperWidth(), c.paperHeight()),
> QPrinter.Millimeter)
> printer.setFullPage(True)
> printer.setColorMode(QPrinter.Color)
> printer.setResolution(c.printResolution())
> pdfPainter = QPainter(printer)
> paperRectMM = printer.pageRect(QPrinter.Millimeter)
> paperRectPixel = printer.pageRect(QPrinter.DevicePixel)
>
> c.render(pdfPainter, paperRectPixel, paperRectMM)
>
>
>
> [1]
> http://docs.qgis.org/testing/en/docs/pyqgis_developer_cookbook/composer.html#output-to-pdf
>
>
>
>
> 2014-07-07 19:20 GMT+02:00 kimaidou <kimaidou at gmail.com>:
>
> Hi all,
>>
>> I would like to share an issue I am having while trying to simply export
>> a composition as PDF.
>>
>> Under QGIS 2.2, I had no problem, but QGIS 2.4 Segfault with the simple
>> steps :
>>
>> c = QgsComposition( QgsMapSettings() )
>> c.setPaperSize( 290, 210 )
>> c.setPrintResolution( 100 )
>> c.setSnapGridOffsetX( 3.5 )
>> c.setSnapGridOffsetY( 0 )
>> c.setSnapGridResolution( 2.5 )
>> c.setNumPages( 1 )
>>
>> cl = QgsComposerLabel( c )
>> cl.setItemPosition( 0, 10, 100, 100 )
>> content = 'test'
>> cl.setText( content )
>> cl.setFrameEnabled( False )
>> c.addItem( cl )
>>
>> c.exportAsPDF( '/tmp/test.pdf' )
>>
>> NB: I just discoverd that QgsComposition( QgsMapRenderer() ) is
>> deprecated since QGIS 2.4 as explained here:
>> http://www2.qgis.org/api/deprecated.html
>> But using it or the new instanciation does not change the problem.
>>
>> Has anyone any hint on this issue ?
>>
>> Thanks in advance
>> Michael
>>
>>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osgeo.org/pipermail/qgis-user/attachments/20140707/9b10f093/attachment.html>


More information about the Qgis-user mailing list