Re: Maybe OT: getting general information of a pdf file
Re: Maybe OT: getting general information of a pdf file
- Subject: Re: Maybe OT: getting general information of a pdf file
- From: demski <email@hidden>
- Date: Mon, 24 Oct 2005 17:38:08 +0200
Am 12.10.2005 um 01:22 schrieb has:
demski wrote:
is there maybe anybody out there knowing of how to get the general
information (esp. page size (maybe even the different 'boxes'),
count of pages) out of a pdf-file without opening it with preview
or even Acrobat?
Take it you mean you don't want to open 'em in a GUI app. Can't
suggest any CLI tools offhand: 'apropos pdf' doesn't turn up
anything interesting, and 'pdf' isn't exactly the most productive
term to Google for. Maybe someone else knows of something along
those lines. Otherwise it sounds like you want to use Core
Services. Unless you like C programming, the easiest way to do that
would be to write a Python script that uses Apple's Core Services-
to-Python bridge:
<http://developer.apple.com/documentation/GraphicsImaging/
Conceptual/drawingwithquartz2d/dq_python/chapter_17_section_1.html>
That's it
Just if it is of any interest to anybody, here my python-script,
which will then called via do shell script:
#!/usr/bin python
import sys
from CoreGraphics import *
def InSpect(pdfPath):
"width, height, Pages from a pdf-file."
pdf = CGPDFDocumentCreateWithProvider
(CGDataProviderCreateWithFilename (pdfPath))
s = pdf.getNumberOfPages()
g = pdf.getCropBox (1)
b = g.size.width
h = g.size.height
print int(s),int(b),int(h)
if __name__ == '__main__':
InSpect (sys.argv[1])
For I just started to hack python, there might be unelegant things in
it.
If ther's anybody having hints to improve, I would be glad!
greetz demski
(You'll need some patience to make sense of /Developer/Examples/
Quartz/Python/API-SUMMARY, unfortunately, as its format is rather
primitive.)
You could then run that script from AS using 'do shell script',
passing it a path to the PDF file in question and having it return
an tab/return-delimited string containing all the extracted data in
easy-to-digest form.
HTH
has
--
http://freespace.virgin.net/hamish.sanderson/
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Applescript-users mailing list (Applescript-
email@hidden)
Help/Unsubscribe/Update your Subscription:
40unter-anderem.com
This email sent to email@hidden
gruss, demski
Die Anderen · digitale mediendienstleistungen
Bellealliancestraße 58 b · 20259 Hamburg
fon: 040 41 26 61 81
fax: 040 41 26 61 83
email@hidden
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Applescript-users mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden