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ářů
Ahoj Přátelé!
Jaká je role erotiky a sexu ve vašem životě?
Ať už čtete literaturu a články nebo studujete vše v praxi, je důležité porozumět a
podporovat, protože sex a erotika je jedním ze základních životních směrů.
Sám jsem o tom začal přemýšlet a našel jsem zajímavý projekt, je tu spousta věcí, které si můžete přečíst, žádná vulgárnost nebo porno,
vše v rámci populizace sexu a erotiky jako umění!
Zde je tento projekt - https://www.eroticanus.ru
Přeji vám všem hodně štěstí, Omlouvám se, pokud vás toto téma nezajímá)
Gas Slot
(Tracyken, 24. 12. 2022 3:50)
GAS SLOT Adalah, situs judi slot online terpercaya no.1 di Indonesia saat ini yang menawarkan beragam pilihan permainan slot online yang tentunya dapat kalian mainkan serta menangkan dengan mudah setiap hari. Sebagai agen judi slot resmi, kami merupakan bagian dari server slot777 yang sudah terkenal sebagai provider terbaik yang mudah memberikan hadiah jackpot maxwin kemenangan besar di Indonesia saat ini. GAS SLOT sudah menjadi pilihan yang tepat untuk Anda yang memang sedang kebingungan mencari situs judi slot yang terbukti membayar setiap kemenangan dari membernya. Dengan segudang permainan judi slot 777 online yang lengkap dan banyak pilihan slot dengan lisensi resmi inilah yang menjadikan kami sebagai agen judi slot terpercaya dan dapat kalian andalkan
Pills news sheet. Generic Name. sksonlq
(FaBeike, 23. 12. 2022 23:25)Your testosterone level off is at its highest in the morning after you wake up. It is highest in a second after waking up from the quick sensitivity position (REM) nod off stage. The spreading in this hormone unescorted may be ample supply to cause an erection, even in the dearth of any physical stimulation. https://sibluevi.com/ viagra for women 2013
TilsPlosyIcojemiwele
(VernonDon, 22. 12. 2022 9:54)
https://telegra.ph/Aunt-Christina-Has-Arrived-11-27
Many thanks! I like it! oraoibd
(Postore, 21. 12. 2022 20:05)
Pills information leaflet. What side effects?
https://paxilcr.top/ long term effects of paxil
Best trends of drugs. Wangle dirt here.
Pills intelligence leaflet. Brand names. vhbgqca
(Faerate, 20. 12. 2022 23:45)Can you get rid of a bacterial infection without antibiotics such as https://flagylpls.com/ flagyl 250 mg tablets for dogs
TilsPlosyIcojemiwele
(VernonDon, 20. 12. 2022 21:12)
https://telegra.ph/Ashly-Anderson-Porn-03-29
nba중계
(Jamesclach, 19. 12. 2022 6:53)
프리미엄 스포츠중계 PICKTV(픽티비)는 회원가입없이 무료스포츠중계,월드컵중계,무료TV시청이 무료로 가능합니다
nba중계
(Jamesclach, 18. 12. 2022 18:53)
프리미엄 스포츠중계 PICKTV(픽티비)는 회원가입없이 무료스포츠중계,월드컵중계,무료TV시청이 무료로 가능합니다
TilsPlosyIcojemiwele
(VernonDon, 17. 12. 2022 13:29)
https://telegra.ph/Julie-Candy18-Colombiana-12-12
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
Jak často čtete články o erotice a sexu?
(Mashasnurf, 24. 12. 2022 7:39)