Exemplo n.º 1
0
// Push textEdit contents to a printer
void MainWindow::on_actionPrint_triggered()
{
    QPrinter printer;
    printer.setPrinterName("Printer");
    QPrintDialog dialog(&printer, this);
    if(dialog.exec() == QDialog::Rejected) {
        return;
    } else {
        ui->textEdit->print(&printer);
    }
}
Exemplo n.º 2
0
void dController::printOverSide(int RowId)
{

    //TODO это должно быть в отдельном классе !!!
    QGraphicsScene *scene = new QGraphicsScene();

    bool page_orient= false;
   int  margin_top = MM_TO_POINT(15);
   int  margin_bottom=MM_TO_POINT(15);
    int margin_left=MM_TO_POINT(35);
    int margin_right=MM_TO_POINT(15);
    int page_width=210;
    int page_height=297;

    scene->clear();
    scene->setSceneRect(0, 0, MM_TO_POINT(page_width),MM_TO_POINT(page_height));

    QGraphicsRectItem *border_rect = new QGraphicsRectItem (QRectF(margin_left, margin_top, MM_TO_POINT(page_width)-margin_left-margin_right,MM_TO_POINT(page_height)-margin_top-margin_bottom));
    qDebug() <<"margin_rect"<< margin_left << margin_top << margin_left<<margin_right;
    border_rect->setPen(QPen(Qt::black,2,Qt::DotLine));
    border_rect->setBrush(QBrush(Qt::white));
    border_rect->setOpacity(0.5);
    border_rect->setZValue(0);
    //border_rect->setData(ObjectName, "Border");
    scene->addItem(border_rect);

	    SimpleItem* MBitem = new SimpleItem;
	    MBitem->setPos(MM_TO_POINT(5), MM_TO_POINT(280));
	    MBitem->setPrintFrame(false);
	    MBitem->setText(QStringList()<<QString("МБ №-%1"));
	    MBitem->setFlag(QGraphicsItem::ItemIsMovable);

	    MBitem->setParentItem(border_rect);
	    //scene->addItem(MBtem);
	scene->update();

    QPrinter printer;
    printer.setPrinterName(curPrinter); //Печать на реальный принтер
     //printer.setOutputFormat(QPrinter::PdfFormat);
     //printer.setOutputFileName("overside.pdf");
     //printer.setPageSize(QPrinter::A4);
     QPainter painter(&printer);
     scene->render(&painter);

     //emit sayMeGood();
}
Exemplo n.º 3
0
void RenderWindow::filePrint()
{
    orReport report;
    report.setDom(_doc);
    report.setParamList(getParameterList());

    QPrinter printer;
    if(!_printerName.isEmpty())
    {
        printer.setPrinterName(_printerName);
        _printerName = QString::null;
    }

    if(report.isValid())
        report.print(&printer);
    else
        report.reportError(this);
}
Exemplo n.º 4
0
void QPrinterProto::setPrinterName(const QString & name)
{
  QPrinter *item = qscriptvalue_cast<QPrinter*>(thisObject());
  if (item)
    item->setPrinterName(name);
}
Exemplo n.º 5
0
int Printer::setPrinterName(lua_State * L) // ( const QString & name )
{
	QPrinter* lhs = ValueBinding<MyQPrinter>::check( L, 1 );
	lhs->setPrinterName( QtValueBase::toString( L, 2 ));
	return 0;
}
Exemplo n.º 6
0
void CustRegister::printRegister()
{
    QDate       theDate;
    QPrinter    prn;
    QPainter    p;
    QRect       rect;
    ADBTable    cust;
    ADBTable    cont;
    ADB         DB;
    QString     tmpSt;
    char        tStr[1024];
    int         yPos;
    int         pageNo = 1;
    float       Balance = 0.00;
    float       EndingBalance;
    CustomersDB CDB;
    AddressesDB addrDB;
    
    CDB.get(myCustID);
    addrDB.get(REF_CUSTOMER, myCustID, "Billing");
    
    theDate = QDate::currentDate();
    
    // prn.setPrintProgram("ghostview");
    prn.setPrinterName("PostScript");
    // prn.setOutputFileName("/home/marc/test.ps");
    // prn.setOutputToFile(TRUE);
    prn.setPageSize(QPrinter::Letter);
    
    prn.setDocName("Register Listing");
    prn.setCreator("Blarg! Online Services, Inc.");
    
    if (!prn.setup()) return;
    
    p.begin(&prn);
    
    EndingBalance = DB.sumFloat("select SUM(Amount) from AcctsRecv where CustomerID = %ld", myCustID);
    
    // Put the Blarg header and contact information on the page.
    printHeader(&p, &CDB, &addrDB, EndingBalance);
    
    // Put the register header on the page.
    registerHeader(&p);
    
    // Now, get the register information from the database.
    DB.query("select TransDate, DueDate, LoginID, Memo, Amount from AcctsRecv where CustomerID = %ld order by TransDate, LoginID", myCustID);
    
    yPos = 165;
    p.setFont(QFont("courier", 8, QFont::Normal));
    while (DB.getrow()) {
        int Lines = (int) (strlen(DB.curRow["Memo"]) / 52) + 1;
        int RowHeight = 15 * Lines;
        
        // Check to see if we have enough room on the page left for this
        // line.
        if (yPos+RowHeight >= 740) {
            printFooter(&p, pageNo++);
            prn.newPage();
            printHeader(&p, &CDB, &addrDB, EndingBalance);
            registerHeader(&p);
            yPos = 165;
            p.setFont(QFont("courier", 8, QFont::Normal));
        } 
    
        // The transaction date.
        rect.setCoords(20, yPos, 79, yPos + RowHeight);
        p.drawRect(rect);
        p.drawText(rect, AlignVCenter|AlignHCenter, DB.curRow["TransDate"]);
        
        // The Due Date
        rect.setCoords(80, yPos, 139, yPos + RowHeight);
        p.drawRect(rect);
        p.drawText(rect, AlignVCenter|AlignHCenter, DB.curRow["DueDate"]);
        
        // The Login ID
        rect.setCoords(140, yPos, 199, yPos + RowHeight);
        p.drawRect(rect);
        p.drawText(rect, AlignVCenter|AlignHCenter, DB.curRow["LoginID"]);
        
        // The description...
        rect.setCoords(200, yPos, 419, yPos + RowHeight);
        p.drawRect(rect);
        rect.setCoords(203, yPos, 419, yPos + RowHeight);
        p.drawText(rect, WordBreak|AlignLeft|AlignVCenter, DB.curRow["Memo"]);
        
        // The amount.
        rect.setCoords(420, yPos, 479, yPos + RowHeight);
        p.drawRect(rect);
        p.drawText(rect, AlignRight|AlignVCenter, DB.curRow["Amount"]);
        
        // The balance.
        Balance += atof(DB.curRow["Amount"]);
        sprintf(tStr, "%.2f", Balance);
        if (Balance == 0.0) strcpy(tStr, "0.00");
        rect.setCoords(480, yPos, 539, yPos + RowHeight);
        p.drawRect(rect);
        p.drawText(rect, AlignRight|AlignVCenter, tStr);
        
        yPos += RowHeight;
    }

    // Put the footer on the page.
    printFooter(&p, pageNo);
    
    // prn.newPage();
    
    // p.drawText(300, 600, "Page 2");
    
    p.end();
}