michaelrsweet / pdfio

PDFio is a simple C library for reading and writing PDF files.
https://www.msweet.org/pdfio
Apache License 2.0
198 stars 44 forks source link

Cant get info from PDF #33

Closed ire4ever1190 closed 2 years ago

ire4ever1190 commented 2 years ago

Can't get info (e.g. author, subject, keywords) from PDF when reading in from a file

To Reproduce Compile and run this

#include "pdfio.h"

int main() {
  { // Create the test file
    pdfio_file_t *pdf = pdfioFileCreate("test.pdf", "2.0", NULL, NULL, NULL, NULL);
    pdfioFileSetAuthor(pdf, "John Doe");
    printf("%s\n", pdfioFileGetAuthor(pdf));
    pdfioFileClose(pdf);
  }
  { // Read it back in
    pdfio_file_t *pdf = pdfioFileOpen("test.pdf", NULL, NULL, NULL, NULL);
    printf("%s", pdfioFileGetAuthor(pdf));
    pdfioFileClose(pdf);
  }
}

Expected behavior File should be read back in correctly and print "John Doe" twice

Additional Info I can find /Author(John Doe) in the info object so it does seem to be writing correctly

System Information:

michaelrsweet commented 2 years ago

@ire4ever1190 Weird, because the unit test program (testpdfio.c) explicitly tests pdfioFileGet/SetAuthor, but not after opening the file a second time. Will add that and test...

michaelrsweet commented 2 years ago

OK, I'm able to reproduce...

michaelrsweet commented 2 years ago

[master a3f3bbf] Fix pdfioFileGetAuthor, etc. APIs (Issue #33)