[ANN] LCB Apple PDFKit Widget (pretty much obsolete now)

Find out what's going on with LiveCode (the company), product releases, announcements, and events.

Moderators: Klaus, FourthWorld, heatherlaine, kevinmiller, robinmiller

Post Reply
PaulDaMacMan
Posts: 515
Joined: Wed Apr 24, 2013 4:53 pm
Contact:

[ANN] LCB Apple PDFKit Widget (pretty much obsolete now)

Post by PaulDaMacMan » Sat Sep 11, 2021 9:57 am

LCB wrapper for Apple's PDFKit but I'm a bit worried that I may be stepping on their toes since they include their own XPDF extension with their paid versions. I just needed to do some simple processing of a bunch of PDFs and wound up creating another LCB Library and Widget. It's a become a fairly complete wrapper and came together quickly, but I don't want to hurt their business either because as much as I'm complaining here, I do love their product and want them to do well as a business, and they all seem like very nice people too.
This was from an PM exchange I had last month while trying to help someone with LCB & FFI for JAVA / Android

Since OpenSource LC Community Edition is no longer supported by LC Ltd, and it looks like LC 9.6.4 contains a cross platform widget wrapper for Google's PDFium library, that is now a rather moot point, perhaps even a complete waste of time.
Screen Shot 2021-09-11 at 5.24.24 AM.png
Screen Shot 2021-09-11 at 5.24.24 AM.png (48.8 KiB) Viewed 510 times

So here is my incomplete LCB wrapper/widget for Apple's PDFKit for anyone still using LC Community Edition, tested with LCC 9.6.3 on macOS 10.14.6 & 10.15.7 (It might work on iOS too with some adjustments, I don't know ). I assume it will work with LC Commercial Editions as well although I don't know why you would want to.
https://github.com/PaulMcClernan/LCB_ApplePDFKit
Screen Shot 2021-09-11 at 5.27.42 AM.png

If anyone is suddenly very interested in learning FFI + Objective C, this contains an example of using NSNotificationCenter in LCB.
There's two versions: the original LCB Library only ( that can create it's own viewing NSWindow) and a second version that's an Apple native PDFView in LC widget form that can be placed on your stacks. Theres some other functions like extracting text, page count etc.
I added the PDFviews because I wanted to see the PDFs I was extracting text from but the Browser Widget is tied to WebKit PDF plugin which apparently isn't fully compatible with Adobe's Acrobat WebPlug (which I need to have for my day job)
Browser Widget PDF Fail.png
Last edited by PaulDaMacMan on Sat Sep 11, 2021 4:54 pm, edited 1 time in total.
My LCB Repos: https://github.com/PaulMcClernan/
My LiveCode YouTube Videos: PlayList

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

Re: [ANN] LCB Apple PDFKit Widget (pretty much obsolete now)

Post by Klaus » Sat Sep 11, 2021 11:57 am

Hi Paul,
... and it looks like LC 9.6.4 contains a cross platform widget wrapper for Google's PDFium library, that is now a rather moot point,
FYI:
The PDF widget is only contained in the costly "PRO feature pack" for LC!


Best

Klaus

stam
Posts: 703
Joined: Sun Jun 04, 2006 9:39 pm
Location: London, UK

Re: [ANN] LCB Apple PDFKit Widget (pretty much obsolete now)

Post by stam » Sat Sep 11, 2021 12:26 pm

That's really great, thank you for sharing Paul.

The only issue is that it's not cross platform.
Any chance you can incorporate FOSS solutions like XPDFReader command line tool?

I used this and posted instructions on how this can be used from LC here: viewtopic.php?f=8&t=35280&hilit=pdf&start=30#p201036

Not sure if this can be wrapped in a nice external somehow? Or maybe that's not desirable/feasible...
Stam

PaulDaMacMan
Posts: 515
Joined: Wed Apr 24, 2013 4:53 pm
Contact:

Re: [ANN] LCB Apple PDFKit Widget (pretty much obsolete now)

Post by PaulDaMacMan » Sat Sep 11, 2021 4:33 pm

stam wrote:
Sat Sep 11, 2021 12:26 pm
That's really great, thank you for sharing Paul.

The only issue is that it's not cross platform.
Any chance you can incorporate FOSS solutions like XPDFReader command line tool?

I used this and posted instructions on how this can be used from LC here: viewtopic.php?f=8&t=35280&hilit=pdf&start=30#p201036

Not sure if this can be wrapped in a nice external somehow? Or maybe that's not desirable/feasible...
Stam
To be honest this was more of an "accidental" development, it just came together very quickly when I started to look at Apple's PDF Kit which is a fairly "high level" API that I was able to easily tap into with LCB. I accomplished what I needed to almost immediately, and the rest (viewing in a window & making the native widget) was more of an exercise then anything else.

Since Adobe made PDF an open format at some point, there's plenty of free open source, tools for dealing with them including XPDF, and the very nice, made for LC, Quartam PDF library (which I had been unaware had gone open source until just the other day).
If you or anyone else would like to take a crack what you're talking about that I'd be happy to help if I can, but I have more pressing concerns right now. I'm currently looking to remove anything that's not fully GPL3 compatible.

I would suggest going with a System level API on platforms like Windows or Android if possible because there's no additional libraries needed and you can rely on those being around for very long time. If you're on Linux "system level" could mean anything depending on the distro. I'm not currently a big Linux user (but I could see that changing in the future).
My LCB Repos: https://github.com/PaulMcClernan/
My LiveCode YouTube Videos: PlayList

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

Re: [ANN] LCB Apple PDFKit Widget (pretty much obsolete now)

Post by Klaus » Sat Sep 11, 2021 6:31 pm

Hi Paul,

just tested you Apple PDF widget, cool, thanks a lot! :-)


Best

Klaus

PaulDaMacMan
Posts: 515
Joined: Wed Apr 24, 2013 4:53 pm
Contact:

Re: [ANN] LCB Apple PDFKit Widget (pretty much obsolete now)

Post by PaulDaMacMan » Sun Sep 12, 2021 2:37 am

Klaus wrote:
Sat Sep 11, 2021 6:31 pm
Hi Paul,

just tested you Apple PDF widget, cool, thanks a lot! :-)


Best

Klaus
You're welcome! But again It's somewhat incomplete, it posts all PDFView AND inherited NSView notifications to the script engine, some of those are redundant or useless messages. If anyone wants to work on it, that's cool with me. I'm happy to help with LCB questions if I can.

Also, as a graphics-for-print pre-press type guy, I'd like to point out that Apple's PDF rendering engine is garbage for high-end graphics use (can't handle very high-resolution images well, can't render overprinting inks properly, etc.), although even Adobe has some flaws in that area (still no support for opaque inks) which is quite frustrating when clients want to look at PDF "proofs" on their iPhones (but you know "the customer is always right" so...). It is what it is.
My LCB Repos: https://github.com/PaulMcClernan/
My LiveCode YouTube Videos: PlayList

Post Reply

Return to “Announcements”