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'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
parfym gift set billigt aperca.se
(aperca.se, 17. 10. 2020 5:45)
My spouse and I stumbled over here by a different page and thought I might as well check things out. I like what I see so now i'm following you. Look forward to going over your web page again. inun.aperca.se/map4.php parfym gift set billigt
oratrg.se
(oratrg.se, 16. 10. 2020 3:54)
What's up, this weekend is nice designed for me, as this occasion i am reading this impressive informative article here at my house. oratrg.se/map29.php tova helgesson flashback
cross fit Гёvelser munhea.se
(munhea.se, 15. 10. 2020 13:38)
I couldn't resist commenting. Exceptionally well written! loqua.munhea.se/map4.php cross fit Гёvelser
vad är giftigt för katter aperca.se
(aperca.se, 15. 10. 2020 11:56)
Very good post! We are linking to this great post on our website. Keep up the great writing. suspi.aperca.se/map3.php vad är giftigt för katter
Подкупать или арендовать туалетные кабины
(Michaelgat, 14. 10. 2020 15:04)
Немедленно современные удобства и удобство имеют все шансы
быть доступны везде: для даче, строительной площадке, для
торжественном событии под не закрытымоткрытым небом, –
дословно в всяком пространстве сообразно Вашему желанию.
https://ecogr.ru/service/
sasilu.se
(sasilu.se, 14. 10. 2020 0:58)
Amazing! Its actually remarkable article, I have got much clear idea regarding from this piece of writing. sasilu.se/map21.php painful hard skin on feet
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 | 50 | 51 | 52 | 53 | 54 | 55 | 56 | 57 | 58 | 59 | 60 | 61 | 62 | 63 | 64 | 65 | 66 | 67 | 68 | 69 | 70 | 71 | 72 | 73 | 74 | 75 | 76 | 77 | 78 | 79 | 80 | 81 | 82 | 83 | 84 | 85 | 86 | 87 | 88 | 89 | 90 | 91 | 92 | 93 | 94 | 95 | 96 | 97
graviditetstest visar negativt munhea.se
(munhea.se, 25. 10. 2020 8:02)