void SchedulePrintDialog::setupPdfPrinter( QPrinter & printer )
{
	printer.setOutputFormat( QPrinter::PdfFormat );
	setupPrinter(printer);

	printer.setFullPage( true );
	printer.setResolution( mDpiSpin->value() );
	printer.setFontEmbeddingEnabled(false);
}
Esempio n. 2
0
void PagePrinter::doPrint(bool ok)
{
    if (! ok)
    {
        std::cout << "Page could not be loaded" ;
        QCoreApplication::exit(1);
    }

    this->settings()->setAttribute(QWebSettings::PrintElementBackgrounds, true);
    this->settings()->setAttribute(QWebSettings::JavascriptEnabled, false);
    QPrinter *printer = new QPrinter(QPrinterInfo::defaultPrinter(), QPrinter::ScreenResolution);
    printer->setFontEmbeddingEnabled(true);
    printer->setOutputFormat(QPrinter::PdfFormat);
    printer->setFullPage(true);
    QTemporaryFile file;
    if (! file.open())
        exit(1);
    QString output = file.fileName().append(".pdf");
    printer->setOutputFileName(output);
    print(printer);
    std::cout << output.toLatin1().data();
    QCoreApplication::exit(0);
}
Esempio n. 3
0
void QPrinterProto::setFontEmbeddingEnabled(bool enable)
{
  QPrinter *item = qscriptvalue_cast<QPrinter*>(thisObject());
  if (item)
    item->setFontEmbeddingEnabled(enable);
}
Esempio n. 4
0
/// Writes all the relevant data into the tdf file.
void ExportEPS::doExport()
{
  using namespace std;

  // code adapted from Umbrello
  bool exportSuccessful;
  QRect textrect;

  //out->close();

    // print the image to a normal postscript file,
    // do not clip so that everything ends up in the file
    // regardless of "paper size"

    // because we want to work with postscript
    // user-coordinates, set to the resolution
    // of the printer (which should be 72dpi here)
    QPrinter *printer;

    printer = new QPrinter(QPrinter::ScreenResolution);

    printer->setOutputToFile(true);
    printer->setOutputFormat(QPrinter::PostScriptFormat);
    printer->setOutputFileName(fileName);
    printer->setColorMode(QPrinter::Color);
	printer->setFontEmbeddingEnabled(true);

    // do not call printer.setup(); because we want no user
    // interaction here
    QPainter *painter = new QPainter(printer);

    // make sure the widget sizes will be according to the
    // actually used printer font, important for getDiagramRect()
    // and the actual painting
    //view->forceUpdateWidgetFontMetrics(painter);

    if (!scrollview)
    {
      delete painter;
      delete printer;
      exportSuccessful = FALSE;
    }
    Draw* draw = new Draw(scrollview, options);
    QRect rect = draw->getBoundingBox(machine, painter);
	rect.setWidth(rect.width()+10);
	rect.setHeight(rect.height()+10);
    painter->translate(-rect.x(),-rect.y());
    //view->getDiagram(rect,*painter);

    int resolution = printer->resolution();


    if (scrollview)
      scrollview->getDrawArea()->getSelection()->deselectAll(machine);
    draw->drawStates(machine, painter, 0, 0, 1.0);
    draw->drawTransitions(machine, painter, 0, 0, 1.0);
    if (machine->getDrawITrans())
      draw->drawInitialTransition(machine, machine->getInitialTransition(), painter, 0, 0, 1.0, textrect, FALSE);

    // delete painter and printer before we try to open and fix the file
    delete painter;
    delete printer;
    delete draw;
    
    // modify bounding box from screen to eps resolution.
    rect.setWidth( int(ceil(rect.width() * 72.0/resolution)) );
    rect.setHeight( int(ceil(rect.height() * 72.0/resolution)) );
    exportSuccessful = fixEPS(fileName,rect);
	
    // next painting will most probably be to a different device (i.e. the screen)
    //view->forceUpdateWidgetFontMetrics(0);

    if (scrollview)
      scrollview->getDrawArea()->reset();
    //return exportSuccessful;
}
Esempio n. 5
0
int Printer::setFontEmbeddingEnabled(lua_State * L) // ( bool enable )
{
	QPrinter* lhs = ValueBinding<MyQPrinter>::check( L, 1 );
	lhs->setFontEmbeddingEnabled( Util::toBool( L, 2 ) );
	return 0;
}