MCPcopy Index your code
hub / github.com/Audio4Linux/JDSP4Linux / savePdf

Method savePdf

3rdparty/qcustomplot/qcustomplot.cpp:15237–15298  ·  view source on GitHub ↗

! Saves a PDF with the vectorized plot to the file \a fileName. The axis ratio as well as the scale of texts and lines will be derived from the specified \a width and \a height. This means, the output will look like the normal on-screen output of a QCustomPlot widget with the corresponding pixel width and height. If either \a width or \a height is zero, the exported image will have the s

Source from the content-addressed store, hash-verified

15235 \see savePng, saveBmp, saveJpg, saveRastered
15236*/
15237bool QCustomPlot::savePdf(const QString &fileName, int width, int height, QCP::ExportPen exportPen, const QString &pdfCreator, const QString &pdfTitle)
15238{
15239 bool success = false;
15240#ifdef QT_NO_PRINTER
15241 Q_UNUSED(fileName)
15242 Q_UNUSED(exportPen)
15243 Q_UNUSED(width)
15244 Q_UNUSED(height)
15245 Q_UNUSED(pdfCreator)
15246 Q_UNUSED(pdfTitle)
15247 qDebug() << Q_FUNC_INFO << "Qt was built without printer support (QT_NO_PRINTER). PDF not created.";
15248#else
15249 int newWidth, newHeight;
15250 if (width == 0 || height == 0)
15251 {
15252 newWidth = this->width();
15253 newHeight = this->height();
15254 } else
15255 {
15256 newWidth = width;
15257 newHeight = height;
15258 }
15259
15260 QPrinter printer(QPrinter::ScreenResolution);
15261 printer.setOutputFileName(fileName);
15262 printer.setOutputFormat(QPrinter::PdfFormat);
15263 printer.setColorMode(QPrinter::Color);
15264 printer.printEngine()->setProperty(QPrintEngine::PPK_Creator, pdfCreator);
15265 printer.printEngine()->setProperty(QPrintEngine::PPK_DocumentName, pdfTitle);
15266 QRect oldViewport = viewport();
15267 setViewport(QRect(0, 0, newWidth, newHeight));
15268#if QT_VERSION < QT_VERSION_CHECK(5, 3, 0)
15269 printer.setFullPage(true);
15270 printer.setPaperSize(viewport().size(), QPrinter::DevicePixel);
15271#else
15272 QPageLayout pageLayout;
15273 pageLayout.setMode(QPageLayout::FullPageMode);
15274 pageLayout.setOrientation(QPageLayout::Portrait);
15275 pageLayout.setMargins(QMarginsF(0, 0, 0, 0));
15276 pageLayout.setPageSize(QPageSize(viewport().size(), QPageSize::Point, QString(), QPageSize::ExactMatch));
15277 printer.setPageLayout(pageLayout);
15278#endif
15279 QCPPainter printpainter;
15280 if (printpainter.begin(&printer))
15281 {
15282 printpainter.setMode(QCPPainter::pmVectorized);
15283 printpainter.setMode(QCPPainter::pmNoCaching);
15284 printpainter.setMode(QCPPainter::pmNonCosmetic, exportPen==QCP::epNoCosmetic);
15285 printpainter.setWindow(mViewport);
15286 if (mBackgroundBrush.style() != Qt::NoBrush &&
15287 mBackgroundBrush.color() != Qt::white &&
15288 mBackgroundBrush.color() != Qt::transparent &&
15289 mBackgroundBrush.color().alpha() > 0) // draw pdf background color if not white/transparent
15290 printpainter.fillRect(viewport(), mBackgroundBrush);
15291 draw(&printpainter);
15292 printpainter.end();
15293 success = true;
15294 }

Callers

nothing calls this directly

Calls 10

viewportFunction · 0.85
QRectClass · 0.85
setMarginsMethod · 0.80
alphaMethod · 0.80
QStringClass · 0.50
sizeMethod · 0.45
setModeMethod · 0.45
beginMethod · 0.45
colorMethod · 0.45
endMethod · 0.45

Tested by

no test coverage detected