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
Printable View
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
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
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.