Results 1 to 5 of 5

Thread: [RESOLVED] help to load .pdf files

  1. #1

    Thread Starter
    Lively Member
    Join Date
    Dec 2012
    Location
    Dammam, Saudi Arabia
    Posts
    74

    Resolved [RESOLVED] help to load .pdf files

    Hi All,

    I want to upload Employee's documents to a database. I'm using Image control for this. When I try to upload a pdf file, it shows me an error like this: "invalid Picture". I need to upload documents in pdf format.

    Please help me

  2. #2
    Default Member Bonnie West's Avatar
    Join Date
    Jun 2012
    Location
    InIDE
    Posts
    4,060

    Re: help to load .pdf files

    Quote Originally Posted by nasar View Post
    I'm using Image control for this. When I try to upload a pdf file, it shows me an error like this: "invalid Picture".
    That's because a PDF file is not a "picture" file, although it can contain embedded pictures (JPG, etc.).

    Can you provide even more details about your problem?
    On Local Error Resume Next: If Not Empty Is Nothing Then Do While Null: ReDim i(True To False) As Currency: Loop: Else Debug.Assert CCur(CLng(CInt(CBool(False Imp True Xor False Eqv True)))): Stop: On Local Error GoTo 0
    Declare Sub CrashVB Lib "msvbvm60" (Optional DontPassMe As Any)

  3. #3

    Thread Starter
    Lively Member
    Join Date
    Dec 2012
    Location
    Dammam, Saudi Arabia
    Posts
    74

    Re: help to load .pdf files

    Thanks for the reply Bonnie.


    Below is the code which i'm using to load image files. its working fine. but when i try to load a pdf file it
    shows an error at line - Set PIC = LoadPicture(NewPath)

    While googling i read somewhere that pdf files can be loaded with the help of AcroPDF

    Code:
    Private Sub LoadImage(txtName As TextBox, ImgName As PictureBox, ItemName As String, EmpName As String, EmpNo As String)
    Dim Path,  CopiedFileName As String
    Dim FileCopy As New Scripting.FileSystemObject
    Dim FolderCreate As New Scripting.FileSystemObject
    Dim NewPath, EditedPath As String
    Dim PIC As StdPicture
    Dim Fname, Copy As String
    Dim OrgPath As String
    Const NewH As Integer = 2175, NewW As Integer = 2655
    
    
    On Error GoTo ErrHandler
        
        With cdlAll
             .DialogTitle = "Select " & ItemName
             .Filter = "Picture Files(*.bmp,*.ico,*.jpg)|*.bmp;*.ico;*.jpg|PDF Files(*.pdf)|*.pdf|All Files(*.*)|*.*"
             .ShowOpen
             txtName.Text = .FileName
        End With
        If txtName.Text <> "" Then
            Path = CreateObject("WScript.Shell").ExpandEnvironmentStrings(txtName.Text)
            OrgPath = FileCopy.GetParentFolderName(Path)
            OrgPath = OrgPath & "\"
            If FileCopy.FolderExists("......" & EmpName & "-" & EmpNo) Then
                Copy = "............" & EmpName & "-" & EmpNo
            Else
                Copy = FolderCreate.CreateFolder("........................" & EmpName & "-" & EmpNo)
                
            End If
            Copy = Copy & "\"
            FileCopy.CopyFile Path, Copy, True
            NewPath = Copy & FileCopy.GetFileName(Path)
             '----------------------------------------------------------------------------
              '--resizing the pic
            Set PIC = LoadPicture(NewPath)
            With ImgName   '--pictude box
    
    
                .width = NewW 
                .Height = NewH
                .AutoRedraw = True
                .Cls
                Call .PaintPicture(PIC, 0, 0, NewW, NewH)
                .AutoRedraw = False
                CopiedFileName = FileCopy.GetBaseName(NewPath) & "_edited." & FileCopy.GetExtensionName(NewPath)
    
    
                Call SavePicture(.Image, CopiedFileName)
                OrgPath = OrgPath & CopiedFileName
                FileCopy.MoveFile OrgPath, Copy
            End With
    '-----------------------------------------------------------------------------------
            EditedPath = Copy & CopiedFileName
    
    
            ImgName.Picture = LoadPicture(EditedPath) '---loading the edited pic for viewing
            txtName.Text = NewPath      '-- actual pic path for saving
        End If    
        
    Exit Sub
    ErrHandler:
        Debug.Print err.Number & " -" & err.Description
        txtName.Text = ""
        ImgName.Picture = LoadPicture("")
    End Sub
    Last edited by nasar; May 21st, 2013 at 01:40 AM.

  4. #4
    Default Member Bonnie West's Avatar
    Join Date
    Jun 2012
    Location
    InIDE
    Posts
    4,060

    Re: help to load .pdf files

    It seems you want a screenshot of the PDF file to appear in your picture box. In that case, VB6 can't do it alone. I haven't used AcroPDF but I suppose it has the capability to extract thumbnails from a PDF file.
    On Local Error Resume Next: If Not Empty Is Nothing Then Do While Null: ReDim i(True To False) As Currency: Loop: Else Debug.Assert CCur(CLng(CInt(CBool(False Imp True Xor False Eqv True)))): Stop: On Local Error GoTo 0
    Declare Sub CrashVB Lib "msvbvm60" (Optional DontPassMe As Any)

  5. #5

    Thread Starter
    Lively Member
    Join Date
    Dec 2012
    Location
    Dammam, Saudi Arabia
    Posts
    74

    Re: help to load .pdf files

    Quote Originally Posted by Bonnie West View Post
    It seems you want a screenshot of the PDF file to appear in your picture box. In that case, VB6 can't do it alone. I haven't used AcroPDF but I suppose it has the capability to extract thumbnails from a PDF file.
    Thanks for the reply again... I got it Bonnie....

    I tried AcroPDF and it worked fine.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width