Skip to content


Fix #94
Browse files Browse the repository at this point in the history
  • Loading branch information
hhrutter committed Jul 21, 2019
1 parent 3b47039 commit 18994fd
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 22 deletions.
21 changes: 11 additions & 10 deletions
@@ -1,4 +1,4 @@
# pdfcpu: a golang pdf processor
# pdfcpu: a Go PDF processor

[![Build Status](](
Expand All @@ -17,15 +17,15 @@ It provides both an API and a CLI. Supported are all versions up to PDF 1.7 (ISO
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.

<p align="center">
<kbd><img src="resources/gridpdf.png" height="150"></kbd>&nbsp;
<kbd><img src="resources/wmi1abs.png" height="150"></kbd>&nbsp;
<kbd><img src="resources/nup9pdf.png" height="150"></kbd>&nbsp;
<kbd><img src="resources/stt31.png" height="150"></kbd><br><br>
<kbd><img src="resources/sti.png" height="150"></kbd>&nbsp;
<kbd><a href=""><img src="resources/gridpdf.png" height="150"></a></kbd>&nbsp;
<kbd><a href=""><img src="resources/wmi1abs.png" height="150"></a></kbd>&nbsp;
<kbd><a href=""><img src="resources/nup9pdf.png" height="150"></a></kbd>&nbsp;
<kbd><a href=""><img src="resources/stt31.png" height="150"></a></kbd><br><br>
<kbd><a href=""><img src="resources/sti.png" height="150"></a></kbd>&nbsp;
<kbd><img src="resources/hold3.png" height="150"></kbd>&nbsp;
<kbd><img src="resources/wmi4.png" height="150"></kbd>&nbsp;<br><br>
<kbd><img src="resources/stp.png" height="150"></kbd>&nbsp;
<kbd><img src="resources/gridimg.png" height="150"></kbd>
<kbd><a href=""><img src="resources/wmi4.png" height="150"></a></kbd>&nbsp;<br><br>
<kbd><a href=""><img src="resources/stp.png" height="150"></a></kbd>&nbsp;
<kbd><a href=""><img src="resources/gridimg.png" height="150"></a></kbd>

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

* [pdfcpu package](
* [pdfcpu api](
* [pdfcpu API](
* [pdfcpu CLI](

## Status

Expand Down
9 changes: 6 additions & 3 deletions pkg/pdfcpu/writeObjects.go
Expand Up @@ -204,9 +204,12 @@ func writeObject(ctx *Context, objNumber, genNumber int, s string) error {

w := ctx.Write

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

// Set write-offset for this object.
Expand Down
12 changes: 3 additions & 9 deletions pkg/pdfcpu/xreftable.go
Expand Up @@ -266,17 +266,11 @@ func (xRefTable *XRefTable) FindTableEntryLight(objNr int) (*XRefTableEntry, boo
func (xRefTable *XRefTable) FindTableEntry(objNr int, genNr int) (*XRefTableEntry, bool) {

//fmt.Printf("FindTableEntry: obj#:%d gen:%d \n", objNumber, generationNumber)

entry, found := xRefTable.Find(objNr)
// if found && entry == nil {
// fmt.Printf("FindTableEntry(%d,%d) finds entry = nil!\n", objNr, genNr)
// }

if found && *entry.Generation == genNr {
return entry, found
if !found || *entry.Generation != genNr {
return nil, false

return nil, false
return entry, found

// FindTableEntryForIndRef returns the XRefTable entry for given indirect reference.
Expand Down
Binary file modified resources/gridimg.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit 18994fd

Please sign in to comment.