Skip to content

Commit 9749d6d

Browse files
committed
Fix #953
1 parent 8711370 commit 9749d6d

File tree

3 files changed

+10
-4
lines changed

3 files changed

+10
-4
lines changed

pkg/pdfcpu/types/types.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -428,7 +428,7 @@ func (nameObject Name) Clone() Object {
428428
}
429429

430430
func (nameObject Name) String() string {
431-
return fmt.Sprint(string(nameObject))
431+
return string(nameObject)
432432
}
433433

434434
// PDFString returns a string representation as found in and written to a PDF file.
@@ -442,7 +442,7 @@ func (nameObject Name) PDFString() string {
442442

443443
// Value returns a string value for this PDF object.
444444
func (nameObject Name) Value() string {
445-
return string(nameObject)
445+
return nameObject.String()
446446
}
447447

448448
///////////////////////////////////////////////////////////////////////////////////

pkg/pdfcpu/validate/object.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -712,7 +712,7 @@ func validateNameEntry(xRefTable *model.XRefTable, d types.Dict, dictName, entry
712712
// Validation
713713
v := name.Value()
714714
if validate != nil && (required || len(v) > 0) && !validate(v) {
715-
return nil, errors.Errorf("pdfcpu: validateNameEntry: dict=%s entry=%s invalid dict entry: %s", dictName, entryName, v)
715+
return &name, errors.Errorf("pdfcpu: validateNameEntry: dict=%s entry=%s invalid dict entry: %s", dictName, entryName, v)
716716
}
717717

718718
if log.ValidateEnabled() {

pkg/pdfcpu/validate/xReftable.go

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -298,7 +298,13 @@ func pageModeValidator(v model.Version) func(s string) bool {
298298
func validatePageMode(xRefTable *model.XRefTable, rootDict types.Dict, required bool, sinceVersion model.Version) error {
299299
n, err := validateNameEntry(xRefTable, rootDict, "rootDict", "PageMode", required, sinceVersion, pageModeValidator(xRefTable.Version()))
300300
if err != nil {
301-
return err
301+
if xRefTable.ValidationMode == model.ValidationStrict || n == nil {
302+
return err
303+
}
304+
// Relax validation of "UseAttachments" before PDF v1.6.
305+
if *n != "UseAttachments" {
306+
return err
307+
}
302308
}
303309

304310
if n != nil {

0 commit comments

Comments
 (0)