Code: Select all
ImportC ""
CFRelease(CFTypeRef.L)
CFStringCreateWithCString(CFAllocatorRef.L, CString, CFStringEncoding.L)
CFURLCreateWithFileSystemPath(CFAllocatorRef.L, FilePath.L, PathStyle.L, IsDirectory.L)
CGPDFDocumentCreateWithURL(CFURLRef.L)
CGPDFDocumentGetNumberOfPages(PDFDocumentRef.L)
CGPDFDocumentRelease(PDFDocumentRef.L)
EndImport
#kCFAllocatorDefault = 0
#kCFURLPOSIXPathStyle = 0
#kCFStringEncodingMacRoman = 0
Procedure.L OpenPDFDocument(PathAndPDFName.S)
CFFilePath = CFStringCreateWithCString(#kCFAllocatorDefault, @PathAndPDFName, #kCFStringEncodingMacRoman)
If CFFilePath
CFURL = CFURLCreateWithFileSystemPath(#kCFAllocatorDefault, CFFilePath, #kCFURLPOSIXPathStyle, #False)
If CFURL
CFRelease(CFFilePath)
PDFDocumentRef = CGPDFDocumentCreateWithURL(CFURL)
CFRelease(CFURL)
ProcedureReturn PDFDocumentRef
EndIf
EndIf
ProcedureReturn 0
EndProcedure
Define Info.S
Define PathAndPDFName.S = "/Developer/About Xcode.pdf"
PDFDocumentRef = OpenPDFDocument(PathAndPDFName)
If PDFDocumentRef
Info = "The PDF document '"
Info + GetFilePart(PathAndPDFName)
Info + "' contains " + Str(CGPDFDocumentGetNumberOfPages(PDFDocumentRef))
Info + " pages."
MessageRequester("PDF-Info", Info)
CGPDFDocumentRelease(PDFDocumentRef)
EndIf