Skip to content

Commit 18994fd

Browse files
committed
Fix pdfcpu#94
1 parent 3b47039 commit 18994fd

File tree

4 files changed

+20
-22
lines changed

4 files changed

+20
-22
lines changed

README.md

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# pdfcpu: a golang pdf processor
1+
# pdfcpu: a Go PDF processor
22

33
[![Build Status](https://travis-ci.org/hhrutter/pdfcpu.svg?branch=master)](https://travis-ci.org/hhrutter/pdfcpu)
44
[![GoDoc](https://godoc.org/github.com/hhrutter/pdfcpu?status.svg)](https://godoc.org/github.com/hhrutter/pdfcpu)
@@ -17,15 +17,15 @@ It provides both an API and a CLI. Supported are all versions up to PDF 1.7 (ISO
1717
This is an effort to build a comprehensive PDF processing library from the ground up written in Go. Over time pdfcpu aims to support the standard range of PDF processing features and also any interesting use cases that may present themselves along the way.
1818

1919
<p align="center">
20-
<kbd><img src="resources/gridpdf.png" height="150"></kbd>&nbsp;
21-
<kbd><img src="resources/wmi1abs.png" height="150"></kbd>&nbsp;
22-
<kbd><img src="resources/nup9pdf.png" height="150"></kbd>&nbsp;
23-
<kbd><img src="resources/stt31.png" height="150"></kbd><br><br>
24-
<kbd><img src="resources/sti.png" height="150"></kbd>&nbsp;
20+
<kbd><a href="https://pdfcpu.io/core/grid"><img src="resources/gridpdf.png" height="150"></a></kbd>&nbsp;
21+
<kbd><a href="https://pdfcpu.io/core/watermark"><img src="resources/wmi1abs.png" height="150"></a></kbd>&nbsp;
22+
<kbd><a href="https://pdfcpu.io/core/nup"><img src="resources/nup9pdf.png" height="150"></a></kbd>&nbsp;
23+
<kbd><a href="https://pdfcpu.io/core/stamp"><img src="resources/stt31.png" height="150"></a></kbd><br><br>
24+
<kbd><a href="https://pdfcpu.io/core/stamp"><img src="resources/sti.png" height="150"></a></kbd>&nbsp;
2525
<kbd><img src="resources/hold3.png" height="150"></kbd>&nbsp;
26-
<kbd><img src="resources/wmi4.png" height="150"></kbd>&nbsp;<br><br>
27-
<kbd><img src="resources/stp.png" height="150"></kbd>&nbsp;
28-
<kbd><img src="resources/gridimg.png" height="150"></kbd>
26+
<kbd><a href="https://pdfcpu.io/core/watermark"><img src="resources/wmi4.png" height="150"></a></kbd>&nbsp;<br><br>
27+
<kbd><a href="https://pdfcpu.io/core/stamp"><img src="resources/stp.png" height="150"></a></kbd>&nbsp;
28+
<kbd><a href="https://pdfcpu.io/core/grid"><img src="resources/gridimg.png" height="150"></a></kbd>
2929
</p>
3030

3131
## Focus
@@ -64,7 +64,8 @@ The main focus lies on strong support for batch processing and scripting via a r
6464
### GoDoc
6565

6666
* [pdfcpu package](https://godoc.org/github.com/hhrutter/pdfcpu)
67-
* [pdfcpu api](https://godoc.org/github.com/hhrutter/pdfcpu/pkg/api)
67+
* [pdfcpu API](https://godoc.org/github.com/hhrutter/pdfcpu/pkg/api)
68+
* [pdfcpu CLI](https://godoc.org/github.com/hhrutter/pdfcpu/pkg/cli)
6869

6970
## Status
7071

pkg/pdfcpu/writeObjects.go

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -204,9 +204,12 @@ func writeObject(ctx *Context, objNumber, genNumber int, s string) error {
204204

205205
w := ctx.Write
206206

207-
// Cleanup entry (nexessary for split command)
208-
entry, _ := ctx.FindTableEntry(objNumber, genNumber)
209-
entry.Compressed = false
207+
// Cleanup entry (necessary for split command)
208+
// TODO This is not the right place to check for an existing obj since we maybe writing NULL.
209+
entry, ok := ctx.FindTableEntry(objNumber, genNumber)
210+
if ok {
211+
entry.Compressed = false
212+
}
210213

211214
// Set write-offset for this object.
212215
w.SetWriteOffset(objNumber)

pkg/pdfcpu/xreftable.go

Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -266,17 +266,11 @@ func (xRefTable *XRefTable) FindTableEntryLight(objNr int) (*XRefTableEntry, boo
266266
func (xRefTable *XRefTable) FindTableEntry(objNr int, genNr int) (*XRefTableEntry, bool) {
267267

268268
//fmt.Printf("FindTableEntry: obj#:%d gen:%d \n", objNumber, generationNumber)
269-
270269
entry, found := xRefTable.Find(objNr)
271-
// if found && entry == nil {
272-
// fmt.Printf("FindTableEntry(%d,%d) finds entry = nil!\n", objNr, genNr)
273-
// }
274-
275-
if found && *entry.Generation == genNr {
276-
return entry, found
270+
if !found || *entry.Generation != genNr {
271+
return nil, false
277272
}
278-
279-
return nil, false
273+
return entry, found
280274
}
281275

282276
// FindTableEntryForIndRef returns the XRefTable entry for given indirect reference.

resources/gridimg.png

-382 KB
Loading

0 commit comments

Comments
 (0)