Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
P
pagedjs-cli
Manage
Activity
Members
Labels
Plan
Issues
0
Issue boards
Milestones
Wiki
Requirements
Code
Merge requests
0
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Releases
Package Registry
Container Registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Insights
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Mathis Poncet
pagedjs-cli
Commits
cfc07b9c
Unverified
Commit
cfc07b9c
authored
5 years ago
by
incymbalis
Browse files
Options
Downloads
Patches
Plain Diff
preferCSSPageSize *does* work after all
parent
6bd3d0b8
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
src/printer.js
+1
-15
1 addition, 15 deletions
src/printer.js
with
1 addition
and
15 deletions
src/printer.js
+
1
−
15
View file @
cfc07b9c
...
...
@@ -192,7 +192,7 @@ class Printer extends EventEmitter {
let
settings
=
{
printBackground
:
true
,
displayHeaderFooter
:
false
,
//
preferCSSPageSize: options.width ? false : true,
// does not currently work with bleeds: needs to be calculated from the document
preferCSSPageSize
:
options
.
width
?
false
:
true
,
width
:
options
.
width
,
height
:
options
.
height
,
orientation
:
options
.
orientation
,
...
...
@@ -204,20 +204,6 @@ class Printer extends EventEmitter {
}
}
if
(
!
options
.
width
)
{
// calculate paper size from the first page's dimensions
await
page
.
exposeFunction
(
'
setWidthHeight
'
,
(
width
,
height
)
=>
{
settings
.
width
=
`
${
width
}
mm`
;
settings
.
height
=
`
${
height
}
mm`
;
});
await
page
.
evaluate
(()
=>
{
const
rect
=
document
.
querySelector
(
'
.pagedjs_page
'
).
getBoundingClientRect
();
setWidthHeight
(
Math
.
round
(
CSS
.
px
(
rect
.
width
).
to
(
'
mm
'
).
value
),
Math
.
round
(
CSS
.
px
(
rect
.
height
).
to
(
'
mm
'
).
value
)
);
});
}
let
pdf
=
await
page
.
pdf
(
settings
)
.
catch
((
e
)
=>
{
console
.
error
(
e
);
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment