Skip to content

Commit 4a9adac

Browse files
committed
Fix #157, bump version
1 parent a7901a1 commit 4a9adac

File tree

134 files changed

+66
-67
lines changed

Some content is hidden

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

134 files changed

+66
-67
lines changed

.gitignore

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,5 +15,11 @@ _scripts/*.csv
1515
dist/*
1616

1717
# Samples generated by tests
18-
pkg/samples/**
18+
# pkg/samples/create/*
19+
# pkg/samples/fonts/*
20+
# pkg/samples/grid/*
21+
# pkg/samples/import/*
22+
# pkg/samples/nup/*
23+
# pkg/samples/stamp/*
24+
# pkg/samples/watermark/*
1925

.goreleaser.yml

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -13,12 +13,18 @@ builds:
1313
- amd64
1414
dist: ./dist
1515
archives:
16-
- replacements:
17-
darwin: Darwin
18-
linux: Linux
19-
windows: Windows
20-
386: i386
21-
amd64: x86_64
16+
-
17+
format: tar.xz
18+
format_overrides:
19+
- goos: windows
20+
format: zip
21+
replacements:
22+
darwin: macOS
23+
linux: Linux
24+
windows: Windows
25+
386: i386
26+
amd64: x86_64
27+
wrap_in_directory: true
2228
checksum:
2329
name_template: 'checksums.txt'
2430
snapshot:

.travis.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
language: go
22

33
go:
4-
- 1.13.x
4+
- 1.14.x
55

66
os:
77
- linux

README.md

Lines changed: 4 additions & 6 deletions

pkg/api/test/import_test.go

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -58,29 +58,29 @@ func TestImportImages(t *testing.T) {
5858
impConf string
5959
ensureOutFile bool
6060
}{
61-
// Convert an image into a single page PDF.
62-
// The page dimensions will match the image dimensions.
61+
//Convert an image into a single page PDF.
62+
//The page dimensions will match the image dimensions.
6363
{"TestConvertImageToPDF",
6464
[]string{filepath.Join(resDir, "logoSmall.png")},
6565
"convertImage.pdf",
6666
"",
6767
false},
6868

6969
// Import an image as a new page of the existing output file.
70-
{"TestImportImage",
71-
[]string{filepath.Join(resDir, "logoSmall.png")},
72-
"importImage.pdf",
73-
"",
74-
true},
70+
// {"TestImportImage",
71+
// []string{filepath.Join(resDir, "logoSmall.png")},
72+
// "importImage.pdf",
73+
// "",
74+
// true},
7575

76-
// Import images by creating an A3 page for each image.
77-
// Images are page centered with 1.0 relative scaling.
78-
// Import an image as a new page of the existing output file.
76+
//Import images by creating an A3 page for each image.
77+
//Images are page centered with 1.0 relative scaling.
78+
//Import an image as a new page of the existing output file.
7979
{"TestCenteredImportImage",
8080
imageFileNames(t, "../../../resources"),
81-
"importImage.pdf",
81+
"importImageToA3.pdf",
8282
"f:A3, pos:c, s:1.0",
83-
true},
83+
false},
8484
} {
8585
testImportImages(t, tt.msg, tt.imgFiles, tt.outFile, tt.impConf, tt.ensureOutFile)
8686
}

pkg/api/test/nup_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ func imageFileNames(t *testing.T, dir string) []string {
6060
}
6161
fn := []string{}
6262
for _, fi := range files {
63-
if strings.HasSuffix(fi.Name(), "jpg") || strings.HasSuffix(fi.Name(), "png") {
63+
if strings.HasSuffix(fi.Name(), "png") || strings.HasSuffix(fi.Name(), "jpg") {
6464
fn = append(fn, filepath.Join(dir, fi.Name()))
6565
}
6666
}

pkg/pdfcpu/context.go

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -62,18 +62,18 @@ func (ctx *Context) ResetWriteContext() {
6262
ctx.Write = NewWriteContext(ctx.Write.Eol)
6363
}
6464

65-
func (rCtx *ReadContext) logReadContext(logStr []string) {
66-
if rCtx.UsingObjectStreams {
67-
logStr = append(logStr, "using object streams\n")
65+
func (rc *ReadContext) logReadContext(logStr *[]string) {
66+
if rc.UsingObjectStreams {
67+
*logStr = append(*logStr, "using object streams\n")
6868
}
69-
if rCtx.UsingXRefStreams {
70-
logStr = append(logStr, "using xref streams\n")
69+
if rc.UsingXRefStreams {
70+
*logStr = append(*logStr, "using xref streams\n")
7171
}
72-
if rCtx.Linearized {
73-
logStr = append(logStr, "is linearized file\n")
72+
if rc.Linearized {
73+
*logStr = append(*logStr, "is linearized file\n")
7474
}
75-
if rCtx.Hybrid {
76-
logStr = append(logStr, "is hybrid reference file\n")
75+
if rc.Hybrid {
76+
*logStr = append(*logStr, "is hybrid reference file\n")
7777
}
7878
}
7979

@@ -90,7 +90,7 @@ func (ctx *Context) String() string {
9090

9191
logStr = append(logStr, fmt.Sprintf("has %d pages\n", ctx.PageCount))
9292

93-
ctx.Read.logReadContext(logStr)
93+
ctx.Read.logReadContext(&logStr)
9494

9595
if ctx.Tagged {
9696
logStr = append(logStr, "is tagged file\n")

pkg/pdfcpu/doc.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,23 +8,23 @@ The commands are:
88
attachments list, add, remove, extract embedded file attachments
99
changeopw change owner password
1010
changeupw change user password
11-
collect create custom sequence of selected pages
11+
collect create custom sequence of selected pages
1212
decrypt remove password protection
1313
encrypt set password protection
1414
extract extract images, fonts, content, pages or metadata
1515
fonts install, list supported fonts
1616
grid rearrange pages or images for enhanced browsing experience
1717
import import/convert images to PDF
1818
info print file info
19-
keywords list, add, remove keywords
19+
keywords list, add, remove keywords
2020
merge concatenate PDFs
2121
nup rearrange pages or images for reduced number of pages
2222
optimize optimize PDF by getting rid of redundant page resources
2323
pages insert, remove selected pages
2424
paper print list of supported paper sizes
2525
permissions list, set user access permissions
2626
portfolio list, add, remove, extract portfolio entries with optional description
27-
properties list, add, remove document properties
27+
properties list, add, remove document properties
2828
rotate rotate pages
2929
split split up s PDF by span or bookmark
3030
stamp add, remove, update text, image or PDF stamps for selected pages

pkg/pdfcpu/utf16.go

Lines changed: 5 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -41,34 +41,20 @@ func IsStringUTF16BE(s string) bool {
4141
}
4242

4343
// IsUTF16BE checks for Big Endian byte order mark.
44-
func IsUTF16BE(b []byte) (ok bool, err error) {
45-
44+
func IsUTF16BE(b []byte) bool {
4645
if len(b) == 0 {
47-
return false, nil
48-
}
49-
50-
if len(b)%2 != 0 {
51-
return false, errors.Errorf("DecodeUTF16String: UTF16 needs even number of bytes: %v\n", b)
46+
return false
5247
}
53-
5448
// Check BOM
55-
ok = b[0] == 0xFE && b[1] == 0xFF
56-
57-
return ok, nil
49+
return b[0] == 0xFE && b[1] == 0xFF
5850
}
5951

6052
func decodeUTF16String(b []byte) (s string, err error) {
6153

6254
//log.Debug.Printf("decodeUTF16String: begin %v\n", b)
6355

64-
// Check for Big Endian UTF-16.
65-
isUTF16BE, err := IsUTF16BE(b)
66-
if err != nil {
67-
return
68-
}
69-
7056
// We only accept big endian byte order.
71-
if !isUTF16BE {
57+
if !IsUTF16BE(b) {
7258
err = errors.Errorf("decodeUTF16String: not UTF16BE: %v\n", b)
7359
return
7460
}
@@ -170,12 +156,7 @@ func HexLiteralToString(hexString string) (string, error) {
170156
}
171157

172158
// Check for Big Endian UTF-16.
173-
isUTF16BE, err := IsUTF16BE(b)
174-
//if err != nil {
175-
// return "", err
176-
//}
177-
178-
if isUTF16BE {
159+
if IsUTF16BE(b) {
179160
return decodeUTF16String(b)
180161
}
181162

pkg/pdfcpu/validate/objects.go

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -996,7 +996,11 @@ func validateString(xRefTable *pdf.XRefTable, o pdf.Object, validate func(string
996996
s, err = pdf.HexLiteralToString(o.Value())
997997

998998
default:
999-
return "", errors.New("pdfcpu: validateString: invalid type")
999+
err = errors.New("pdfcpu: validateString: invalid type")
1000+
}
1001+
1002+
if err != nil {
1003+
return s, err
10001004
}
10011005

10021006
// Validation
@@ -1047,7 +1051,11 @@ func validateStringEntry(xRefTable *pdf.XRefTable, d pdf.Dict, dictName, entryNa
10471051
s, err = pdf.HexLiteralToString(o.Value())
10481052

10491053
default:
1050-
return nil, errors.Errorf("pdfcpu: validateStringEntry: dict=%s entry=%s invalid type", dictName, entryName)
1054+
err = errors.Errorf("pdfcpu: validateStringEntry: dict=%s entry=%s invalid type", dictName, entryName)
1055+
}
1056+
1057+
if err != nil {
1058+
return nil, err
10511059
}
10521060

10531061
// Validation

pkg/pdfcpu/version.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ import (
2323
)
2424

2525
// VersionStr is the current pdfcpu version.
26-
var VersionStr = "v0.3.2 dev"
26+
var VersionStr = "v0.3.3 dev"
2727

2828
// Version is a type for the internal representation of PDF versions.
2929
type Version int
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.

pkg/samples/create/TextBorderTest.pdf

5.94 KB
Binary file not shown.
5.33 KB
Binary file not shown.

pkg/samples/create/TextRotateDemo.pdf

1.56 KB
Binary file not shown.
1.56 KB
Binary file not shown.
5.42 KB
Binary file not shown.
Binary file not shown.
4.11 KB
Binary file not shown.
Binary file not shown.

pkg/samples/create/acroFormDemo.pdf

5.69 KB
Binary file not shown.

pkg/samples/create/annotationDemo.pdf

6.57 MB
Binary file not shown.

pkg/samples/create/test.pdf

861 Bytes
Binary file not shown.
Binary file not shown.
1.89 KB
Binary file not shown.
2.21 KB
Binary file not shown.
2.27 KB
Binary file not shown.
1.98 KB
Binary file not shown.
Binary file not shown.
1.96 KB
Binary file not shown.
Binary file not shown.
1.59 KB
Binary file not shown.
Binary file not shown.
1.99 KB
Binary file not shown.
2.08 KB
Binary file not shown.
1.78 KB
Binary file not shown.
Binary file not shown.
2.2 KB
Binary file not shown.
2.27 KB
Binary file not shown.
1.97 KB
Binary file not shown.
Binary file not shown.
1.41 KB
Binary file not shown.
1.42 KB
Binary file not shown.
5.47 KB
Binary file not shown.
Binary file not shown.
2.76 KB
Binary file not shown.
2.78 KB
Binary file not shown.
2.77 KB
Binary file not shown.

pkg/samples/fonts/core/Courier.pdf

2.75 KB
Binary file not shown.
2.97 KB
Binary file not shown.
2.99 KB
Binary file not shown.
2.96 KB
Binary file not shown.

pkg/samples/fonts/core/Helvetica.pdf

2.93 KB
Binary file not shown.

pkg/samples/fonts/core/Symbol.pdf

2.99 KB
Binary file not shown.

pkg/samples/fonts/core/Times-Bold.pdf

2.98 KB
Binary file not shown.
2.99 KB
Binary file not shown.
2.96 KB
Binary file not shown.
2.96 KB
Binary file not shown.
3.07 KB
Binary file not shown.
9.13 MB
Binary file not shown.

pkg/samples/grid/testGridFromPDF.pdf

222 KB
Binary file not shown.

pkg/samples/import/convertImage.pdf

288 KB
Binary file not shown.
9.13 MB
Binary file not shown.

pkg/samples/nup/NUpFromImages.pdf

9.13 MB
Binary file not shown.
289 KB
Binary file not shown.

pkg/samples/nup/TestNUpFromPDF.pdf

3.37 MB
Binary file not shown.
342 KB
Binary file not shown.
Binary file not shown.
342 KB
Binary file not shown.
107 KB
Binary file not shown.
84.9 KB
Binary file not shown.
54.9 KB
Binary file not shown.
54.9 KB
Binary file not shown.
54.8 KB
Binary file not shown.
54.9 KB
Binary file not shown.
54.9 KB
Binary file not shown.
54.9 KB
Binary file not shown.
54.9 KB
Binary file not shown.
54.9 KB
Binary file not shown.
54.9 KB
Binary file not shown.
54.9 KB
Binary file not shown.
Binary file not shown.
Binary file not shown.
54.8 KB
Binary file not shown.
54.9 KB
Binary file not shown.
Binary file not shown.
54.9 KB
Binary file not shown.
54.9 KB
Binary file not shown.
54.9 KB
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
54.9 KB
Binary file not shown.
54.9 KB
Binary file not shown.
54.9 KB
Binary file not shown.
54.8 KB
Binary file not shown.
54.8 KB
Binary file not shown.
54.8 KB
Binary file not shown.
Binary file not shown.
Binary file not shown.
342 KB
Binary file not shown.
107 KB
Binary file not shown.
Binary file not shown.
54.9 KB
Binary file not shown.
54.9 KB
Binary file not shown.
54.8 KB
Binary file not shown.
54.9 KB
Binary file not shown.
54.9 KB
Binary file not shown.
54.9 KB
Binary file not shown.
54.9 KB
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
54.8 KB
Binary file not shown.
54.8 KB
Binary file not shown.
Binary file not shown.
54.9 KB
Binary file not shown.
54.9 KB
Binary file not shown.
54.9 KB
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
54.9 KB
Binary file not shown.
54.9 KB
Binary file not shown.
54.9 KB
Binary file not shown.
54.8 KB
Binary file not shown.
54.8 KB
Binary file not shown.
54.8 KB
Binary file not shown.

resources/stRoundBorder.png

136 KB

0 commit comments

Comments
 (0)