Skip to content

Commit fd34b05

Browse files
committed
Fix #821
1 parent dfaa588 commit fd34b05

File tree

2 files changed

+8
-5
lines changed

2 files changed

+8
-5
lines changed

pkg/api/attach.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -107,7 +107,7 @@ func AddAttachments(rs io.ReadSeeker, w io.Writer, files []string, coll bool, co
107107
return errors.New("pdfcpu: AddAttachments: No attachment added")
108108
}
109109

110-
return WriteContext(ctx, w)
110+
return Write(ctx, w, conf)
111111
}
112112

113113
// AddAttachmentsFile embeds files into a PDF context read from inFile and writes the result to outFile.
@@ -176,7 +176,7 @@ func RemoveAttachments(rs io.ReadSeeker, w io.Writer, files []string, conf *mode
176176
return errors.New("pdfcpu: RemoveAttachments: No attachment removed")
177177
}
178178

179-
return WriteContext(ctx, w)
179+
return Write(ctx, w, conf)
180180
}
181181

182182
// RemoveAttachmentsFile deletes embedded files from a PDF context read from inFile and writes the result to outFile.

pkg/pdfcpu/validate/xReftable.go

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -147,6 +147,11 @@ func validateNames(xRefTable *model.XRefTable, rootDict types.Dict, required boo
147147
continue
148148
}
149149

150+
if xRefTable.Names[treeName] != nil {
151+
// Already internalized.
152+
continue
153+
}
154+
150155
d, err := xRefTable.DereferenceDict(value)
151156
if err != nil {
152157
return err
@@ -160,10 +165,8 @@ func validateNames(xRefTable *model.XRefTable, rootDict types.Dict, required boo
160165
return err
161166
}
162167

163-
// Internalize this name tree.
164-
// If no validation takes place, name trees have to be internalized via xRefTable.LocateNameTree
165-
// TODO Move this out of validation into Read.
166168
if tree != nil {
169+
// Internalize.
167170
xRefTable.Names[treeName] = tree
168171
}
169172

0 commit comments

Comments
 (0)