Results 1 to 5 of 5

Thread: Postscript gereration with QT

  1. #1
    Join Date
    Mar 2011
    Posts
    22
    Thanks
    1
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Postscript gereration with QT

    Hi all,

    where can I find an example how to generate an encapsulated postscript file with QPainter?
    I don't want to print it via print dialog. I'm looking for a as simple as possible solution to write a file direct to the drive.

    Thanks
    dexli

  2. #2
    Join Date
    Feb 2007
    Location
    Karlsruhe, Germany
    Posts
    469
    Thanks
    17
    Thanked 90 Times in 88 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Postscript gereration with QT

    You use the QPainter class. There is an outputFormat for PS.

    Qt Code:
    1. QPrinter printer(QPrinter::HighResolution);
    2. printer.setOutputFormat(QPrinter::PostScriptFormat);
    3. printer.setOutputFileName(m_currentTopic+".ps");
    4. qreal xmargin = contentRect.width()*0.01;
    5. qreal ymargin = contentRect.height()*0.01;
    6. printer.setPaperSize(10*contentRect.size()*1.02,QPrinter::DevicePixel);
    7. printer.setPageMargins(xmargin,ymargin,xmargin,ymargin,QPrinter::DevicePixel);
    8. QPainter painter;
    9. painter.begin(&printer);
    10. render(&painter,QRectF(QPointF(0,0),10*contentRect.size()),contentRect);
    11. painter.end();
    To copy to clipboard, switch view to plain text mode 
    Just a quick copy paste from a project of mine. you will need to adapt that, obviously.

    Joh

  3. #3
    Join Date
    Mar 2011
    Posts
    22
    Thanks
    1
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Postscript gereration with QT

    Just a quick copy paste from a project of mine. you will need to adapt that, obviously.
    But it seems to be a good start.
    But as far as i can see there is no feature which produces eps. Is there a trick to get eps ??


    Thanks
    Dexli
    Last edited by dexli; 6th April 2011 at 21:48. Reason: additional question

  4. #4
    Join Date
    Mar 2009
    Location
    Brisbane, Australia
    Posts
    7,729
    Thanks
    13
    Thanked 1,610 Times in 1,537 Posts
    Qt products
    Qt4 Qt5
    Platforms
    Unix/X11 Windows
    Wiki edits
    17

    Default Re: Postscript gereration with QT

    No, the postscript output is printer oriented not as a graphics file format.

    Ghostscript has the ability to do this conversion using a perl script and the bundled utilities.

    Curiously similar question to this: http://www.qtcentre.org/threads/4039...ration-with-QT
    Are you and netterfield the same person or do you just have the same homework assignment?

  5. #5
    Join Date
    Mar 2011
    Posts
    22
    Thanks
    1
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Postscript gereration with QT

    Quote Originally Posted by ChrisW67 View Post
    No, the postscript output is printer oriented not as a graphics file format.


    Ghostscript has the ability to do this conversion using a perl script and the bundled utilities.
    That is true, but than i also can generate eg. a Xfig format file and use fig2dev. I think it is not so much work to add a eps to the printformat because there are only 2 differences. The bounding box and the showpage command.
    The showpage command can maybe easily removed from the ps file after creation, but the comoutation of the bounding box might be tricky.

    Quote Originally Posted by ChrisW67 View Post
    Curiously similar question to this: http://www.qtcentre.org/threads/4039...ration-with-QT
    Are you and netterfield the same person or do you just have the same homework assignment?
    Nope! definetiey not the same person. I'm a newbe regarding QT and C++ and try to lern both with a small report generator project. For this I have to generate some sketches. At the moment I use Perl to write a xfig file and than convert it to eps to import it in M$Wörg

Similar Threads

  1. Problem in opening postscript image
    By deck99 in forum Qt Programming
    Replies: 1
    Last Post: 19th March 2011, 10:09
  2. QStackedWidget fill Postscript image And scroll problem
    By patrik08 in forum Qt Programming
    Replies: 11
    Last Post: 22nd April 2007, 09:30

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.