PDF thumbnails from VBA
I was asked to develop a form where user can see a pdf thumbnail of a pdf file. It was pretty far from what I have been developing so I decided to use "uncle" google to find a solution. There are some solutions but nothing what was expecting. You can use paid version of Adobe or free Adobe Acrobat ActiveX (Acropdf1) or some others free tools that can work along a pdf file. I tested only the free version of Acrobat ActiveX component and it was really nightmare. Then I found a C# project using the GhostScript tool for creating a pdf thumbnail. Unfortunatelly VBA cannot work with this project directly. Read more to find solution.
As I mentioned you can use the Acropdf1 activeX which is automatically installed with the Adobe Reader application.
How to add the Acropdf1 activeX on a VBA form
At the first time the activeX seemed to be a good solution but then I found two "bugs". The first one is more important than the second one. The activeX takes focus and never give it back and if you press the "TAB" key, then the whole application will crash. It's very known bug but Adobe cannot fix it for some reason. And the second bug rather behavior - of the activeX control is uncomfortable - it always takes focus and never give it back and also you don't have option to find out if a pdf document is fully loaded or not. My client was complaining about that for many times so I decided to find another solution.
I found code from Matthew Ephraim. where he uses a free tool Ghostscrip and .NETFramework 3.5 and C#. Form Visual Studio you can use his tool without any problems just include it into your project. Unfortunately we cannot use his dll directly from VBA. That was the reason why I took his code and made a little adjustment to expose methods from his project to the COM object.
Now - after registration the dll to your system - you can reference the dll as usually and use it !!! And it works great.
Who is interested how to create a C# dll that can work with VBA I attached the zip file with entire C# solution. Look at the Attachment section.
And who just want to use it as soon as possible, download the installer and install it. I also prepare a sample and you can find everything in the Attachment section.
The installer just check if your system contains the .NETFramework 4 and if not, it will suggest to download it and then register the dlls into your system.
Your code can look like this one
and then you can take the output file as an ordinary image file and load it - for example - to an image control.
Option Explicit
'********************************************************************************
'TestPDFThumbnailGeneration
'
' Purpose: It uses reference to GhostscriptWrapper library.
' From a pdf file creates a jpg file that represents a thumbnail of the pdf.
' You can set page number and DPI quality.
'
' Inputs: -none-
'
' Outputs: -none-
'
' Created: 02/10/2011 Premysl Lazecky
'
' Modified: .
'
'********************************************************************************
Sub TestPDFThumbnailGeneration()
Dim PDF As GhostscriptWrapper
Dim strPath As String
Dim strInputFile As String
strInputFile = "Test.pdf"
strPath = ActiveWorkbook.Path
If Right$(strPath, 1) <> Application.PathSeparator Then
strPath = strPath & Application.PathSeparator
End If
Set PDF = New GhostscriptWrapper
PDF.GeneratePDFThumb inputPath:=strPath & strInputFile, _
outputPath:=strPath & "Output.jpg", _
Page:=1, _
Width:=72, Height:=72
Set PDF = Nothing
End Sub
As the result of this code you will get a jpg file called Output.jpg with thumbnail of defined page in the pdf file - in this case page 1 - with defined resolution.
Attachments
Installer and sample files
C# project
Komentáře
Přehled komentářů
I was suggested this website by means of my cousin. I'm now not positive whether or not this put up is written through him as no one else recognize such designated about my problem. You are incredible! Thanks! spare.aperca.se/map3.php willys trelleborg jobb
squgarik.se
(squgarik.se, 28. 10. 2020 4:09)
This text is invaluable. Where can I find out more? squgarik.se/map2.php kur mot fГ¶rkylning
olja pГҐ apoteket munhea.se
(munhea.se, 26. 10. 2020 22:02)
Hi! This is my first visit to your blog! We are a collection of volunteers and starting a new project in a community in the same niche. Your blog provided us useful information to work on. You have done a marvellous job! gurgle.munhea.se/map13.php olja pГҐ apoteket
nike outlet sverige munhea.se
(munhea.se, 26. 10. 2020 19:22)
I have been browsing on-line greater than 3 hours lately, but I never discovered any fascinating article like yours. It's pretty price sufficient for me. In my opinion, if all site owners and bloggers made excellent content material as you did, the internet will likely be much more helpful than ever before. atrec.munhea.se/map10.php nike outlet sverige
sasilu.se
(sasilu.se, 26. 10. 2020 4:21)
Nice post. I used to be checking continuously this weblog and I am impressed! Extremely useful information specifically the closing part :) I deal with such info a lot. I used to be looking for this certain info for a long time. Thank you and good luck. sasilu.se/map10.php sluta med levaxin symptom
egluopu.se
(egluopu.se, 25. 10. 2020 8:50)
It's hard to come by experienced people about this topic, however, you seem like you know what you're talking about! Thanks egluopu.se/map1.php sarah sjöström längd
graviditetstest visar negativt munhea.se
(munhea.se, 25. 10. 2020 8:02)
I've been exploring for a bit for any high quality articles or blog posts on this kind of space . Exploring in Yahoo I eventually stumbled upon this website. Studying this info So i am glad to exhibit that I have an incredibly good uncanny feeling I found out exactly what I needed. I so much for sure will make certain to don?t put out of your mind this web site and give it a look on a constant basis. neti.munhea.se/map1.php graviditetstest visar negativt
michael kors jacka dam munhea.se
(munhea.se, 23. 10. 2020 11:22)
Great goods from you, man. I have remember your stuff prior to and you're just extremely excellent. I really like what you've got here, certainly like what you are saying and the best way through which you say it. You're making it entertaining and you continue to take care of to stay it smart. I can't wait to learn far more from you. This is actually a great web site. sgemr.munhea.se/map14.php michael kors jacka dam
azilopar.se
(azilopar.se, 22. 10. 2020 18:34)
Thanks for the good writeup. It in fact was a amusement account it. Look complex to far introduced agreeable from you! By the way, how can we be in contact? azilopar.se/map23.php metagest med saltsyra
var ligger maldiverna aperca.se
(aperca.se, 22. 10. 2020 17:51)
Hey I am so excited I found your webpage, I really found you by error, while I was researching on Askjeeve for something else, Anyways I am here now and would just like to say many thanks for a remarkable post and a all round interesting blog (I also love the theme/design), I don't have time to go through it all at the minute but I have book-marked it and also included your RSS feeds, so when I have time I will be back to read more, Please do keep up the awesome job. break.aperca.se/map7.php var ligger maldiverna
bra kosttillskott vid deff munhea.se
(munhea.se, 22. 10. 2020 10:00)
No matter if some one searches for his vital thing, so he/she wants to be available that in detail, so that thing is maintained over here. hana.munhea.se/map9.php bra kosttillskott vid deff
panilul.se
(panilul.se, 21. 10. 2020 23:04)
I am not positive the place you're getting your info, but great topic. I must spend a while learning much more or working out more. Thank you for fantastic information I used to be on the lookout for this info for my mission. panilul.se/map1.php syd energi fiber
dehllap.se
(dehllap.se, 21. 10. 2020 3:22)
What a information of un-ambiguity and preserveness of valuable experience concerning unexpected emotions. dehllap.se/map15.php kopparspiral oregelbunden mens
Г¤ppelformad kropp diet aperca.se
(aperca.se, 20. 10. 2020 22:06)
I like reading an article that can make people think. Also, many thanks for allowing for me to comment! sollb.aperca.se/map9.php Г¤ppelformad kropp diet
slem i halsen allergi munhea.se
(munhea.se, 20. 10. 2020 16:34)
Hi, Neat post. There's a problem together with your web site in internet explorer, would check this? IE still is the marketplace chief and a large part of people will omit your magnificent writing because of this problem. nistm.munhea.se/map3.php slem i halsen allergi
otertbe.se
(otertbe.se, 20. 10. 2020 7:44)
Neat blog! Is your theme custom made or did you download it from somewhere? A design like yours with a few simple tweeks would really make my blog jump out. Please let me know where you got your design. Thanks otertbe.se/map29.php aspartic acid svenska
smala hГ¶ga badrumsskГҐp aperca.se
(aperca.se, 19. 10. 2020 0:23)
First off I would like to say wonderful blog! I had a quick question in which I'd like to ask if you don't mind. I was interested to find out how you center yourself and clear your mind before writing. I've had a difficult time clearing my mind in getting my ideas out. I do enjoy writing but it just seems like the first 10 to 15 minutes are lost simply just trying to figure out how to begin. Any recommendations or tips? Kudos! derse.aperca.se/map3.php smala hГ¶ga badrumsskГҐp
dry skin everywhere munhea.se
(munhea.se, 18. 10. 2020 23:37)
Appreciate the recommendation. Let me try it out. tuta.munhea.se/map4.php dry skin everywhere
persdap.se
(persdap.se, 18. 10. 2020 6:05)
I'm truly enjoying the design and layout of your blog. It's a very easy on the eyes which makes it much more pleasant for me to come here and visit more often. Did you hire out a developer to create your theme? Fantastic work! persdap.se/map14.php eget smГ¶r recept
godis grossist sverige munhea.se
(munhea.se, 17. 10. 2020 6:36)
Hi there! Would you mind if I share your blog with my zynga group? There's a lot of folks that I think would really enjoy your content. Please let me know. Cheers riedu.munhea.se/map7.php godis grossist sverige
1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49
willys trelleborg jobb aperca.se
(aperca.se, 28. 10. 2020 6:58)