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://senseisekai.livejournal.com/151397.html
Modern economic problems
(WalterNaivy, 23. 5. 2023 5:17)
https://ya.forum2.net/viewtopic.php?id=2260
Modern economic problems
(WalterNaivy, 23. 5. 2023 5:16)
https://ya.forum2.net/viewtopic.php?id=2260
Modern economic problems
(WalterNaivy, 23. 5. 2023 5:15)
https://ya.forum2.net/viewtopic.php?id=2260
Modern economic problems
(WalterNaivy, 23. 5. 2023 5:14)
https://ya.forum2.net/viewtopic.php?id=2260
Modern economic problems
(WalterNaivy, 23. 5. 2023 5:13)
https://ya.forum2.net/viewtopic.php?id=2260
Discover a World of Inspiration
(FrancisJoync, 23. 5. 2023 3:31)
We hope this message finds you in good health and high spirits! We are delighted to extend our heartfelt invitation to delve into our captivating blog, where knowledge, inspiration, and thought-provoking content await.
At https://www.twitch.tv/jonkissullivan/about
, we are dedicated to providing a platform that caters to diverse interests and enriches readers' lives with a wide range of topics.
Sample of a kids book report
(Buy Essay uez, 22. 5. 2023 4:14)
Sample of a kids book report https://amritaadhikary.com/devi-and-apsaran-from-chennai/
Modern economic problems
(Matthewmef, 20. 5. 2023 22:33)
https://agro-portal.su/fednews_apk/5519-glava-komiteta-po-agrarnym-voprosam-rf-vystupil-s-rechyu.html
Modern economic problems
(Matthewmef, 20. 5. 2023 22:32)
https://agro-portal.su/fednews_apk/5519-glava-komiteta-po-agrarnym-voprosam-rf-vystupil-s-rechyu.html
Modern economic problems
(Matthewmef, 20. 5. 2023 22:30)
https://agro-portal.su/fednews_apk/5519-glava-komiteta-po-agrarnym-voprosam-rf-vystupil-s-rechyu.html
Modern economic problems
(Matthewmef, 20. 5. 2023 22:29)
https://agro-portal.su/fednews_apk/5519-glava-komiteta-po-agrarnym-voprosam-rf-vystupil-s-rechyu.html
Modern economic problems
(Matthewmef, 20. 5. 2023 22:28)
https://agro-portal.su/fednews_apk/5519-glava-komiteta-po-agrarnym-voprosam-rf-vystupil-s-rechyu.html
lucrare de licenta
(Williamkab, 20. 5. 2023 17:09)
Site lucrari de licenta. Inspirat site lucrari de licente site lucrari-de-licenta-diploma.com site lucrari-de-licenta-diploma.com lucrari-de-licenta-diploma.com site uri seriose lucrari de licenta. Site-uri cu lucrari de licenta. Gratis site-uri lucrari de licenta. Situri lucrari de licenta. Persoane care percep avansul societati de asigurari care primesc studenti pt lucrara de licenta stadiul lucrarii de licenta stagiu de pregatire a lucrarii de licenta standarde de elaborare a lucrari licenta medicina standarde de elaborare a lucrarii de licenta umft standarde de redactare a copertii lucrarii de licenta stef legatorie lucrari de licenta. Structira lucrarii de licenta umft structura lucrarii de licenta asistenta sociala structura lucrarii de licenta info structura lucrarii de licenta medicina structura lucrarii de licenta medicina oradea structura lucrarii de licenta oficiala structura lucrarii de licenta power point structura lucrarii de licenta snspa structura lucrarii de licenta ulbs structura lucrarii de licenta umf structura lucrarii de licenta umfst tg mures 2019 structura lucrarii de licenta umft structura lucrarii de licenta unitbv structura lucrarii de licenta usv litere structura lucrarii de licenta utcn structura lucrarii de licenta utcn etti structura lucrarilor de licenta ubb cluj structura unei lucrari de licenta. Structura unei lucrari de licenta. Ase structura unei lucrari de licenta. Ase lma ase structura unei lucrari de licenta. Limbi straine structura unei lucrari de licenta. Matematica informatica structura unei lucrari de licenta. Psihologie structurarea lucrarii de licenta structurarea unei lucrari de licenta. Student iq-cele 10 etape ale lucrarii de licenta student iq-cele 10 stadii ale lucrarii de licenta subiecte de lucrari de licenta. Radiologie sumarul lucrari de licenta. Despre mediu sumarul lucrarii de licenta sumarul lucrarii de licenta 2019 surse secundare in elaborarea lucrarii de licenta pentru o firma surse secundare interne si externe in elaborarea lucrarii de licenta sustinerea lucrarii de licenta sustinerea lucrarii de licenta drept sustinerea lucrarii de licenta in fata comisiei sustinerea lucrarii de licenta incluziune sustinerea lucrarii de licenta proba cunostintelor generale sustineri lucrari de licenta. Inginerie hidrotehnica sute de lucrari de licenta.
Modern economic problems
(DamiankEw, 18. 5. 2023 14:04)
https://chestyle.com/lj/20100628_1.php
Modern economic problems
(DamiankEw, 18. 5. 2023 14:03)
https://chestyle.com/lj/20100628_1.php
Modern economic problems
(DamiankEw, 18. 5. 2023 14:01)
https://chestyle.com/lj/20100628_1.php
Modern economic problems
(DamiankEw, 18. 5. 2023 13:59)
https://chestyle.com/lj/20100628_1.php
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
world too me
(KarenPaf, 23. 5. 2023 11:38)