[TD]fix page margins on pdf export (fix #15848)
This commit is contained in:
committed by
Yorik van Havre
parent
248b05e379
commit
6678923486
@@ -134,6 +134,8 @@ void PagePrinter::makePageLayout(TechDraw::DrawPage* dPage, QPageLayout& pageLay
|
||||
height = attr.pageheight;
|
||||
pageLayout.setPageSize(QPageSize(attr.paperSize));
|
||||
pageLayout.setOrientation(attr.orientation);
|
||||
pageLayout.setMode(QPageLayout::FullPageMode);
|
||||
pageLayout.setMargins(QMarginsF());
|
||||
}
|
||||
|
||||
/// print the Page associated with the parent MDIViewPage as a Pdf file
|
||||
@@ -149,6 +151,7 @@ void PagePrinter::printPdf(std::string file)
|
||||
QString outputFile = QString::fromUtf8(file.data(), file.size());
|
||||
QPdfWriter pdfWriter(outputFile);
|
||||
QPageLayout pageLayout = pdfWriter.pageLayout();
|
||||
auto marginsdb = pageLayout.margins(QPageLayout::Millimeter);
|
||||
QString documentName = QString::fromUtf8(m_vpPage->getDrawPage()->getNameInDocument());
|
||||
pdfWriter.setTitle(documentName);
|
||||
// default pdfWriter dpi is 1200.
|
||||
@@ -159,6 +162,7 @@ void PagePrinter::printPdf(std::string file)
|
||||
double height = A4Widthmm;
|
||||
makePageLayout(dPage, pageLayout, width, height);
|
||||
pdfWriter.setPageLayout(pageLayout);
|
||||
marginsdb = pageLayout.margins(QPageLayout::Millimeter);
|
||||
|
||||
// first page does not respect page layout unless painter is created after
|
||||
// pdfWriter layout is established.
|
||||
@@ -229,16 +233,6 @@ void PagePrinter::printAll(QPrinter* printer, App::Document* doc)
|
||||
makePageLayout(dPage, pageLayout, width, height);
|
||||
printer->setPageLayout(pageLayout);
|
||||
|
||||
//for some reason the first page doesn't obey the pageLayout, so we have to print
|
||||
//a sacrificial blank page, but we make it a feature instead of a bug by printing a
|
||||
//table of contents on the sacrificial page.
|
||||
// Note: if the painter(printer) occurs after the printer->setPageLayout, then the
|
||||
// first page will obey the layout. This would mean creating the painter inside the
|
||||
// loop.
|
||||
// if (firstTime) {
|
||||
// firstTime = false;
|
||||
// printBannerPage(printer, painter, pageLayout, doc, docObjs);
|
||||
// }
|
||||
if (!firstTime) {
|
||||
printer->newPage();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user