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ářů
ფუნდამენტალური ანალიზის ფორექსის წიგნი. https://ge.forex-is.com
Forex robotics
(Forexvoma, 10. 12. 2020 22:12)Pobieranie wskaźnika Forex. https://pl.forex-is.com
រាំស្វា ភ្លេងសុទ្ធ
(cambodiamussuc, 10. 12. 2020 9:09)
តន់ ចន្ទសីម៉ា ភ្លេងសុទ្ធ
ខារា៉អូខេ ភ្លេងសុទ្ធ
កូនប្រសារស្រុកស្រែ
និពន្ធ Melody និងទំនុកច្រៀង សេង តារា
និពន្ធបទភ្លេង ទីណូ
សម្រួលឡើងវិញ សាក់
https://www.youtube.com/watch?v=vtChbT6QpCg
https://www.youtube.com/channel/UCcC55uu4uBpgxGkyUsozQ5A
How to disable pm?
(belleDriex, 9. 12. 2020 7:36)Hello i am new user and i would to ask you, How to disable a pm?
Always very favorable prices for servicesmassage happy ending in NY
(MatthewMiz, 7. 12. 2020 18:52)
<b></b>
Pnademic info expert
(MixClots, 3. 12. 2020 23:56)
I am expert of pandemic, and i can help you.
PS: How are you? I am from France :)/ mixx
Dating and sex without obligation in your city
(Gabrielevorm, 30. 11. 2020 4:34)
https://bit.ly/2I3ZL7m - Dating and sex without obligation in your city
https://t.me/DatingFlirting
- Flirting in your city
@@@==
Hi! Only from 18+!
(SandraRip, 24. 11. 2020 17:49)Here loveawake.ru you are waiting for interesting Dating only for adults!
finnar runt munnen magen aperca.se
(aperca.se, 6. 11. 2020 8:52)
Hi there! I know this is kinda off topic but I'd figured I'd ask. Would you be interested in exchanging links or maybe guest authoring a blog post or vice-versa? My site addresses a lot of the same subjects as yours and I believe we could greatly benefit from each other. If you happen to be interested feel free to shoot me an email. I look forward to hearing from you! Fantastic blog by the way! huera.aperca.se/map3.php finnar runt munnen magen
dehllap.se boeuf bourgogne recept
(dehllap.se boeuf bourgogne recept, 5. 11. 2020 17:36)
I could not resist commenting. Perfectly written! boeuf bourgogne recept dehllap.se/map9.php
plantering av blommor munhea.se
(munhea.se, 5. 11. 2020 0:52)
It is not my first time to go to see this web page, i am visiting this web page dailly and get nice information from here every day. skywe.munhea.se/map8.php plantering av blommor
lanba.se surhetsgrad i kroppen
(lanba.se surhetsgrad i kroppen, 5. 11. 2020 0:23)
Definitely believe that which you stated. Your favorite justification appeared to be on the web the simplest thing to be aware of. I say to you, I definitely get annoyed while people think about worries that they just do not know about. You managed to hit the nail upon the top and defined out the whole thing without having side effect , people could take a signal. Will likely be back to get more. Thanks surhetsgrad i kroppen lanba.se/map24.php
medicin fГ¶r springmask aperca.se
(aperca.se, 4. 11. 2020 9:36)
Fine way of explaining, and fastidious article to take information about my presentation topic, which i am going to convey in university. huera.aperca.se/map1.php medicin fГ¶r springmask
halv ГҐtta hos mig recept 2016 munhea.se
(munhea.se, 3. 11. 2020 12:19)
Pretty! This has been an extremely wonderful article. Many thanks for providing these details. atrec.munhea.se/map7.php halv ГҐtta hos mig recept 2016
aloe vera shot aperca.se
(aperca.se, 2. 11. 2020 16:15)
This paragraph is genuinely a nice one it assists new net visitors, who are wishing in favor of blogging. prosd.aperca.se/map8.php aloe vera shot
baka brГ¶d maskin munhea.se
(munhea.se, 1. 11. 2020 23:40)
When I initially commented I seem to have clicked the -Notify me when new comments are added- checkbox and now whenever a comment is added I receive 4 emails with the exact same comment. Perhaps there is a way you are able to remove me from that service? Thank you! searn.munhea.se/map6.php baka brГ¶d maskin
otertbe.se
(otertbe.se, 1. 11. 2020 3:12)
Fantastic goods from you, man. I've keep in mind your stuff previous to and you are simply too great. I really like what you have received here, really like what you are saying and the way in which during which you say it. You're making it entertaining and you still take care of to keep it smart. I can not wait to learn much more from you. This is really a great website. otertbe.se/map16.php frisГ¶r ГҐgatan linkГ¶ping
orebro e skola aperca.se
(aperca.se, 31. 10. 2020 20:30)
I loved as much as you'll receive carried out right here. The sketch is attractive, your authored material stylish. nonetheless, you command get got an nervousness over that you wish be delivering the following. unwell unquestionably come more formerly again as exactly the same nearly very often inside case you shield this hike. reldo.aperca.se/map7.php orebro e skola
vad Г¤r hypertoni aperca.se
(aperca.se, 30. 10. 2020 2:06)
I'd like to thank you for the efforts you have put in writing this site. I'm hoping to see the same high-grade content by you later on as well. In fact, your creative writing abilities has inspired me to get my own, personal blog now ;) doodr.aperca.se/map1.php vad Г¤r hypertoni
benmmdi.se
(benmmdi.se, 30. 10. 2020 0:05)
I am not certain where you are getting your info, however great topic. I must spend some time learning much more or working out more. Thanks for magnificent info I was looking for this info for my mission. benmmdi.se/map5.php ingefära för magen
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
Forex trading software online
(Forexvoma, 21. 12. 2020 7:58)