Results 1 to 7 of 7
  1. #1
    lmjconvey89 is offline Novice
    Windows 10 Office 365
    Join Date
    Jun 2020
    Posts
    11

    View PDF in Report

    Hi All,

    Looking to insert a "screenshot" of a PDF in a Report that can then be printed.

    We're a design company, the designer will export their drawing as a PDF, then complete the spec on Access. The PDF will only ever be one page, so don't need to tackle the scenario of seeing the second page.

    I have a field of where the PDF is located. It works a treat with images however the software exports the drawings with a black background, the PDF is exported with a white background and much easier to see.

    Obviously I can't go down the insert Image route as it doesn't recognise PDFs (to the best of my knowledge).

    I think (un)bound object frame may work but I have never used it and have no idea how to set it up.



    Any help would be appreciated. The PDF just needs to be view, not interactive.

  2. #2
    Micron is offline Virtually Inert Person
    Windows 10 Access 2016
    Join Date
    Jun 2014
    Location
    Ontario, Canada
    Posts
    12,800
    If you're storing the pdf in a table attachment field, it's not advised as you will likely soon exceed the db limit of 2GB. Storing the path to the file is the preferred method. For attachment field, what I think you want is a bound object control, not image control. For files retrieved from the network via stored path, IIRC you want to use an unbound object control.
    The more we hear silence, the more we begin to think about our value in this universe.
    Paraphrase of Professor Brian Cox.

  3. #3
    Gicu's Avatar
    Gicu is offline VIP
    Windows 10 Access 2010 32bit
    Join Date
    Jul 2015
    Location
    Kelowna, BC, Canada
    Posts
    4,115
    Have a look at this older app I made quite a few years ago, don't worry about the title, it can handle PDFs too and if you look at the code you should get what you need.

    Cheers,
    Attached Files Attached Files
    Vlad Cucinschi
    MS Access Developer
    http://forestbyte.com/

  4. #4
    ranman256's Avatar
    ranman256 is offline VIP
    Windows Vista Access 2010 32bit
    Join Date
    Apr 2014
    Location
    Kentucky
    Posts
    9,525
    do not put pdf's in reports. you loose quality.
    but you can open it (like Micron said) WITH a report if needed.

    paste this code into a module, then make a button to open the path.

    whatever path is in the textbox will open in its native application
    OpenNativeApp txtBox


    Code:
    #If Win64 Then      'Public Dclare PtrSafe Function
    Private Declare PtrSafe Function ShellExecute Lib "shell32.dll" Alias "ShellExecuteA" (ByVal hwnd As Long, ByVal lpszOp As String, ByVal lpszFile As String, ByVal lpszParams As String, ByVal lpszDir As String, ByVal FsShowCmd As Long) As Long
    Private Declare PtrSafe Function GetDesktopWindow Lib "user32" () As Long
    #else
    Private Declare Function ShellExecute Lib "shell32.dll" Alias "ShellExecuteA" (ByVal hwnd As Long, ByVal lpszOp As String, ByVal lpszFile As String, ByVal lpszParams As String, ByVal lpszDir As String, ByVal FsShowCmd As Long) As Long
    Private Declare Function GetDesktopWindow Lib "user32" () As Long
    #End If
    Const SW_SHOWNORMAL = 1
    Const SE_ERR_FNF = 2&
    Const SE_ERR_PNF = 3&
    Const SE_ERR_ACCESSDENIED = 5&
    Const SE_ERR_OOM = 8&
    Const SE_ERR_DLLNOTFOUND = 32&
    Const SE_ERR_SHARE = 26&
    Const SE_ERR_ASSOCINCOMPLETE = 27&
    Const SE_ERR_DDETIMEOUT = 28&
    Const SE_ERR_DDEFAIL = 29&
    Const SE_ERR_DDEBUSY = 30&
    Const SE_ERR_NOASSOC = 31&
    Const ERROR_BAD_FORMAT = 11&
    
    Public Sub OpenNativeApp(ByVal psDocName As String)
    Dim r As Long, msg As String
    r = StartDoc(psDocName)
    If r <= 32 Then
        'There was an error
        Select Case r
            Case SE_ERR_FNF
                msg = "File not found"
            Case SE_ERR_PNF
                msg = "Path not found"
            Case SE_ERR_ACCESSDENIED
                msg = "Access denied"
            Case SE_ERR_OOM
                msg = "Out of memory"
            Case SE_ERR_DLLNOTFOUND
                msg = "DLL not found"
            Case SE_ERR_SHARE
                msg = "A sharing violation occurred"
            Case SE_ERR_ASSOCINCOMPLETE
                msg = "Incomplete or invalid file association"
            Case SE_ERR_DDETIMEOUT
                msg = "DDE Time out"
            Case SE_ERR_DDEFAIL
                msg = "DDE transaction failed"
            Case SE_ERR_DDEBUSY
                msg = "DDE busy"
            Case SE_ERR_NOASSOC
                msg = "No association for file extension"
            Case ERROR_BAD_FORMAT
                msg = "Invalid EXE file or error in EXE image"
            Case Else
                msg = "Unknown error"
        End Select
    '    MsgBox msg
    End If
    End Sub
    
    Private Function StartDoc(psDocName As String) As Long
    Dim Scr_hDC As Long
    Scr_hDC = GetDesktopWindow()
    StartDoc = ShellExecute(Scr_hDC, "Open", psDocName, "", "C:\", SW_SHOWNORMAL)
    End Function



  5. #5
    lmjconvey89 is offline Novice
    Windows 10 Office 365
    Join Date
    Jun 2020
    Posts
    11
    Thanks all for your quick responses. Just to be clear I haven't inserted the PDF in to my tables just the path. Also I don't want to open the PDF, I just want to create a "window" to see what's in the PDF and for this to be printed on the Report.

    Attached is what I have done so far, it all works perfectly fine with the images updating per record using the path that is stored. My problem is it needs to be a PDF as the JPGs become unviewable.

    Click image for larger version. 

Name:	Capture.JPG 
Views:	18 
Size:	98.0 KB 
ID:	47162

  6. #6
    CJ_London is offline VIP
    Windows 10 Access 2010 32bit
    Join Date
    Mar 2015
    Posts
    11,424
    there is an active X control called Adobe PDF reader which might work for you on reports, you will have to experiment. Found this link which may be of assistance http://msaccess.erpmakers.com/Articl...%20control.php

    Regret don't have time to experiment with it

  7. #7
    Gicu's Avatar
    Gicu is offline VIP
    Windows 10 Access 2010 32bit
    Join Date
    Jul 2015
    Location
    Kelowna, BC, Canada
    Posts
    4,115
    @lmjconvey89:
    Did you have a look at my sample file? It uses a bound OLE Object Frame control to display the file selected in a listbox. The code can easily be adapted to use your saved path.

    Cheers,
    Vlad Cucinschi
    MS Access Developer
    http://forestbyte.com/

Please reply to this thread with any new information or opinions.

Similar Threads

  1. Replies: 1
    Last Post: 09-16-2019, 11:16 AM
  2. Replies: 0
    Last Post: 07-27-2018, 02:17 PM
  3. Replies: 16
    Last Post: 03-13-2018, 05:24 PM
  4. Replies: 4
    Last Post: 03-02-2018, 09:11 AM
  5. Replies: 10
    Last Post: 02-06-2018, 02:37 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Other Forums: Microsoft Office Forums