Convert PDF to Image Using VBA Macro

Hi

I have pdf file which i need to convert to ImageFormat [ PNG or GIF ] using Word VBA Macro

please provide the solution either through VBA or VB or .net framework

thanks

 


Orcas
 

Question Info


Last updated December 4, 2019 Views 7,438 Applies to:

Is it absolutely required to do this in Word? It would be much easier to use a program that's actually designed to do this. Try Snagit (www.techsmith.com) -- there's a free trial version you can download.


Jay Freedman
MS Word MVP  FAQ: http://word.mvps.org
_____________________________
https://jay-freedman.info

Did this solve your problem?

Sorry this didn't help.

Great! Thanks for marking this as the answer.

How satisfied are you with this reply?

Thanks for your feedback, it helps us improve the site.

How satisfied are you with this response?

Thanks for your feedback.

Word has no native ability to open or process PDF files.


Graham Mayor - Word MVP
www.gmayor.com
Posted via the Communities Bridge
http://communitybridge.codeplex.com/
Graham Mayor (Microsoft Word MVP 2002-2019)
For more Word tips and downloads visit my web site
https://www.gmayor.com/Word_pages.htm

Did this solve your problem?

Sorry this didn't help.

Great! Thanks for marking this as the answer.

How satisfied are you with this reply?

Thanks for your feedback, it helps us improve the site.

How satisfied are you with this response?

Thanks for your feedback.

I think PDF to Image Converter can help you solve this program, you can have a try, windows supported. http://www.oxpdf.com/pdf-to-image-converter.html

2 people were helped by this reply

·

Did this solve your problem?

Sorry this didn't help.

Great! Thanks for marking this as the answer.

How satisfied are you with this reply?

Thanks for your feedback, it helps us improve the site.

How satisfied are you with this response?

Thanks for your feedback.

Depending on the quality of image you need and on whether a conversion of just the first page will do it for you, you could automate PowerPoint instead.

Set the PPT slide size to proportions that match the PDF
Insert the PDF as an object
Position it to 0,0 and set it to the slide's height and width
Save the slide as a PNG or GIF

Simple example, automated from within PPT
You could modify the code to automate PPT from other apps

Sub SavePDFAsPng(sPathToPDF As String, sPathToPNG As String)

    Dim oPres As Presentation
    Dim oSh As Shape
    
    ' Height/Width are hardcoded here
    ' You could get trickier and bring the PDF into any presentation
    ' once to get its proportions, delete it, set the slide size to the same
    ' proportions, then re-insert the PDF
    Dim sngWidth As Single
    Dim sngHeight As Single
    sngWidth = 612
    sngHeight = 792
    
    Set oPres = Presentations.Add
    With oPres
        With .PageSetup ' set it to 8.5x11
            .SlideHeight = sngHeight  ' 11in * 72 points per inch
            .SlideWidth = sngWidth
        End With
        .Slides.AddSlide 1, .SlideMaster.CustomLayouts(1)
        With .Slides(1)
            Set oSh = .Shapes.AddOLEObject(0, 0, sngWidth, sngHeight, , sPathToPDF)
            Call .Export(sPathToPNG, "PNG")
        End With
        .Saved = True
        .Close
        
    End With
    
    
End Sub

Sub TestSavePDFAsPng()

 Call SavePDFAsPng("C:\Temp\MyTest.pdf", "C:\Temp\MyTest.PNG")
End Sub

PowerPoint Help:
http://www.pptfaq.com/
PPTools:
http://www.pptools.com

3 people were helped by this reply

·

Did this solve your problem?

Sorry this didn't help.

Great! Thanks for marking this as the answer.

How satisfied are you with this reply?

Thanks for your feedback, it helps us improve the site.

How satisfied are you with this response?

Thanks for your feedback.