How i can leave QPrinter border / margin ? my QGraphicsScene is exact A4...
the grey part is the paper & white is margin to write...
i wand fill exact the grey part on A4..
Now here .. QPrinter display a default border i suppose...
/* XSL-FO -editor base widget */
/* http://www.zvon.org/xxl/xslfoReference/Output/index.html
<fo:simple-page-master margin-right="5pt" margin-left="5pt" margin-bottom="22pt" margin-top="22pt" page-width="21cm" page-height="29.7cm" master-name="first">
<fo:region-body/>
</fo:simple-page-master>
*/
void DisplayScene::MakefilePrintPdf()
{
if (fileName.size() > 1) {
QString UserlastDirOpen
= fileName.
left(fileName.
lastIndexOf("/"))+"/";
setter.setValue("LastDir",UserlastDirOpen);
printer.
setOutputFormat(QPrinter::PdfFormat);
if (!fileName.endsWith(".pdf")) {
fileName = fileName+".pdf";
}
printer.setOutputFileName(fileName);
scene->render(&painter); /* scene QGraphicsScene */
if (is_file(fileName)) {
/* disply pdf if exist! */
OpenDesktop
(QUrl(fileName
));
}
}
}
/* XSL-FO -editor base widget */
/* http://www.zvon.org/xxl/xslfoReference/Output/index.html
<fo:simple-page-master margin-right="5pt" margin-left="5pt" margin-bottom="22pt" margin-top="22pt" page-width="21cm" page-height="29.7cm" master-name="first">
<fo:region-body/>
</fo:simple-page-master>
*/
void DisplayScene::MakefilePrintPdf()
{
QString fileName = QFileDialog::getSaveFileName(this, "Export PDF",QString(setter.value("LastDir").toString()), "*.pdf");
if (fileName.size() > 1) {
QString UserlastDirOpen = fileName.left(fileName.lastIndexOf("/"))+"/";
setter.setValue("LastDir",UserlastDirOpen);
QApplication::setOverrideCursor(QCursor(Qt::WaitCursor));
QPrinter printer(QPrinter::HighResolution);
printer.setOutputFormat(QPrinter::PdfFormat);
if (!fileName.endsWith(".pdf")) {
fileName = fileName+".pdf";
}
printer.setOutputFileName(fileName);
printer.setPageSize ( QPrinter::A4 );
QPainter painter(&printer);
scene->render(&painter); /* scene QGraphicsScene */
if (is_file(fileName)) {
QApplication::restoreOverrideCursor();
/* disply pdf if exist! */
OpenDesktop(QUrl(fileName));
}
}
QApplication::restoreOverrideCursor();
}
To copy to clipboard, switch view to plain text mode
Bookmarks