New Forum | Previous | Next | (P-PDF) Developers
Topic: How to create thumbnails (JPG?) from PDF in VB
Conf: (P-PDF) Developers, Msg: 36095
Date: 3/6/2002 01:29 PM
I am new to PDF's, so please be gentle. I am developing in VB 6, I have Acrobat 5.0 and I have downloaded the SDK only to find out that it is not exactly Microsoft-friendly.
I need to create small thumbnails - supposedly in JPEG format, although it is not written in stone - of the first page of color, text and graphics PDF files, as they come into a folder. In my ideal COM-based world, it would look something like this:
set objPDDoc = CreateObject("AcroExch.PDDoc")
PDDoc.SaveAs FileType:="jpg", FileName:=Replace(strPath,"pdf","jpg"), Page:=1, Width:=100, Height:=75, Quality:=1, Resolution:=96...
Now the harsh reality is setting in. First of all, it almost looks like I have to understand PDF format. Layers. There is PDDoc, AVDoc and all other layer-specific objects. Which one of them may have the methods I am looking for?
Second, SDK documentation seems to concentrates on Java API, and even in the chapter dedicated to VisualBasic programming, it refers to JSObject as the COM-java bridge. Yet, there is a set of COM components that came with Acrobat, most notably acrobat.tlb, but I can't find the documentation for the object model implemented in them.
Third, many of the earlier replies to questions similar to mine have words "this is a very hard task", "you need a third party product", "well, Acrobat SDK can do it, but that, of course, is out". Why? Why is it out? If you open a PDF file natively and click Save As..., you get "Save as type: JPEG", and it even has some parameters -- not a whole lot, though. For starters, I would like to replicate this functionality through my VB app, JSObject or no JSObject: open a file, save it as JPEG while setting compression, format (somebody please explain those to me), colorspace and resolution. This is what the app allows interactively and this is what I want to learn to do. It will not get the job done, but it would show me the ropes.
What I will need to do next is:
- set size for my thumbnail;
- make sure only the first page gets rendered; when I do it from the app, all pages get rendered as numbered JPEG files, that is bad for me;
- plus, I need to figure out why the resulting JPEGs look so crappy; I know, you have said that JPEG is not a text format, but first, I tried TIFF and it looks just as crappy, and second, I don't mind blurriness if it only left the colors alone. As it is, black text looks anything but black.
Anyway, if you tell me that I cannot accomplish what I set out to do using just the SDK, I will buy it. But I want to hear it from you. And I want to hear how Acrobat.exe does it. If that's a plug-in, can I use it, too?
And if you tell me that I cannot (or should not) program the PDF->JPEG process, then I am sure there is a ready-made tool for it. Please recommend one that is
- COM-based (I will need to wrap it in my app which will search for PDF's, convert them and store JPEGs in a database);
- simple (read: cheap); there is very little I need to do (I think), and I don't want to pay for all the bells and whistles; I don't know what PDF tools go for these days, but I consider $50-$70 a fair deal.
Hope I made sense here. Please address as many of my questions as you can and be mindful of the fact that I am under a deadline.
Thanks in advance. I find your forum extremely useful and your posts very insightful. I apologize if my question has been answered already, and I failed to find it.