Display PDF in Report
Asked Answered
I

1

6

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"

Ictinus answered 17/1, 2018 at 14:29 Comment(7)
can you get it to work with a hyperlink to the pdf instead of an embedded object?Storm
If I create a new report, add an unbound object frame and select a pdf, it works just fine. Having set that, have a look at this discussion: Embedding PDF file in ReportDemmer
How "dynamic" are these PDF images? Is there a limited number of PDFs? How many? You want to programmatically choose which one to display? -- or, are they being generated on the fly by another program? No interaction is required with the PDF (like filling a PDF form), correct? Are they single-page PDF's? Are they all the same dimensions? Do you have the full version of Adobe Acrobat (not reader)? Do you have an issue with using 3rd-party or possibly "unlicensed" software to make this happen? Does this need to work on only one installation of Access?Undervest
....I assume you've posted the bounty since you're already aware (as a little research shows) that what you want to do is not possible through "traditional" means... (ie., this.) That being said, "there's always a way". I have a couple ideas depending on your answers to the above clarifications.Undervest
@Storm Hyperlink does also not change the pdf on the Form load/open Event - also no error.Ictinus
This is getting confusing. What has the report to do with a Form_Load event? Do you want to change the displayed PDF in an already opened report?Tartarean
@Tartarean much sorry, i meant in the Report_load event of courseIctinus
U
3

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!

Undervest answered 28/1, 2018 at 17:28 Comment(12)
Hello Sir, i already heard from the 2jpeg method, but this would also be the most consuming Way for displaying a one Page pdf, i thought there can be a other wayIctinus
The oleunbound does already display the pdf, but i cant load others on the form load/open/current eventIctinus
how you mean set number of Images? this are all pdf'sIctinus
what i don't get is that on the create of the oleunbound object i can choose the PDF and it also got correctly shownIctinus
but i cant change it with the vba code above, there are also no errors, the first PDF just stays in.Ictinus
@JulPod -- You didn't mention in your question that you need to change anything.Undervest
"I want to display dynamically .pdf files ..."Ictinus
"Display", not "Change"Undervest
Do you mean to switch to different pictures, or to change, as in edit the picture?Undervest
You can switch to as many pictures as you want if you are producing them dynamically with the suggestions above. Editing the images is not possible, at least not without a major amount of coding.Undervest
no i dont want to Change anything at the Images, i just want to load different pdf's on the form load or open Event with an oleounbound objectIctinus
or other object as somebody knowsIctinus

© 2022 - 2024 — McMap. All rights reserved.