Ejemplo n.º 1
1
AdvancedPdf::PaperSize AdvancedPdf::paperSize(QPrinter::PaperSize paperSize)
{
    QPrinter pr;
    pr.setOutputFormat(QPrinter::PdfFormat);
    pr.setPaperSize(paperSize);
    QSizeF s = pr.paperSize(QPrinter::Point);
    PaperSize p = { qRound(s.width()), qRound(s.height()) };
    return p;
}
Ejemplo n.º 2
0
bool QPrinterProto::fullPage() const
{
  QPrinter *item = qscriptvalue_cast<QPrinter*>(thisObject());
  if (item)
    return item->fullPage();
  return false;
}
Ejemplo n.º 3
0
int QPrinterProto::fromPage() const
{
  QPrinter *item = qscriptvalue_cast<QPrinter*>(thisObject());
  if (item)
    return item->fromPage();
  return 0;
}
Ejemplo n.º 4
0
bool QPrinterProto::fontEmbeddingEnabled() const
{
  QPrinter *item = qscriptvalue_cast<QPrinter*>(thisObject());
  if (item)
    return item->fontEmbeddingEnabled();
  return false;
}
Ejemplo n.º 5
0
QPrinter::DuplexMode QPrinterProto::duplex() const
{
  QPrinter *item = qscriptvalue_cast<QPrinter*>(thisObject());
  if (item)
    return item->duplex();
  return QPrinter::DuplexNone;
}
Ejemplo n.º 6
0
bool QPrinterProto::doubleSidedPrinting() const
{
  QPrinter *item = qscriptvalue_cast<QPrinter*>(thisObject());
  if (item)
    return item->doubleSidedPrinting();
  return false;
}
Ejemplo n.º 7
0
QString QPrinterProto::docName() const
{
  QPrinter *item = qscriptvalue_cast<QPrinter*>(thisObject());
  if (item)
    return item->docName();
  return QString();
}
Ejemplo n.º 8
0
QPrinter::ColorMode QPrinterProto::colorMode() const
{
  QPrinter *item = qscriptvalue_cast<QPrinter*>(thisObject());
  if (item)
    return item->colorMode();
  return QPrinter::Color;
}
Ejemplo n.º 9
0
bool QPrinterProto::collateCopies() const
{
  QPrinter *item = qscriptvalue_cast<QPrinter*>(thisObject());
  if (item)
    return item->collateCopies();
  return false;
}
Ejemplo n.º 10
0
bool QPrinterProto::abort()
{
  QPrinter *item = qscriptvalue_cast<QPrinter*>(thisObject());
  if (item)
    return item->abort();
  return false;
}
Ejemplo n.º 11
0
void Matrix::exportVector(const QString& fileName, int res, bool color)
{
	if ( fileName.isEmpty() ){
		QMessageBox::critical(this, tr("QtiPlot - Error"), tr("Please provide a valid file name!"));
        return;
	}

	QPrinter printer;
    printer.setCreator("QtiPlot");
	printer.setFullPage(true);
	if (res)
		printer.setResolution(res);

    printer.setOutputFileName(fileName);
    if (fileName.contains(".eps"))
    	printer.setOutputFormat(QPrinter::PostScriptFormat);

    if (color)
		printer.setColorMode(QPrinter::Color);
	else
		printer.setColorMode(QPrinter::GrayScale);

	printer.setOrientation(QPrinter::Portrait);

    int cols = numCols();
    int rows = numRows();
    QRect rect = QRect(0, 0, cols, rows);
    printer.setPaperSize(QSizeF(cols, rows), QPrinter::DevicePixel);

    QPainter paint(&printer);
    paint.drawImage(rect, d_matrix_model->renderImage());
    paint.end();
}
Ejemplo n.º 12
0
void Help::filePrint()
{
    QPrinter printer;
    printer.setFullPage(TRUE);
    if ( printer.setup() ) {
	QPainter p( &printer );
	QPaintDeviceMetrics metrics(p.device());
	int dpix = metrics.logicalDpiX();
	int dpiy = metrics.logicalDpiY();
	const int margin = 72; // pt
	QRect body(margin*dpix/72, margin*dpiy/72,
		   metrics.width()-margin*dpix/72*2,
		   metrics.height()-margin*dpiy/72*2 );
	QFont font("times", 10);
	QSimpleRichText richText( browser->text(), font, browser->context(), browser->styleSheet(),
				  browser->mimeSourceFactory(), body.height() );
	richText.setWidth( &p, body.width() );
	QRect view( body );
	int page = 1;
	do {
	    richText.draw( &p, body.left(), body.top(), view, colorGroup() );
	    view.moveBy( 0, body.height() );
	    p.translate( 0 , -body.height() );
	    p.setFont( font );
	    p.drawText( view.right() - p.fontMetrics().width( QString::number(page) ),
			view.bottom() + p.fontMetrics().ascent() + 5, QString::number(page) );
	    if ( view.top()  >= richText.height() )
		break;
	    printer.newPage();
	    page++;
	} while (TRUE);
    }
}
Ejemplo n.º 13
0
int Printer::setPrinterSelectionOption(lua_State * L) // ( const QString & option )
{
	QPrinter* lhs = ValueBinding<MyQPrinter>::check( L, 1 );
#ifndef _WIN32
	lhs->setPrinterSelectionOption( QtValueBase::toString( L, 2 ));
#endif
	return 0;
}
Ejemplo n.º 14
0
int Printer::printerSelectionOption(lua_State * L) // const : QString 
{
	QPrinter* lhs = ValueBinding<MyQPrinter>::check( L, 1 );
#ifndef _WIN32
	*QtValue<QString>::create( L ) = lhs->printerSelectionOption();
#endif
	return 1; 
}
void SchedulePrintDialog::savePdf()
{
	QPrinter printer;
	setupPdfPrinter(printer);
	QString fileName = QFileDialog::getSaveFileName(this, "Choose File Name for Pdf", QString(), "Pdf Documents (*.pdf)" );
	printer.setOutputFileName( fileName );
	doPrint(&printer);
}
Ejemplo n.º 16
0
void HelpBrowser::print()
{
	QPrinter printer;
	printer.setFullPage(true);
	QPrintDialog dialog(&printer, this);
	if (dialog.exec())
 		textBrowser->print(&printer);
}
Ejemplo n.º 17
0
//-------------------------------------------------------------------------
void QGuidoItemContainer::exportToPdf(const QString& fileName)
{
	QPrinter printer;
	printer.setFullPage(true);
	printer.setOutputFileName( fileName );
	printer.setOutputFormat( QPrinter::PdfFormat );
	exportToPdf( &printer );
}
Ejemplo n.º 18
0
void PrinterTests::paperSize()
{
    QPrinter printer;
    printer.setPaperSize(QPrinter::A4);
    const QSizeF size = Printer::paperSize(&printer);
    QCOMPARE(size.width(), 2100.0);
    QCOMPARE(size.height(), 2970.0);
}
Ejemplo n.º 19
0
void QgsComposition::beginPrintAsPDF( QPrinter& printer, const QString& file )
{
  printer.setOutputFormat( QPrinter::PdfFormat );
  printer.setOutputFileName( file );
  printer.setPaperSize( QSizeF( paperWidth(), paperHeight() ), QPrinter::Millimeter );

  QgsPaintEngineHack::fixEngineFlags( printer.paintEngine() );
}
void SchedulePrintDialog::setupPdfPrinter( QPrinter & printer )
{
	printer.setOutputFormat( QPrinter::PdfFormat );
	setupPrinter(printer);

	printer.setFullPage( true );
	printer.setResolution( mDpiSpin->value() );
	printer.setFontEmbeddingEnabled(false);
}
Ejemplo n.º 21
0
void QgsComposition::beginPrint( QPrinter &printer )
{
  //set resolution based on composer setting
  printer.setFullPage( true );
  printer.setColorMode( QPrinter::Color );

  //set user-defined resolution
  printer.setResolution( printResolution() );
}
Ejemplo n.º 22
0
void ProRataGraphPane::print()
{
	if ( !(qtwGraphTab->currentWidget()) )
	{
		return ;
	}

/*
	QString qsSaveFileName = QFileDialog::getSaveFileName(
                    this,
                    "ProRata - Choose a file name to save",
                    ".",
                    "Images (*.png *.jpg)");

	if (qsSaveFileName.isEmpty())
	{
		return;
	}
	*/

	ProRataGraph *clickedGraph = (ProRataGraph *)qtwGraphTab->currentWidget();

	QPrinter printer;
    //printer.setOutputToFile(true);
    //printer.setOutputFileName(qsSaveFileName);
    printer.setDocName(QString("ProRata_Graph"));

    printer.setCreator("ProRata Graph");
    printer.setOrientation(QPrinter::Landscape);

	QPrintDialog dialog(&printer);
    if ( dialog.exec() )
    {
		QwtPlotPrintFilter filter;
		if ( printer.colorMode() == QPrinter::GrayScale )
        {
            filter.setOptions(QwtPlotPrintFilter::PrintAll 
                & ~QwtPlotPrintFilter::PrintCanvasBackground);
        }
		clickedGraph->print( printer, filter );
	}
	
	

/*
	//QPixmap *qpPic = new QPixmap( qsSaveFileName );
	//QPainter * qpntrPainter = new QPainter( qpPic );
	QPixmap qpPic( qsSaveFileName );
	qpPic.save( qsSaveFileName );
	//QPainter * qpntrPainter = new QPainter( qpPic );

	//clickedGraph->print( qpntrPainter, clickedGraph->frameGeometry() );
	clickedGraph->print( qpPic );
*/
	//QMessageBox::information( this, "Printing done.", QString( "Saved \"") + qsSaveFileName + QString( "\"" ) );

}
Ejemplo n.º 23
0
void PrinterTests::pageSize()
{
    QPrinter printer;
    printer.setPaperSize(QPrinter::A4);
    printer.setPageMargins(10, 20, 30, 40, QPrinter::Millimeter);
    const QSizeF size = Printer::pageSize(&printer);
    QCOMPARE(size.width(), 1700.0);
    QCOMPARE(size.height(), 2370.0);
}
//! Print the checked in and missing items.
void wndInventoryCheck::printReport( void )
{
    QPrinter printer;
    printer.setPaperSize( QPrinter::Letter );
    printer.setPageMargins( 1, 1, 1, 1, QPrinter::Inch );

    QPrintDialog *dialog = new QPrintDialog( &printer, this );
    if ( dialog->exec() != QDialog::Accepted )
    {
        return;
    }

    // PDF printing:
    //printer.setOutputFormat(QPrinter::PdfFormat);
    //printer.setOutputFileName("test.pdf");

    // Build the painter data which is printed
    QPainter painter;

    if ( !painter.begin( &printer ) ) // Link the painter to the printer
    {
        qWarning("Printer Error: Could not link painter to printer. ");
        return;
    }

    painter.setFont( QFont( "Courier New", 12, QFont::Bold ) );

    int pw = (int)( printer.pageRect( QPrinter::DevicePixel ).width() );
    int ph = (int)( printer.pageRect( QPrinter::DevicePixel ).height() );
    int y = 0;
    painter.drawText( 0, 0, pw, ph, Qt::AlignHCenter, "Station 40 - Youngsville Fire Department\n"
                     "Inventory Audit Report\n"  + QDate::currentDate().toString( "dddd the d of MMMM yyyy" ) );
    y = 80;
    if ( _pUI->chkCheckedItems->isChecked() )
    {
        painter.drawText( 0, y, pw, ph, Qt::AlignLeft, "Checked Items" );
        y += 20;

        for ( int i = 0; i < _pUI->tblCheckedIn->model()->rowCount(); i++ )
        {
            painter.drawText( 20, y, pw, ph, Qt::AlignLeft, _pUI->tblCheckedIn->model()->index( i, 1 ).data().toString() );
            y += 20;
        }
    }

    if ( _pUI->chkMissingItems->isChecked() )
    {
        painter.drawText( 0, y, pw, ph, Qt::AlignLeft, "Missing Items" );
        y += 20;
        for ( int i=0; i < _pUI->tblNotCheckedIn->model()->rowCount(); i++ )
        {
            painter.drawText( 20, y, pw, ph, Qt::AlignLeft, _pUI->tblNotCheckedIn->model()->index( i, 1 ).data().toString() );
            y += 20;
        }
    }
    painter.end();
}
Ejemplo n.º 25
0
void StressPlotter::postscript(QString fname, float w, float h)
{
  QPrinter printer;
  printer.setPaperSize(QSizeF(w, h), QPrinter::Point);
  printer.setOutputFormat(QPrinter::PostScriptFormat);
  printer.setOutputFileName(fname);  // can override to pdf if not .ps
  QPainter p(&printer);
  drawStress(&p, (int)w, int(h), true);
}
Ejemplo n.º 26
0
void PrintDialog::on_printButton_clicked()
{
  QPrinter printer;
  printer.setPageMargins(10.0,10.0,10.0,10.0,printer.Millimeter);
  QPrintDialog *dialog = new QPrintDialog(&printer, this);
  dialog->setWindowTitle(tr("Print Document"));
  if (dialog->exec() != QDialog::Accepted)
    return;
  ui->textEdit->print(&printer);
}
Ejemplo n.º 27
0
void MyTextBrowser::slotPRINTER()
{
  QPrinter printer;
  printer.setColorMode(QPrinter::Color);
  QPrintDialog dialog(&printer);
  if (dialog.exec() == QDialog::Accepted)
  {
    PRINT(&printer);
  } 
}
Ejemplo n.º 28
0
bool KDReports::Report::exportToFile( const QString& fileName, QWidget* parent )
{
    d->ensureLayouted();
    QPrinter printer;
    printer.setOutputFileName( fileName ); // must be done before setupPrinter, since it affects DPI
    setupPrinter( &printer );
    const bool ret = d->doPrint( &printer, parent );
    printer.setOutputFileName( QString() );
    return ret;
}
Ejemplo n.º 29
0
void Document::print()
{
	QPrinter printer;
	printer.setPageSize(QPrinter::Letter);
	printer.setPageMargins(0.5, 0.5, 0.5, 0.5, QPrinter::Inch);
	QPrintDialog dialog(&printer, this);
	if (dialog.exec() == QDialog::Accepted) {
		m_text->print(&printer);
	}
}
Ejemplo n.º 30
0
void Plot3D::printPlot()
{
    QPrinter printer;
    printer.setOrientation(QPrinter::Landscape);
    QPrintDialog dialog(&printer);
    if ( dialog.exec() )
    {

    }
}