|
-
May 20th, 2013, 03:18 AM
#1
Thread Starter
Lively Member
[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
-
May 20th, 2013, 04:15 AM
#2
Re: help to load .pdf files
 Originally Posted by nasar
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)
-
May 21st, 2013, 01:31 AM
#3
Thread Starter
Lively Member
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.
-
May 22nd, 2013, 07:29 AM
#4
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)
-
May 22nd, 2013, 11:50 PM
#5
Thread Starter
Lively Member
Re: help to load .pdf files
 Originally Posted by Bonnie West
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
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|