Set PDF metadata using Livecode

LiveCode is the premier environment for creating multi-platform solutions for all major operating systems - Windows, Mac OS X, Linux, the Web, Server environments and Mobile platforms. Brand new to LiveCode? Welcome!

Moderators: Klaus, FourthWorld, heatherlaine, robinmiller, kevinmiller

Post Reply
PaoloMazza
Posts: 27
Joined: Wed Nov 15, 2006 11:27 am

Set PDF metadata using Livecode

Post by PaoloMazza » Fri Jun 24, 2016 11:02 am

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
Paolo Mazza
Italy

Klaus
Posts: 11497
Joined: Sat Apr 08, 2006 8:41 am
Location: Germany
Contact:

Re: Set PDF metadata using Livecode

Post by Klaus » Fri Jun 24, 2016 12:17 pm

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

FourthWorld
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 7314
Joined: Sat Apr 08, 2006 7:05 am
Location: Los Angeles
Contact:

Re: Set PDF metadata using Livecode

Post by FourthWorld » Fri Jun 24, 2016 3:12 pm

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.
Richard Gaskin
Community volunteer LiveCode Community Liaison

LiveCode development, training, and consulting services: Fourth World Systems: http://FourthWorld.com
LiveCode User Group on Facebook : http://FaceBook.com/groups/LiveCodeUsers/

Klaus
Posts: 11497
Joined: Sat Apr 08, 2006 8:41 am
Location: Germany
Contact:

Re: Set PDF metadata using Livecode

Post by Klaus » Fri Jun 24, 2016 3:25 pm

Ah, yes, completely forgot about that one! :oops:
However I had the impression that Paolo meant existing PDF documents!?

FourthWorld
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 7314
Joined: Sat Apr 08, 2006 7:05 am
Location: Los Angeles
Contact:

Re: Set PDF metadata using Livecode

Post by FourthWorld » Fri Jun 24, 2016 3:49 pm

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.
Richard Gaskin
Community volunteer LiveCode Community Liaison

LiveCode development, training, and consulting services: Fourth World Systems: http://FourthWorld.com
LiveCode User Group on Facebook : http://FaceBook.com/groups/LiveCodeUsers/

PaoloMazza
Posts: 27
Joined: Wed Nov 15, 2006 11:27 am

Re: Set PDF metadata using Livecode

Post by PaoloMazza » Fri Jun 24, 2016 4:24 pm

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
Paolo Mazza
Italy

PaoloMazza
Posts: 27
Joined: Wed Nov 15, 2006 11:27 am

Re: Set PDF metadata using Livecode

Post by PaoloMazza » Fri Jun 24, 2016 4:39 pm

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
Paolo Mazza
Italy

FourthWorld
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 7314
Joined: Sat Apr 08, 2006 7:05 am
Location: Los Angeles
Contact:

Re: Set PDF metadata using Livecode

Post by FourthWorld » Fri Jun 24, 2016 6:00 pm

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?
Richard Gaskin
Community volunteer LiveCode Community Liaison

LiveCode development, training, and consulting services: Fourth World Systems: http://FourthWorld.com
LiveCode User Group on Facebook : http://FaceBook.com/groups/LiveCodeUsers/

PaoloMazza
Posts: 27
Joined: Wed Nov 15, 2006 11:27 am

Re: Set PDF metadata using Livecode

Post by PaoloMazza » Mon Jun 27, 2016 9:37 am

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
Paolo Mazza
Italy

MaxV
Posts: 1575
Joined: Tue May 28, 2013 2:20 pm
Location: Italy
Contact:

Re: Set PDF metadata using Livecode

Post by MaxV » Fri Jul 08, 2016 3:42 pm

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)
Livecode Wiki: http://livecode.wikia.com
My blog: https://livecode-blogger.blogspot.com
To post code use this: http://tinyurl.com/ogp6d5w

Post Reply

Return to “Getting Started with LiveCode - Experienced Developers”