Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
P
poppler
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Service Desk
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Operations
Operations
Incidents
Environments
Packages & Registries
Packages & Registries
Container Registry
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Nathanael Noblet
poppler
Commits
311db0b2
Commit
311db0b2
authored
Dec 05, 2019
by
corentinfoucault
Committed by
Albert Astals Cid
Dec 05, 2019
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
[PdfToPpm] Add an option to scale before rotate
-scale-dimension-before-rotation
parent
5aa8552b
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
19 additions
and
6 deletions
+19
-6
utils/pdftoppm.1
utils/pdftoppm.1
+3
-0
utils/pdftoppm.cc
utils/pdftoppm.cc
+16
-6
No files found.
utils/pdftoppm.1
View file @
311db0b2
...
...
@@ -62,6 +62,9 @@ Scales each page vertically to fit in scale-to-y pixels. If scale-to-x
is set to -1, the horizontal size will determined by the aspect ratio
of the page.
.TP
.B \-scale-dimension-before-rotation
Swaps horizontal and vertical size for a rotated (landscape) pdf before scaling instead of after.
.TP
.BI \-x " number"
Specifies the x-coordinate of the crop area top left corner
.TP
...
...
utils/pdftoppm.cc
View file @
311db0b2
...
...
@@ -74,6 +74,7 @@ static int lastPage = 0;
static
bool
printOnlyOdd
=
false
;
static
bool
printOnlyEven
=
false
;
static
bool
singleFile
=
false
;
static
bool
scaleDimensionBeforeRotation
=
false
;
static
double
resolution
=
0.0
;
static
double
x_resolution
=
150.0
;
static
double
y_resolution
=
150.0
;
...
...
@@ -128,6 +129,8 @@ static const ArgDesc argDesc[] = {
"print only even pages"
},
{
"-singlefile"
,
argFlag
,
&
singleFile
,
0
,
"write only the first page and do not add digits"
},
{
"-scale-dimension-before-rotation"
,
argFlag
,
&
scaleDimensionBeforeRotation
,
0
,
"for rotated pdf, resize dimensions before the rotation"
},
{
"-r"
,
argFP
,
&
resolution
,
0
,
"resolution, in DPI (default is 150)"
},
...
...
@@ -218,6 +221,11 @@ static const ArgDesc argDesc[] = {
{}
};
static
bool
needToRotate
(
int
angle
)
{
return
(
angle
==
90
)
||
(
angle
==
270
);
}
static
bool
parseJpegOptions
()
{
//jpegOpt format is: <opt1>=<val1>,<opt2>=<val2>,...
...
...
@@ -395,7 +403,7 @@ int main(int argc, char *argv[]) {
bool
ok
;
int
exitCode
;
int
pg
,
pg_num_len
;
double
pg_w
,
pg_h
,
tmp
;
double
pg_w
,
pg_h
;
Win32Console
win32Console
(
&
argc
,
&
argv
);
exitCode
=
99
;
...
...
@@ -558,6 +566,9 @@ int main(int argc, char *argv[]) {
pg_h
=
doc
->
getPageMediaHeight
(
pg
);
}
if
(
scaleDimensionBeforeRotation
&&
needToRotate
(
doc
->
getPageRotate
(
pg
)))
std
::
swap
(
pg_w
,
pg_h
);
if
(
scaleTo
!=
0
)
{
resolution
=
(
72.0
*
scaleTo
)
/
(
pg_w
>
pg_h
?
pg_w
:
pg_h
);
x_resolution
=
y_resolution
=
resolution
;
...
...
@@ -575,11 +586,10 @@ int main(int argc, char *argv[]) {
}
pg_w
=
pg_w
*
(
x_resolution
/
72.0
);
pg_h
=
pg_h
*
(
y_resolution
/
72.0
);
if
((
doc
->
getPageRotate
(
pg
)
==
90
)
||
(
doc
->
getPageRotate
(
pg
)
==
270
))
{
tmp
=
pg_w
;
pg_w
=
pg_h
;
pg_h
=
tmp
;
}
if
(
!
scaleDimensionBeforeRotation
&&
needToRotate
(
doc
->
getPageRotate
(
pg
)))
std
::
swap
(
pg_w
,
pg_h
);
if
(
ppmRoot
!=
nullptr
)
{
const
char
*
ext
=
png
?
"png"
:
(
jpeg
||
jpegcmyk
)
?
"jpg"
:
tiff
?
"tif"
:
mono
?
"pbm"
:
gray
?
"pgm"
:
"ppm"
;
if
(
singleFile
&&
!
forceNum
)
{
...
...
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