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ářů
interesting news
best cardholder video her
(Walterowedo, 23. 3. 2023 2:09)best cardholder video here https://www.youtube.com/watch?v=_6SbaPRllxM
best cardholder video her
(Walterowedo, 23. 3. 2023 0:23)best cardholder video here https://www.youtube.com/watch?v=wNXH0FoPGqg
best cardholder video her
(Walterowedo, 22. 3. 2023 14:37)best cardholder video here https://www.youtube.com/watch?v=_6SbaPRllxM
best cardholder video her
(Walterowedo, 22. 3. 2023 12:25)best cardholder video here https://www.youtube.com/watch?v=wNXH0FoPGqg
best cardholder video her
(Walterowedo, 22. 3. 2023 4:06)best cardholder video here https://www.youtube.com/watch?v=_6SbaPRllxM
Cool, I've been looking for this one for a long time
(Qazzyusant, 21. 3. 2023 20:12)interesting post
https://telegra.ph/Live-poker-birmingham-01-08#Live poker birmingham
(Geraldstarm, 21. 3. 2023 2:28)
https://telegra.ph/Live-roulette-strategy-to-win-01-08#Live roulette strategy to win
https://telegra.ph/Spin-to-win-live-roulette-01-08#Spin to win live roulette
https://telegra.ph/Free-live-roulette-no-deposit-01-08#Free live roulette no deposit
https://telegra.ph/Online-casinos-5-minimum-deposit-01-08#Online casinos $5 minimum deposit
https://telegra.ph/Juegos-de-casinos-online-01-08#Juegos de casinos online
Beautiful Naked Russian Model 18+
(PavelClied, 21. 3. 2023 1:57)
https://www.youtube.com/@FobosPlanet
Naked Sexy young girl dances on a sandy beach without clothes
https://www.youtube.com/@FobosPlanet
?? SEE FULL 4K VIDEO ON CHANNEL?? Fantasy and Dream About Lady Swimming Underwater?? Two Lesbians Woman
wbc 賽程
(MichaelwalrY, 18. 3. 2023 8:14)
2023年第五屆世界棒球經典賽即將拉開帷幕!台灣隊被分在A組,小組賽定於2023年3月8日至3月15日進行,淘汰賽時間為3月15日至3月20日,冠軍賽將在3月21日舉行。比賽將由各組前兩名晉級8強複賽,你準備好一起看世界棒球經典賽了嗎?更多詳情請參考富遊的信息!
以下是比賽的詳細賽程安排:
分組賽
A組:台灣台中市,2023年3月8日至3月12日,洲際球場
B組:日本東京都,2023年3月9日至3月13日,東京巨蛋
C組:美國亞利桑那州鳳凰城,2023年3月11日至3月15日,大通銀行球場
D組:美國佛羅里達州邁阿密,2023年3月11日至3月15日,馬林魚球場
淘汰賽
八強賽(Game 1、2):日本東京都,2023年3月15日至3月16日,東京巨蛋
八強賽(Game 3、4):美國佛羅里達州邁阿密,2023年3月17日至3月18日,馬林魚球場
四強賽(半決賽):美國佛羅里達州邁阿密,2023年3月19日至3月20日,馬林魚球場
冠軍賽(決賽):美國佛羅里達州邁阿密,2023年3月21日,馬林魚球場
你可以參考以上賽程安排,計劃觀看世界棒球經典賽
Exam, condign a inquest
(JamesElult, 18. 3. 2023 6:32)
Hello.
Thanks be given to you in behalf of that
hbunel.com
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
Thanks, I've been looking for this for a long time
(TobiasAnemy, 23. 3. 2023 18:28)