Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Display PDF in Report

Tags:

vba

ms-access

I want to display dynamically .pdf files like pictures in a report, it should look like this:

enter image description here

i already tried with webbrowser, but then it doesn't show up in the preview or when i print the report out...

I also tried a ole unbound object, also no success, here the code i had in the Report_Load event:

Dim vPath As String

vPath = GetNewestDocument(Me!artNr)
'Returns path for pdf file, about:blank if there is no file.
If vPath = "about:blank" Then
        Me!PDFBrowser.visible = True
        Me.PDFBrowser.SourceDoc = vbNullString
Else
        With Me.PDFBrowser
        .OLETypeAllowed = acOLELinked
        .SourceDoc = vPath
        .SizeMode = acOLESizeStretch
        End With
End If

EDIT:

With "I want to display dynamically ..." i meant to change dynamically pdf's in the Report.

EDIT 2:

I just found out that the type of the OLEunbound object is embedded, but i think this one should be linked as i read in other Forums: enter image description here

When i try to Change it gives error: "This property can not be changed because it is read-only"

like image 560
Jul Pod Avatar asked Oct 17 '22 00:10

Jul Pod


1 Answers

You could get a licensed version of Adobe Acrobat (not Reader) and control it programmatically to capture the images you want.

Alternatively, you could use the VBA Shell Function to call a command-line PDF converter like 2Jpeg to programmatically (and dynamically if necessary) convert the PDF to an image (see this), or even "print" the PDF to an image file using the correct driver (see this).

Once you have an image file, you can easily load the created image to your Access form with VBA, perhaps with this.

Without further information (and answers to my previous questions) I can't offer more suggestions at this point but I hope that helps!

like image 132
ashleedawg Avatar answered Dec 29 '22 17:12

ashleedawg