Skip to content

Commit 0342a83

Browse files
committed
Bump version
1 parent b80cf0f commit 0342a83

File tree

113 files changed

+541
-237
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

113 files changed

+541
-237
lines changed

README.md

+7-7
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
[![Latest release](https://img.shields.io/github/release/pdfcpu/pdfcpu.svg)](https://github.com/pdfcpu/pdfcpu/releases)
1010

1111
<a href="https://pdfcpu.io"><img src="resources/logoSmall.png" width="150"></a>
12+
<a href="https://pdfa.org"><img src="resources/pdfa.png" width="75"></a>
1213

1314
pdfcpu is a PDF processing library written in [Go](http://golang.org) supporting encryption.
1415
It provides both an API and a CLI. Supported are all versions up to PDF 1.7 (ISO-32000).
@@ -51,6 +52,7 @@ The main focus lies on strong support for batch processing and scripting via a r
5152
* [collect](https://pdfcpu.io/core/collect)
5253
* [create](https://pdfcpu.io/generate/create)
5354
* [crop](https://pdfcpu.io/core/crop)
55+
* [cut](https://pdfcpu.io/generate/cut)
5456
* [decrypt](https://pdfcpu.io/encrypt/decryptPDF)
5557
* [encrypt](https://pdfcpu.io/encrypt/encryptPDF)
5658
* [extract](https://pdfcpu.io/extract/extract)
@@ -62,11 +64,13 @@ The main focus lies on strong support for batch processing and scripting via a r
6264
* [info](https://pdfcpu.io/info)
6365
* [keywords](https://pdfcpu.io/keywords/keywords)
6466
* [merge](https://pdfcpu.io/core/merge)
67+
* [ndown](https://pdfcpu.io/generate/ndown)
6568
* [nup](https://pdfcpu.io/generate/nup)
6669
* [optimize](https://pdfcpu.io/core/optimize)
6770
* [pages](https://pdfcpu.io/pages/pages)
6871
* [permissions](https://pdfcpu.io/encrypt/perm_add)
6972
* [portfolio](https://pdfcpu.io/portfolio/portfolio)
73+
* [poster](https://pdfcpu.io/generate/poster)
7074
* [properties](https://pdfcpu.io/properties/properties)
7175
* [resize](https://pdfcpu.io/core/resize)
7276
* [rotate](https://pdfcpu.io/core/rotate)
@@ -141,14 +145,15 @@ docker run -it --mount type=bind,source="$(pwd)",target=/app pdfcpu ./pdfcpu val
141145

142146
### What
143147

144-
* Please open an issue if you find a bug or want to propose a change.
148+
* Please [create](https://github.com/pdfcpu/pdfcpu/issues/new/choose) an issue if you find a bug or want to propose a change.
145149
* Feature requests - always welcome!
146150
* Bug fixes - always welcome!
147-
* PRs - anytime!
151+
* PRs - let's [discuss](https://github.com/pdfcpu/pdfcpu/discussions) first or [create](https://github.com/pdfcpu/pdfcpu/issues/new/choose) an issue.
148152
* pdfcpu is stable but still *Alpha* and occasionally undergoing heavy changes.
149153

150154
### How
151155

156+
* The pdfcpu [discussion board](https://github.com/pdfcpu/pdfcpu/discussions) is open! Please engage in any form helpful for the community.
152157
* If you want to report a bug please attach the *very verbose* (`pdfcpu cmd -vv ...`) output and ideally a test PDF that you can share.
153158
* Always make sure your contribution is based on the latest commit.
154159
* Please sign your commits.
@@ -201,8 +206,3 @@ Usage of pdfcpu assumes you know about and respect all copyrights of any PDF con
201206

202207
Apache-2.0
203208

204-
## Powered By
205-
206-
<p align="center">
207-
<a href="https://golang.org"> <img src="resources/Go-Logo_Aqua.png" width="200"> </a>
208-
</p>

cmd/pdfcpu/usage.go

+82-15
Original file line numberDiff line numberDiff line change
@@ -1109,14 +1109,33 @@ Supported usecases:
11091109
usageLongResize = `Resize existing pages.
11101110
11111111
pages ... please refer to "pdfcpu selectedpages"
1112-
description ... scalefactor, dimensions, enforce:f/t, formsize(=papersize), bgcolor
1112+
description ... scalefactor, dimensions, formsize, enforce, border, bgcolor
11131113
inFile ... input pdf file
11141114
outFile ... output pdf file
11151115
1116-
Use scalefactor < 1 to shrink pages
1117-
Use scalefactor > 1 to enlarge pages
1118-
1119-
Examples:
1116+
<description> is a comma separated configuration string containing:
1117+
1118+
scalefactor: Resize page by scale factor.
1119+
Use scale < 1 to shrink pages.
1120+
Use scale > 1 to enlarge pages.
1121+
1122+
formsize: Resize page to form/paper size eg. A4, Letter, Legal...
1123+
Append 'L' to enforce landscape mode. (eg. A3L)
1124+
Append 'P' to enforce portrait mode. (eg. A4P, TabloidP)
1125+
Please refer to "pdfcpu paper" for a comprehensive list of defined paper sizes.
1126+
"papersize" is also accepted.
1127+
1128+
dimensions: Resize page to custom dimensions.
1129+
(width height) in given display unit eg. "400 200"
1130+
1131+
enforce: if dimensions set only, enforce orientation (on/off, true/false, t/f).
1132+
1133+
border: if dimensions set only, draw content region border (on/off, true/false, t/f).
1134+
1135+
bgcolor: if dimensions set only, background color value for unused page regions.
1136+
1137+
1138+
Examples:
11201139
11211140
pdfcpu resize "scale:2" in.pdf out.pdf
11221141
Enlarge pages by doubling the page dimensions, keep orientation.
@@ -1143,14 +1162,34 @@ description ... scalefactor, dimensions, enforce:f/t, formsize(=papersize), bgco
11431162
usageLongPoster = `Create a poster using paper size.
11441163
11451164
pages ... Please refer to "pdfcpu selectedpages"
1146-
description ... formsize(=papersize), dimensions, scalefactor, border, margin, bgcolor
1165+
description ... formsize(=papersize), dimensions, scalefactor, margin, bgcolor, border
11471166
inFile ... input pdf file
11481167
outDir ... output directory
11491168
outFileName ... output file name
11501169
1151-
Optionally scale your page dimensions then define the poster grid tile size via form size or dimensions.
1170+
Optionally scale up your page dimensions then define the poster grid tile size via form size or dimensions.
1171+
1172+
<description> is a comma separated configuration string containing:
1173+
1174+
scalefactor: Enlarge page by scale factor > 1.
1175+
1176+
formsize: Posterize using tiles with form/paper size eg. A4, Letter, Legal...
1177+
Append 'L' to enforce landscape mode. (eg. A3L)
1178+
Append 'P' to enforce portrait mode. (eg. A4P, TabloidP)
1179+
Please refer to "pdfcpu paper" for a comprehensive list of defined paper sizes.
1180+
"papersize" is also accepted.
1181+
1182+
dimensions: Posterize using tiles with custom dimensions.
1183+
(width height) in given display unit eg. "400 200"
1184+
1185+
margin: Apply margin / glue area (float >= 0 in given display unit)
1186+
1187+
bgcolor: color value for visualization of margin / glue area.
1188+
1189+
border: if margin set, draw content region border (on/off, true/false, t/f)
1190+
11521191
1153-
Examples:
1192+
Examples:
11541193
11551194
pdfcpu poster "f:A4" in.pdf outDir
11561195
Page format is A2, the printer supports A4.
@@ -1160,21 +1199,30 @@ description ... scalefactor, dimensions, enforce:f/t, formsize(=papersize), bgco
11601199
Page format is A2, the printer supports A4.
11611200
Generate a poster(A0) via a corresponding 4x4 grid of A4 pages.
11621201
1163-
pdfcpu poster -u cm -- "dim:15 10" in.pdf outDir
1164-
Generate a poster via a corresponding grid with cell size 15x10 cm.
1202+
pdfcpu poster -u cm -- "dim:15 10, margin:1, bgcol:DarkGray, border:on" in.pdf outDir
1203+
Generate a poster via a corresponding grid with cell size 15x10 cm and provide a glue area of 1 cm.
11651204
11661205
See also the related commands: ndown, cut`
11671206

11681207
usageNDown = "usage: pdfcpu ndown [-p(ages) selectedPages] -- [description] n inFile outDir [outFileName]" + generalFlags
11691208
usageLongNDown = `Cut selected page into n pages symmetrically.
11701209
11711210
pages ... Please refer to "pdfcpu selectedpages"
1172-
description ... border, margin, bgcolor
1211+
description ... margin, bgcolor, border
11731212
n ... the n-Down value (see below for details)
11741213
inFile ... input pdf file
11751214
outDir ... output directory
11761215
outFileName ... output file name
11771216
1217+
<description> is a comma separated configuration string containing:
1218+
1219+
margin: Apply margin / glue area (float >= 0 in given display unit)
1220+
1221+
bgcolor: color value for visualization of margin / glue area.
1222+
1223+
border: if margin set, draw content region border (on/off, true/false, t/f)
1224+
1225+
11781226
grid Eg.
11791227
Supported values for n: 2 ... 1x2 A1 -> 2 x A2
11801228
3 ... 1x3
@@ -1184,7 +1232,8 @@ description ... scalefactor, dimensions, enforce:f/t, formsize(=papersize), bgco
11841232
12 ... 3x4
11851233
16 ... 4x4 A1 -> 16 x A5
11861234
1187-
Examples:
1235+
1236+
Examples:
11881237
11891238
pdfcpu ndown 2 in.pdf outDir
11901239
Page format is A2, the printer supports A3.
@@ -1193,22 +1242,41 @@ description ... scalefactor, dimensions, enforce:f/t, formsize(=papersize), bgco
11931242
pdfcpu ndown 4 in.pdf outDir
11941243
Page format is A2, the printer supports A4.
11951244
Quick cut page into 4 equally (A4) sized pages.
1245+
1246+
pdfcpu ndown -u cm -- "margin:1, bgcol:DarkGray, border:on" 4 in.pdf outDir
1247+
Page format is A2, the printer supports A4.
1248+
Quick cut page into 4 equally (A4) sized pages and provide a glue area of 1 cm.
11961249
11971250
See also the related commands: poster, cut`
11981251

11991252
usageCut = "usage: pdfcpu cut [-p(ages) selectedPages] -- description inFile outDir [outFileName]" + generalFlags
12001253
usageLongCut = `Custom cut pages horizontally or vertically.
12011254
12021255
pages ... Please refer to "pdfcpu selectedpages"
1203-
description ... horizontal, vertical, origin, bgcolor, border, margin
1256+
description ... horizontal, vertical, margin, bgcolor, border
12041257
inFile ... input pdf file
12051258
outDir ... output directory
12061259
outFileName ... output file name
12071260
12081261
Fine grained custom page cutting.
12091262
Apply any number of horizontal or vertical page cuts.
12101263
1211-
Examples:
1264+
<description> is a comma separated configuration string containing:
1265+
1266+
horizontal: Apply horizontal page cuts at height fraction (origin top left corner)
1267+
A sequence of fractions separated by white space.
1268+
1269+
vertical: Apply vertical page cuts at width fraction (origin top left corner)
1270+
A sequence of fractions separated by white space.
1271+
1272+
margin: Apply margin / glue area (float >= 0 in given display unit)
1273+
1274+
bgcolor: color value for visualization of margin / glue area.
1275+
1276+
border: if margin set, draw content region border (on/off, true/false, t/f)
1277+
1278+
1279+
Examples:
12121280
12131281
pdfcpu cut -- "hor:.25" inFile outDir
12141282
Apply a horizontal page cut at 0.25*height
@@ -1217,7 +1285,6 @@ description ... scalefactor, dimensions, enforce:f/t, formsize(=papersize), bgco
12171285
pdfcpu cut -- "hor:.25, vert:.75" inFile outDir
12181286
Apply a horizontal page cut at 0.25*height
12191287
Apply a vertical page cut at 0.75*width
1220-
Results in 4 PDF pages.
12211288
12221289
pdfcpu cut -- "hor:.33 .66" inFile outDir
12231290
Has the same effect as: pdfcpu ndown 3 in.pdf outDir

pkg/api/test/api_test.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -107,7 +107,7 @@ func copyFile(t *testing.T, srcFileName, destFileName string) error {
107107

108108
func imageFileNames(t *testing.T, dir string) []string {
109109
t.Helper()
110-
fn, err := model.ImageFileNames(dir)
110+
fn, err := model.ImageFileNames(dir, types.MB)
111111
if err != nil {
112112
t.Fatal(err)
113113
}

pkg/api/test/cut_test.go

+35-17
Original file line numberDiff line numberDiff line change
@@ -25,10 +25,10 @@ import (
2525
"github.com/pdfcpu/pdfcpu/pkg/pdfcpu/types"
2626
)
2727

28-
func testCut(t *testing.T, msg, inFile, outDir, outFile, cutConf string) {
28+
func testCut(t *testing.T, msg, inFile, outDir, outFile string, unit types.DisplayUnit, cutConf string) {
2929
t.Helper()
3030

31-
cut, err := pdfcpu.ParseCutConfig(cutConf, types.POINTS)
31+
cut, err := pdfcpu.ParseCutConfig(cutConf, unit)
3232
if err != nil {
3333
t.Fatalf("%s: %v\n", msg, err)
3434
}
@@ -46,46 +46,59 @@ func TestCut(t *testing.T) {
4646
msg string
4747
inFile string
4848
outDir, outFile string
49+
unit types.DisplayUnit
4950
cutConf string
5051
}{
5152
{"TestRotatedCutHor",
5253
"testRot.pdf",
5354
"cut",
5455
"cutHorRot",
55-
"hor:.5"},
56+
types.CENTIMETRES,
57+
"hor:.5, margin:1, border:on"},
5658

5759
{"TestCutHor",
5860
"test.pdf",
5961
"cut",
6062
"cutHor",
61-
"hor:.5"},
63+
types.CENTIMETRES,
64+
"hor:.5, margin:1, bgcol:#E9967A, border:on"},
6265

6366
{"TestCutVer",
6467
"test.pdf",
6568
"cut",
6669
"cutVer",
67-
"ver:.5"},
70+
types.CENTIMETRES,
71+
"ver:.5, margin:1, bgcol:#E9967A"},
6872

6973
{"TestCutHorAndVerQuarter",
7074
"test.pdf",
7175
"cut",
7276
"cutHorAndVerQuarter",
77+
types.POINTS,
7378
"h:.5, v:.5"},
7479

7580
{"TestCutHorAndVerThird",
7681
"test.pdf",
7782
"cut",
7883
"cutHorAndVerThird",
79-
"h:.33, h:.66, v:.33, v:.66"},
84+
types.POINTS,
85+
"h:.33333, h:.66666, v:.33333, v:.66666"},
86+
87+
{"Test",
88+
"test.pdf",
89+
"cut",
90+
"cutCustom",
91+
types.POINTS,
92+
"h:.25, v:.5"},
8093
} {
81-
testCut(t, tt.msg, tt.inFile, tt.outDir, tt.outFile, tt.cutConf)
94+
testCut(t, tt.msg, tt.inFile, tt.outDir, tt.outFile, tt.unit, tt.cutConf)
8295
}
8396
}
8497

85-
func testNDown(t *testing.T, msg, inFile, outDir, outFile string, n int, cutConf string) {
98+
func testNDown(t *testing.T, msg, inFile, outDir, outFile string, n int, unit types.DisplayUnit, cutConf string) {
8699
t.Helper()
87100

88-
cut, err := pdfcpu.ParseCutConfigForN(n, cutConf, types.POINTS)
101+
cut, err := pdfcpu.ParseCutConfigForN(n, cutConf, unit)
89102
if err != nil {
90103
t.Fatalf("%s: %v\n", msg, err)
91104
}
@@ -104,37 +117,42 @@ func TestNDown(t *testing.T) {
104117
inFile string
105118
outDir, outFile string
106119
n int
120+
unit types.DisplayUnit
107121
cutConf string
108122
}{
109123
{"TestNDownRot2",
110124
"testRot.pdf",
111125
"cut",
112126
"ndownRot2",
113127
2,
114-
""}, // optional border, margin, bgcolor
128+
types.CENTIMETRES,
129+
"margin:1, bgcol:#E9967A"},
115130

116131
{"TestNDown2",
117132
"test.pdf",
118133
"cut",
119134
"ndown2",
120135
2,
121-
""}, // optional border, margin, bgcolor
136+
types.CENTIMETRES,
137+
"margin:1, border:on"},
122138

123139
{"TestNDown9",
124140
"test.pdf",
125141
"cut",
126142
"ndown9",
127143
9,
128-
""}, // optional border, margin, bgcolor
144+
types.CENTIMETRES,
145+
"margin:1, bgcol:#E9967A, border:on"},
129146

130147
{"TestNDown16",
131148
"test.pdf",
132149
"cut",
133150
"ndown16",
134151
16,
152+
types.CENTIMETRES,
135153
""}, // optional border, margin, bgcolor
136154
} {
137-
testNDown(t, tt.msg, tt.inFile, tt.outDir, tt.outFile, tt.n, tt.cutConf)
155+
testNDown(t, tt.msg, tt.inFile, tt.outDir, tt.outFile, tt.n, tt.unit, tt.cutConf)
138156
}
139157
}
140158

@@ -173,22 +191,22 @@ func TestPoster(t *testing.T) {
173191
"test.pdf", // A4
174192
"cut",
175193
"posterScaled",
176-
types.POINTS,
177-
"f:A6, scale:2.0"},
194+
types.CENTIMETRES,
195+
"f:A6, scale:2.0, margin:1, bgcol:#E9967A"},
178196

179197
{"TestPosterDim", // grid made up of 15x10 cm tiles => A4
180198
"test.pdf", // A4
181199
"cut",
182200
"posterDim",
183201
types.CENTIMETRES,
184-
"dim:15 10"},
202+
"dim:15 10, margin:1, border:on"},
185203

186204
{"TestPosterDimScaled", // grid made up of 15x10 cm tiles => A2
187205
"test.pdf", // A4
188206
"cut",
189207
"posterDimScaled",
190208
types.CENTIMETRES,
191-
"dim:15 10, scale:2.0"},
209+
"dim:15 10, scale:2.0, margin:1, bgcol:#E9967A, border:on"},
192210
} {
193211
testPoster(t, tt.msg, tt.inFile, tt.outDir, tt.outFile, tt.unit, tt.cutConf)
194212
}

0 commit comments

Comments
 (0)