0
votes

I am developing a application where user has the facility to share MS-Office files. Under Windows I use the Word Automation objects and a virtual printer to create .BMP files from the .doc and the .ppt's which I then read/display and send it on a network.

Now, I am porting my application on MAC.

On MAC I am really not sure as to how to achieve this stuff. I searched and found a way to get the bitmap representation of files under MAC through the user of QuickLook API. I also found some posts here related to QuickLook.

Get QuickLook preview image for file

Mac Quick Look Preview in an NSView or NSImage?

But here we are stuck with QLThumbnailImageCreate as it gives only a single thumbnail image for the document (1st page of .doc and .ppt). So this would not be of any use for me.

I researched a bit more and found a command qlmanage that with its option of -p will generate the actual PREVIEW of the document not only the thumbnail. But now it only saves the images inside pages as .png files and does nothing with the text. It gives a single Preview.html file though along with PreviewProperties.plist that has information about the attachments.

The same qlmange command does something weird for PowerPoint files. It saves the template of slide as .pdf file( and the embedded images as .png).

Does there exists some way in code through which I can request the MS-Office QuickLook generator (office.qlgenerator) to give me a preview objects and then using that preview object I convert the pages into bitmaps ?

Finder / Spotlight seems to figure the preview perfectly I wonder how are these applications are able to do it ? Does Apple hide this functionality from developers ???

Can anyone having QuickLook expertise guide me through this, or show me some other way possible, with or without QuickLook because as of now I think I am really stuck here.

In simple terms I just want the raw image representations of pages/slides.

Any help in this regard would be highly appreciated.

Thanks & Regards, LazyCoder7

1
I did somehow solve a part of my question that is to print .pdf files. As pdf support is native to MAC OS. I generated .jpg images from .pdf files, now I am thinking of somehow converting .doc, .ppt to .pdf and then using this technique convert .pdf to .jpg. Let's see how far I go.LazyCoder7
I found a sample script here jaimerios.com/?p=171, but it has its own set of problems. Accessibility options needs to be turned ON on MAC. Mine was turned OFF, this might cause problems on other machines too. Moreover, script did not complete successfully. Halted at the point where it needs to enter Command+Shift+G to get the file path. Need to figure out other way round.LazyCoder7
I figured a way out as to how to convert .doc and .ppt to .pdf under MAC. stackoverflow.com/questions/11192396/….LazyCoder7

1 Answers

0
votes

Answering my own question for someone having the same situation as mine.

We would require a two step process here.

1.Any Document -> .PDF.

For this part you may use the information provided at Programming a Filter/Backend to 'Print to PDF' with CUPS from any Mac OS X application. It's very good explained, you can also check out this link https://bitbucket.org/codepoet/cups-pdf-for-mac-os-x/wiki/Home.

Once you understand and experiment with CUPS you will be able to generate .PDF files from .doc or say a .ppt.

Now begins the second part of the solution.

2.Convert .PDF to .JPG.

For this part you can use the code at Convert PDF pages to images with COCOA.

The code works good and gives the desired results.

So now basically we can convert any MS Office files to images and that too page wise without going the QuickLook way (which will not work in this case though).

Hope, this might help someone.

Regards,

CrazyCoder7.