JXA error with PDFDocument

122 views Asked by At

I'm rewriting some python scripts into JXA, but having some difficulties. Here's the code:

ObjC.import('Quartz')
var pdfURL = $.NSURL.fileURLWithPath(filename)
var pdfDoc = $.PDFDocument.alloc.initWithURL(pdfURL)
var numberPages = pdfDoc.pageCount

This works, giving me the page count, but then it flags an error:

Error: exception raised by object: -[__NSArrayM length]: unrecognized selector sent to instance 0x7fafe7cbd610 (-2700)

The working python code is:

    import Quartz
    pdfURL = NSURL.fileURLWithPath_(filename)
    pdfDoc = PDFDocument.alloc().initWithURL_(pdfURL)
    numberPages = pdfDoc.pageCount()
0

There are 0 answers