Qt World Summit: Register Today!

QTextDocument, print image to fit page width

  • Hi all,
    I need to print an image to a pdf page that fit the page width.

    this is my code (that doesn't works as expected):

    QTextDocument document;
    QString html_document_str;
    QPrinter p;
    QPrintDialog pd(&p, 0);

    html_document_str = "<img />";

    The code create a pdf with an empty page. The html code I used works in a browser.

    Where do I wrong?

  • EDIT (the code I pasted before was wrong. In the post I can't write the code I used with escape character) .

    To let you see the code I write it with some space characters:

    html_document_str = " < img src= " :/images/intestazionegw.jpg " width="100%" > " ;

    The proble in my application is that if I put " width =100% " in my html code I don't see the image in the pdf while if I remove the "width" :

    html_document_str = " < img src= " :/images/intestazionegw.jpg " > " ;

    I can see the image printed in the pdf but its dimension is too big and go uotside the page.

Log in to reply