Page 1 of 1

Set PDF metadata using Livecode

Posted: Fri Jun 24, 2016 11:02 am
by PaoloMazza
Is it possible to modify the metadata of a document (PDF) using Livecode?
Is there any stack around able to accomplish this task?
Thanks
Paolo

Re: Set PDF metadata using Livecode

Posted: Fri Jun 24, 2016 12:17 pm
by Klaus
Buongiorno Paolo,

no, currently only setting metadata (and only the "density") when exporting images are supported in LC 8.x.
See the dictionary for "export image with metadata..."


Best

Klaus

Re: Set PDF metadata using Livecode

Posted: Fri Jun 24, 2016 3:12 pm
by FourthWorld
See the optional "with options <array>" clause for the "open printing to PDF" entry in the Dictionary.

Currently the supported metadata includes: Title, Author, Subject, Keywords, Creator, Producer. Their values can be any string.

This only applies to PDFs generated within LiveCode, however. If you need to modify a PDF generated elsewhere you may need to use an external tool for that, though many can be invoked with a command line call executed in LiveCode's shell function.

Re: Set PDF metadata using Livecode

Posted: Fri Jun 24, 2016 3:25 pm
by Klaus
Ah, yes, completely forgot about that one! :oops:
However I had the impression that Paolo meant existing PDF documents!?

Re: Set PDF metadata using Livecode

Posted: Fri Jun 24, 2016 3:49 pm
by FourthWorld
Klaus wrote:Ah, yes, completely forgot about that one! :oops:
However I had the impression that Paolo meant existing PDF documents!?
I think you're right, but it seemed worth mentioning on the odd chance that generating new PDFs may be an option. And if not hopefully a command line tool can help fill in the gaps, or using calls to a PDF library more directly via LiveCode Builder.

Re: Set PDF metadata using Livecode

Posted: Fri Jun 24, 2016 4:24 pm
by PaoloMazza
Thank you all. Yes I meant existing PDF documents.
People said that Hypercard was able to accomplish this task. So I thought LiveCode can do the same.
Thank you very much.
Paolo

Re: Set PDF metadata using Livecode

Posted: Fri Jun 24, 2016 4:39 pm
by PaoloMazza
By the way, any chance to create and save a pdf file from a stack in the LiveCode server using the "open printing to PDF" command?
I tried but I got an error.
I am supposed to use the on-rev server with LiveCode 6.5 .
Thanks
Paolo

Re: Set PDF metadata using Livecode

Posted: Fri Jun 24, 2016 6:00 pm
by FourthWorld
PaoloMazza wrote:Thank you all. Yes I meant existing PDF documents.
People said that Hypercard was able to accomplish this task. So I thought LiveCode can do the same.
Interesting. HypeCard was EOL'd by its manufacturer years before PDF became an open standard. It would be interesting to learn how HyperCard might have been able to solve this.
I am supposed to use the on-rev server with LiveCode 6.5 .
That's a fairly old version. Why are you unable to use a more recent one?

Re: Set PDF metadata using Livecode

Posted: Mon Jun 27, 2016 9:37 am
by PaoloMazza
Hi Richard,
I was told Hypercard was able to change metadata of all documents in MAC OS. It was not like that?

PaoloMazza wrote: That's a fairly old version. Why are you unable to use a more recent one?
I use the on-rev server which at the moment runs version 6.5 of LiveCode server.
I thought that's because they consider it the most stable version of LC server.
Can I ask them to update the version of LiveCode in their server?
Best regards,

Paolo Mazza

Re: Set PDF metadata using Livecode

Posted: Fri Jul 08, 2016 3:42 pm
by MaxV
PDF metadata is complicate, because there are several mechanisms available within PDF files to add metadata:
  • The Info Dictionary has been included in PDF since version 1.0. It contains a set of document info entries, simple pairs of data that consist of a key and a matching value. Some of these are predefined, such as Title, Author, Subject, Keywords, Created (the creation date), Modified (the latest modification date) and Application (the originating application or library). Applications can add their own sets of data to the info dictionary. Probably this is standard livecode way.
  • XMP (Extensible Metadata Platform) is an Adobe technology for embedding metadata into files. It can be used with a wide variety of data files. With Acrobat 5 and PDF 1.4 (2001) this mechanism was also made available for PDF files. XMP is more powerful than the info dictionary, which is why it is used in a number of PDF-based metadata standards.
  • Additional ways of embedding metadata are the PieceInfo Dictionary (used by Illustrator and Photoshop for application specific data when you save a file as a PDF), Object Data (or User Properties) and Measurement Properties.
You want to modify XMP, so use pdftools:

Code: Select all

put shell("pdftools.exe -r -i C:\test.pdf ) into oldXMP
edit it, then

Code: Select all

put newXMP into URL "C:\metadata.xmp"
put shell("pdftools.exe -i C:\test.pdf -o C:\out.pdf -e " & quote & "C:\metadata.xmp" & quote)