<html>
  <head>
    <meta content="text/html; charset=ISO-8859-1"
      http-equiv="Content-Type">
  </head>
  <body bgcolor="#FFFFFF" text="#000000">
    Hi Nathan<br>
    <br>
    &gt;What I have seen so far looks like you have to handle recreating
    the composer and all its items using the xml like in<br>
    <br>
    There has been some rearrangement in the composer classes (the first
    API break :-) ). With git master version, you should be able to
    create a QgsComposition by calling its readXML Method, then call
    QgsComposition::readItemsFromXML.<br>
    <br>
    The composer is a bit of a special case because it is possible to
    replace label strings, map extent / layer / rotation with
    parameters. And with the legend, there is a workaround to avoid
    using the x-server. So with an external python script, I'd recommend
    to use QgsComposition::readItemsFromXML.<br>
    <br>
    Regards,<br>
    Marco<br>
    <br>
    On 19.03.2012 01:22, Nathan Woodrow wrote:
    <blockquote
cite="mid:CAAi8Yg9GNZ2nJUQgKCw7mXqxMfnzi8yNnBjwmLK8f3a9Wag6Ag@mail.gmail.com"
      type="cite">Martin,
      <div><br>
      </div>
      <div>It's not so much that I don't know how to create a new
        composer from Python more that I don't now how to restore a
        composer item from the project file using Python.</div>
      <div><br>
      </div>
      <div>I'm using the project file that contains composers as a
        template which I need to open and print. &nbsp;What I have seen so
        far looks like you have to handle recreating the composer and
        all its items using the xml like in&nbsp;<a moz-do-not-send="true"
href="https://github.com/qgis/Quantum-GIS/blob/master/src/mapserver/qgsprojectparser.cpp">https://github.com/qgis/Quantum-GIS/blob/master/src/mapserver/qgsprojectparser.cpp</a></div>
      <div><br>
      </div>
      <div>Maybe the composer object could do with a createFromXML()
        method which constructs a composer, and all its children, as per
        the project file.</div>
      <div><br>
      </div>
      <div>- Nathan<br>
        <br>
        <div class="gmail_quote">On Mon, Mar 19, 2012 at 4:51 AM, Martin
          Dobias <span dir="ltr">&lt;<a moz-do-not-send="true"
              href="mailto:wonder.sk@gmail.com">wonder.sk@gmail.com</a>&gt;</span>
          wrote:<br>
          <blockquote class="gmail_quote" style="margin:0 0 0
            .8ex;border-left:1px #ccc solid;padding-left:1ex">
            <div class="im">On Thu, Mar 15, 2012 at 2:29 PM, Nathan
              Woodrow &lt;<a moz-do-not-send="true"
                href="mailto:madmanwoo@gmail.com">madmanwoo@gmail.com</a>&gt;
              wrote:<br>
              &gt; Is it possible to:<br>
              &gt;<br>
              &gt; Load QGIS from Python (well I know how to do this
              using<br>
              &gt; QgsApplicaiton.Init())<br>
              &gt; Open the project file<br>
              &gt; Zoom to a location<br>
              &gt; Print the first composer to pdf<br>
              &gt; OR render out the map canvas to a image.<br>
              <br>
            </div>
            Hi Nathan<br>
            <br>
            yes that's all possible from an external python script with
            PyQGIS,<br>
            without actually starting GUI.<br>
            <div class="im"><br>
              &gt; From what I can see the only way is to create a new
              composer item and pass<br>
              &gt; it the composer node from the xml.<br>
              <br>
            </div>
            No need to play with XML, everything can be done using API,
            there is<br>
            an example in the cookbook:<br>
            <a moz-do-not-send="true"
              href="http://qgis.org/pyqgis-cookbook/composer.html"
              target="_blank">http://qgis.org/pyqgis-cookbook/composer.html</a><br>
            <span class="HOEnZb"><font color="#888888"><br>
                Martin<br>
              </font></span></blockquote>
        </div>
        <br>
      </div>
      <br>
      <fieldset class="mimeAttachmentHeader"></fieldset>
      <br>
      <pre wrap="">_______________________________________________
Qgis-developer mailing list
<a class="moz-txt-link-abbreviated" href="mailto:Qgis-developer@lists.osgeo.org">Qgis-developer@lists.osgeo.org</a>
<a class="moz-txt-link-freetext" href="http://lists.osgeo.org/mailman/listinfo/qgis-developer">http://lists.osgeo.org/mailman/listinfo/qgis-developer</a>
</pre>
    </blockquote>
    <br>
    <br>
    <pre class="moz-signature" cols="72">-- 
Dr. Marco Hugentobler
Sourcepole -  Linux &amp; Open Source Solutions
Churerstrasse 22, CH-8808 Pf&auml;ffikon SZ, Switzerland
<a class="moz-txt-link-abbreviated" href="mailto:marco.hugentobler@sourcepole.ch">marco.hugentobler@sourcepole.ch</a> <a class="moz-txt-link-freetext" href="http://www.sourcepole.ch">http://www.sourcepole.ch</a>
Technical Advisor QGIS Project Steering Committee</pre>
  </body>
</html>