Bug report #7894

QGIS Server - GetPrint request does not respect text boxes size and position if dynamic content passed

Added by Michael Douchin almost 11 years ago. Updated almost 11 years ago.

Status:Closed
Priority:Normal
Assignee:René-Luc ReLuc
Category:QGIS Server
Affected QGIS version:master Regression?:No
Operating System: Easy fix?:No
Pull Request or Patch supplied:No Resolution:
Crashes QGIS or corrupts data:No Copied to github as #:16767

Description

I have set up a simple composer in QGIS (last master, compiled this morning). See attached picture qgis_composer.png

When I export in PDF from QGIS desktop composer, I get the attached pdf qgis_pdf

When I ran the request [1] which is the getprint (proxy done by LizMap-Web-Client to hide the map parameter), I get the attached pdf getprind_pdf Basically I added the parameter truc=MY FOO TITLE <b>BOLD</b> )

When I ran the same request but with a longer "truc" parameter, like &truc=MY FOO TITLE <b>BOLD</b><p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Quisque luctus adipiscing fringilla. Fusce eget justo tellus. Maecenas dolor augue, sollicitudin at iaculis et, congue et metus. Aenean tincidunt ipsum sit amet ipsum ornare fermentum. Proin fringilla laoreet hendrerit. Curabitur dui urna, interdum tempus blandit eu,</p>

I get the attached PDF getprint_long_pdf.pdf

So it appears that the dynamic replacement via the GetPrint request does not respect the position and size of my "truc" text box, whereas the desktop composer does.
Or this is a problem with word wrapping perhaps ?

[1] http://localhost/LIZMAP/lizmap-web-client/lizmap/www/index.php/lizmap/service/?repository=dev&project=dev_print&SERVICE=WMS&VERSION=1.3&REQUEST=GetPrint&FORMAT=pdf&EXCEPTIONS=application/vnd.ogc.se_inimage&TRANSPARENT=true&SRS=EPSG:3857&DPI=300&TEMPLATE=lizmap&map0:extent=423524.8086443924,5400434.830480828,431474.979630755,5410235.04125647&map0:rotation=0&map0:scale=49999.99999999999&LAYERS=commune&truc=MY%20FOO%20TITLE%20%3Cb%3EBOLD%3C/b%3E

qgis_composer.png - Qgis composer screenshot (145 KB) Michael Douchin, 2013-05-24 06:19 AM

qgis_pdf.pdf - PDF produced by QGIS Desktop (11.8 KB) Michael Douchin, 2013-05-24 06:19 AM

getprint_pdf.pdf - PDF produced by QGIS Server with a short parameter content (11.7 KB) Michael Douchin, 2013-05-24 06:19 AM

getprint_long_pdf.pdf - PDF produced by QGIS Server with a long parameter content (11.7 KB) Michael Douchin, 2013-05-24 06:19 AM

polygons.geojson - Sample data : very simple geojson polygon layer : used by the attached QGIS project (1.38 KB) Michael Douchin, 2013-05-27 06:37 AM

dev_print.qgs - Project using a composer with a text block rendered as HTML (13.5 KB) Michael Douchin, 2013-05-27 06:37 AM

History

#1 Updated by Michael Douchin almost 11 years ago

Some more description added to be able to reproduce the problem.

Since QWebKit requires a running x-server to be able to render HTML, QGIS composers using HTML blocks or text block rendered as html will make QGIS Server segfault.

As adviced by Marco Hugentobler and Tim Sutton in the thread [1], I describe here the workaroud :

  • Create a fake X server
      Xvfb :99 -ac -noreset &
    
  • Add the option in the fastcgi , for example
      FastCgiConfig -idle-timeout 70 -maxClassProcesses 50 -minProcesses 3
    -init-start-delay 3 -restart-delay 20 -startDelay 15 -initial-env
    DISPLAY=:99
    
  • Restart Apache
    service apache2 restart
    

I also attached a sample project and relative data

[1] http://lists.osgeo.org/pipermail/qgis-developer/2013-May/026228.html

#2 Updated by René-Luc ReLuc almost 11 years ago

I have found the code, src/mapserver/qgsconfigparser.cpp:530

  //replace label text
  foreach ( QgsComposerLabel *currentLabel, composerLabels )
  {
    QString title = parameterMap.value( currentLabel->id().toUpper() );

    if ( title.isEmpty() )
    {
      //remove exported labels not referenced in the request
      if ( !currentLabel->id().isEmpty() )
      {
        c->removeItem( currentLabel );
        delete currentLabel;
      }
      continue;
    }

    currentLabel->setText( title );
    currentLabel->adjustSizeToText();
  }

At the end for each label the size is adjusted to the text, but now every label is HTML.

Other question, why removed label if it was not in parameters ?

#3 Updated by René-Luc ReLuc almost 11 years ago

  • % Done changed from 0 to 100
  • Assignee changed from Marco Hugentobler to René-Luc ReLuc
  • Status changed from Open to Closed

Update with the commit fe883246707644df37a0960fba57250226b8f001

Also available in: Atom PDF