Note that there are some explanatory texts on larger screens.

plurals
  1. POWriting metadata to a pdf using pyobjc
    primarykey
    data
    text
    <p>I'm trying to write metadata to a pdf file using the following python code:</p> <pre><code>from Foundation import * from Quartz import * url = NSURL.fileURLWithPath_("test.pdf") pdfdoc = PDFDocument.alloc().initWithURL_(url) assert pdfdoc, "failed to create document" print "reading pdf file" attrs = {} attrs[PDFDocumentTitleAttribute] = "THIS IS THE TITLE" attrs[PDFDocumentAuthorAttribute] = "A. Author and B. Author" PDFDocumentTitleAttribute = "test" pdfdoc.setDocumentAttributes_(attrs) pdfdoc.writeToFile_("mynewfile.pdf") print "pdf made" </code></pre> <p>This appears to work fine (no errors to the consoled), however when I examine the metadata of the file it is as follows:</p> <pre><code>PdfID0: 242b7e252f1d3fdd89b35751b3f72d3 PdfID1: 242b7e252f1d3fdd89b35751b3f72d3 NumberOfPages: 4 </code></pre> <p>and the original file had the following metadata:</p> <pre><code>InfoKey: Creator InfoValue: PScript5.dll Version 5.2.2 InfoKey: Title InfoValue: Microsoft Word - PROGRESS ON THE GABION HOUSE Compressed.doc InfoKey: Producer InfoValue: GPL Ghostscript 8.15 InfoKey: Author InfoValue: PWK InfoKey: ModDate InfoValue: D:20101021193627-05'00' InfoKey: CreationDate InfoValue: D:20101008152350Z PdfID0: d5fd6d3960122ba72117db6c4d46cefa PdfID1: 24bade63285c641b11a8248ada9f19 NumberOfPages: 4 </code></pre> <p>So the problems are, it is not appending the metadata, and it is clearing the previous metadata structure. What do I need to do to get this to work? My objective is to append metadata that reference management systems can import.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload