Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
O
OpenBoard
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
lifo
Nicolas Ollinger
OpenBoard
Commits
9e5198fb
Commit
9e5198fb
authored
Jan 30, 2012
by
Anatoly Mihalchenko
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Enhancements to raster PDF export
parent
6bbecff5
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
18 additions
and
22 deletions
+18
-22
UBExportPDF.cpp
src/adaptors/UBExportPDF.cpp
+17
-21
UBExportPDF.h
src/adaptors/UBExportPDF.h
+1
-1
No files found.
src/adaptors/UBExportPDF.cpp
View file @
9e5198fb
...
...
@@ -63,9 +63,8 @@ void UBExportPDF::persist(UBDocumentProxy* pDocumentProxy)
}
void
UBExportPDF
::
persistsDocument
(
UBDocumentProxy
*
pDocumentProxy
,
QString
filename
)
void
UBExportPDF
::
persistsDocument
(
UBDocumentProxy
*
pDocumentProxy
,
const
QString
&
filename
)
{
//PDF
QPrinter
pdfPrinter
;
qDebug
()
<<
"exporting document to PDF"
<<
filename
;
...
...
@@ -73,19 +72,15 @@ void UBExportPDF::persistsDocument(UBDocumentProxy* pDocumentProxy, QString file
pdfPrinter
.
setOutputFormat
(
QPrinter
::
PdfFormat
);
pdfPrinter
.
setResolution
(
UBSettings
::
settings
()
->
pdfResolution
->
get
().
toInt
());
pdfPrinter
.
setOutputFileName
(
filename
);
pdfPrinter
.
setFullPage
(
true
);
if
(
UBSettings
::
settings
()
->
pdfPageFormat
->
get
().
toString
()
==
"Letter"
)
pdfPrinter
.
setPageSize
(
QPrinter
::
Letter
);
else
pdfPrinter
.
setPageSize
(
QPrinter
::
A4
);
// pdfMargin is in mm, but margin should be in px
qreal
margin
=
UBSettings
::
settings
()
->
pdfMargin
->
get
().
toDouble
()
*
pdfPrinter
.
resolution
()
/
25.4
;
pdfPrinter
.
setOrientation
(
QPrinter
::
Landscape
);
pdfPrinter
.
setFullPage
(
true
);
QPainter
pdfPainter
(
&
pdfPrinter
);
//need to calculate screen resolution
QDesktopWidget
*
desktop
=
UBApplication
::
desktop
();
int
dpiCommon
=
(
desktop
->
physicalDpiX
()
+
desktop
->
physicalDpiY
())
/
2
;
float
scaleFactor
=
72.0
f
/
dpiCommon
;
QPainter
pdfPainter
;
bool
painterNeedsBegin
=
true
;
int
existingPageCount
=
pDocumentProxy
->
pageCount
();
...
...
@@ -98,20 +93,20 @@ void UBExportPDF::persistsDocument(UBDocumentProxy* pDocumentProxy, QString file
bool
isCrossed
=
scene
->
isCrossedBackground
();
scene
->
setBackground
(
false
,
false
);
QRectF
paperRect
=
pdfPrinter
.
paperRect
();
paperRect
=
paperRect
.
adjusted
(
margin
,
margin
,
-
margin
,
-
margin
);
QRectF
normalized
=
scene
->
normalizedSceneRect
(
paperRect
.
width
()
/
paperRect
.
height
());
QSize
pageSize
=
scene
->
nominalSize
();
// set high res rendering
scene
->
setRenderingQuality
(
UBItem
::
RenderingQualityHigh
);
scene
->
setRenderingContext
(
UBGraphicsScene
::
NonScreen
);
//setting page size to appropriate value
pdfPrinter
.
setPaperSize
(
QSizeF
(
pageSize
.
width
()
*
scaleFactor
,
pageSize
.
height
()
*
scaleFactor
),
QPrinter
::
Point
);
pdfPrinter
.
setOrientation
((
pageSize
.
width
()
>
pageSize
.
height
())
?
QPrinter
::
Landscape
:
QPrinter
::
Portrait
);
if
(
painterNeedsBegin
)
painterNeedsBegin
=
!
pdfPainter
.
begin
(
&
pdfPrinter
);
//render to PDF
scene
->
render
(
&
pdfPainter
,
paperRect
,
normalized
);
scene
->
render
(
&
pdfPainter
);
if
(
pageIndex
<
existingPageCount
-
1
)
pdfPrinter
.
newPage
();
if
(
pageIndex
<
existingPageCount
-
1
)
pdfPrinter
.
newPage
();
//restore screen rendering quality
scene
->
setRenderingContext
(
UBGraphicsScene
::
Screen
);
...
...
@@ -120,6 +115,7 @@ void UBExportPDF::persistsDocument(UBDocumentProxy* pDocumentProxy, QString file
//restore background state
scene
->
setBackground
(
isDark
,
isCrossed
);
}
if
(
!
painterNeedsBegin
)
pdfPainter
.
end
();
}
QString
UBExportPDF
::
exportExtention
()
...
...
src/adaptors/UBExportPDF.h
View file @
9e5198fb
...
...
@@ -33,7 +33,7 @@ class UBExportPDF : public UBExportAdaptor
virtual
QString
exportExtention
();
virtual
void
persist
(
UBDocumentProxy
*
pDocument
);
static
void
persistsDocument
(
UBDocumentProxy
*
pDocument
,
QString
filename
);
static
void
persistsDocument
(
UBDocumentProxy
*
pDocument
,
const
QString
&
filename
);
};
#endif
/* UBEXPORTPDF_H_ */
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment