We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Hi, pdfcpu v0.3.13 I have some scanned pdf on which PropertiesList.Info is nil. I can't add title or property it trows error
goroutine 1 [running]: github.com/pdfcpu/pdfcpu/pkg/pdfcpu.PropertiesAdd(0xc000148b60, 0xc000141e30?)
in properties.go line 44 and 61 there's a TODO handle missing empty dict can you please add this feature
thank you
here's my code - is working if Info is not nil
date, err := ioutil.ReadFile(inPdf) ckErr(err) ctx, err := api.ReadContext(io.ReadSeeker(bytes.NewReader(date)), pdfcpu.NewDefaultConfiguration()) ckErr(err) pdfcpu.PropertiesRemove(ctx.XRefTable, []string{"Title", "Autor"}) properties := map[string]string{"Title": "modified ok"} pdfcpu.PropertiesAdd(ctx.XRefTable, properties) var b bytes.Buffer w := bufio.NewWriter(&b) err = api.WriteContext(ctx, w) ckErr(err) err = ioutil.WriteFile("prop_mod.pdf", b.Bytes(), 0644) ckErr(err)
The text was updated successfully, but these errors were encountered:
Thanks!
I'll check it out.
Sorry, something went wrong.
Hello, any news about this? can't we just link an empty Dict and return it ?
Done, i've slove it by adding new IndirectRef before propertiesAdd and eliminated PropertiesRemove
date, err := ioutil.ReadFile(inPdf) ckErr(err) ctx, err := api.ReadContext(io.ReadSeeker(bytes.NewReader(date)), pdfcpu.NewDefaultConfiguration()) ckErr(err) // ADD NEW EMPTY INFO IF NIL if ctx.XRefTable.Info == nil { ctx.XRefTable.Info = pdfcpu.NewIndirectRef(1, 0) } properties := map[string]string{"Title": "modified ok"} pdfcpu.PropertiesAdd(ctx.XRefTable, properties) var b bytes.Buffer w := bufio.NewWriter(&b) err = api.WriteContext(ctx, w) ckErr(err) err = ioutil.WriteFile("hello.pdf", b.Bytes(), 0644) ckErr(err)
can you please modify properties.go line 44 (PropertiesAdd) with this:
if xRefTable.Info == nil { xRefTable.Info = NewIndirectRef(1, 0) }
If PropertiesRemove is nil just return - do nothing since there's nothing to remove (properties.go line 61)
bfaf786
This is fixed with the latest commit.
hhrutter
No branches or pull requests
Hi,
pdfcpu v0.3.13
I have some scanned pdf on which PropertiesList.Info is nil. I can't add title or property it trows error
goroutine 1 [running]: github.com/pdfcpu/pdfcpu/pkg/pdfcpu.PropertiesAdd(0xc000148b60, 0xc000141e30?)
in properties.go line 44 and 61 there's a TODO handle missing empty dict
can you please add this feature
thank you
here's my code - is working if Info is not nil
The text was updated successfully, but these errors were encountered: