void ViewCurve::print_to_printer()
{
printer.
setOutputFormat(QPrinter::NativeFormat);
printer.
setOrientation(QPrinter::Landscape);
printer.setFullPage(FALSE);
printer.setCreator("Printertest");
// printf("resolution is %i\n", printer.resolution());
// printf("width is %i\n", printer.pageRect().width());
// printf("height is %i\n", printer.pageRect().height());
// printer.setResolution((int)((double)width() / 10.6));
#ifndef WIN32
// printer.setPrintProgram("lpr");
#endif
printerdialog.setWindowTitle("Print");
if(printerdialog.
exec()==QDialog::Accepted) {
drawCurve(&paint);
}
}
void ViewCurve::print_to_postscript()
{
// double width_factor;
fchooser.setConfirmOverwrite(1);
fchooser.setWindowTitle("Print to PostScript");
fchooser.setDefaultSuffix("ps");
#ifndef WIN32
fchooser.setDirectory(getenv("HOME"));
#endif
fchooser.setFilter("PostScript files (*.ps *.PS)");
fchooser.selectFile("printertest.ps");
if(!(fchooser.
exec() == QDialog::Accepted)) {
return;
}
fileNames = fchooser.selectedFiles();
printer.
setOutputFormat(QPrinter::PostScriptFormat);
printer.
setOrientation(QPrinter::Landscape);
printer.setOutputFileName(fileNames.at(0));
// printer.setResolution((int)((double)width() / 10.6));
// printf("resolution is %i\n", printer.resolution());
// printf("width is %i\n", printer.pageRect().width());
// printf("height is %i\n", printer.pageRect().height());
// width_factor = ((double)printer.pageRect().width()) / ((double)width());
// drawCurve(&paint, printer.pageRect().width(), printer.pageRect().height(), width_factor);
drawCurve(&paint);
}
void ViewCurve::print_to_pdf()
{
fchooser.setConfirmOverwrite(1);
fchooser.setWindowTitle("Print to PDF");
fchooser.setDefaultSuffix("pdf");
#ifndef WIN32
fchooser.setDirectory(getenv("HOME"));
#endif
fchooser.setFilter("PDF files (*.pdf *.PDF)");
fchooser.selectFile("printertest.pdf");
if(!(fchooser.
exec() == QDialog::Accepted)) {
return;
}
fileNames = fchooser.selectedFiles();
printer.
setOutputFormat(QPrinter::PdfFormat);
printer.setOutputFileName(fileNames.at(0));
printer.
setOrientation(QPrinter::Landscape);
// printer.setResolution((int)((double)width() / 10.6));
drawCurve(&paint);
}
void ViewCurve::print_to_printer()
{
QPrinter printer(QPrinter::ScreenResolution);
printer.setOutputFormat(QPrinter::NativeFormat);
printer.setOrientation(QPrinter::Landscape);
printer.setFullPage(FALSE);
printer.setPageSize(QPrinter::A4);
printer.setCreator("Printertest");
// printf("resolution is %i\n", printer.resolution());
// printf("width is %i\n", printer.pageRect().width());
// printf("height is %i\n", printer.pageRect().height());
// printer.setResolution((int)((double)width() / 10.6));
#ifndef WIN32
// printer.setPrintProgram("lpr");
#endif
QPrintDialog printerdialog(&printer, this);
printerdialog.setWindowTitle("Print");
if(printerdialog.exec()==QDialog::Accepted)
{
QPainter paint(&printer);
drawCurve(&paint);
}
}
void ViewCurve::print_to_postscript()
{
// double width_factor;
QFileDialog fchooser;
QStringList fileNames;
fchooser.setViewMode(QFileDialog::Detail);
fchooser.setConfirmOverwrite(1);
fchooser.setFileMode(QFileDialog::AnyFile);
fchooser.setAcceptMode(QFileDialog::AcceptSave);
fchooser.setWindowTitle("Print to PostScript");
fchooser.setLabelText(QFileDialog::FileName, "File");
fchooser.setDefaultSuffix("ps");
#ifndef WIN32
fchooser.setDirectory(getenv("HOME"));
#endif
fchooser.setFilter("PostScript files (*.ps *.PS)");
fchooser.selectFile("printertest.ps");
if(!(fchooser.exec() == QDialog::Accepted))
{
return;
}
fileNames = fchooser.selectedFiles();
QPrinter printer(QPrinter::ScreenResolution);
printer.setOutputFormat(QPrinter::PostScriptFormat);
printer.setPageSize(QPrinter::A4);
printer.setOrientation(QPrinter::Landscape);
printer.setOutputFileName(fileNames.at(0));
// printer.setResolution((int)((double)width() / 10.6));
// printf("resolution is %i\n", printer.resolution());
// printf("width is %i\n", printer.pageRect().width());
// printf("height is %i\n", printer.pageRect().height());
// width_factor = ((double)printer.pageRect().width()) / ((double)width());
QPainter paint(&printer);
// drawCurve(&paint, printer.pageRect().width(), printer.pageRect().height(), width_factor);
drawCurve(&paint);
}
void ViewCurve::print_to_pdf()
{
QFileDialog fchooser;
QStringList fileNames;
fchooser.setViewMode(QFileDialog::Detail);
fchooser.setConfirmOverwrite(1);
fchooser.setFileMode(QFileDialog::AnyFile);
fchooser.setAcceptMode(QFileDialog::AcceptSave);
fchooser.setWindowTitle("Print to PDF");
fchooser.setLabelText(QFileDialog::FileName, "File");
fchooser.setDefaultSuffix("pdf");
#ifndef WIN32
fchooser.setDirectory(getenv("HOME"));
#endif
fchooser.setFilter("PDF files (*.pdf *.PDF)");
fchooser.selectFile("printertest.pdf");
if(!(fchooser.exec() == QDialog::Accepted))
{
return;
}
fileNames = fchooser.selectedFiles();
QPrinter printer(QPrinter::ScreenResolution);
printer.setOutputFormat(QPrinter::PdfFormat);
printer.setOutputFileName(fileNames.at(0));
printer.setPageSize(QPrinter::A4);
printer.setOrientation(QPrinter::Landscape);
// printer.setResolution((int)((double)width() / 10.6));
QPainter paint(&printer);
drawCurve(&paint);
}
To copy to clipboard, switch view to plain text mode
If I choose QPrinter::HighResolution instead of QPrinter::ScreenResolution,
Bookmarks