Printing to both Pdf & preview at once

Help
si sol
2007-09-07
2013-04-08
  • si sol

    si sol - 2007-09-07

    Hello,

    I need to print report to both pdf (for archiving purpose) and preview/printer. I'm using ncreport for qt4, my version of qt is 4.2.3. Here are my code snippet :

    NCReport * report = new NCReport(QString::null,0);
    report->setDatabase(&db);
    report->setParseMode(NCReport::fromFile);
    report->setReportFile("test.ncr");

    // print to pdf
    report->setOutputFile("test.pdf");
    report->setOutput(NCReport::PDF);
    report->runReportToPDF();

    // print to preview
    report->setOutput(NCReport::Preview);
    report->runReportToPreview();

    The problem I'm experiencing is : output is OK on the pdf, but the preview only display the value from sql field (label, static text is not displayed). I've tried to change the order (print preview followed by print to pdf) and the preview is OK but no label or static text printed on the pdf. What's probably missing in my code ?.

    Regards,
    solikhin

     
    • si sol

      si sol - 2007-09-07

      I found temporary solution for this problem by creating 2 report, 1 for pdf and 1 for preview. Still looking better solution. Here are my code snippet :

      NCReport * report = new NCReport(QString::null,0);
      report->setDatabase(&db);
      report->setParseMode(NCReport::fromFile);
      report->setReportFile("test.ncr");

      // print to pdf
      report->setOutputFile("test.pdf");
      report->setOutput(NCReport::PDF);
      report->runReportToPDF();
      delete report

      // define another report
      NCReport * rpt = new NCReport(QString::null,0);
      rpt->setDatabase(&db);
      rpt->setParseMode(NCReport::fromFile);
      rpt->setReportFile("test.ncr");

      // print preview
      rpt->setOutput(NCReport::Preview);
      rpt->runReportToPreview();

       

Log in to post a comment.

Get latest updates about Open Source Projects, Conferences and News.

Sign up for the SourceForge newsletter:

JavaScript is required for this form.





No, thanks