Print Page | Close Window

Extract Metadata

Printed From: Debenu Quick PDF Library - PDF SDK Community Forum
Category: For Users of the Library
Forum Name: I need help - I can help
Forum Description: Problems and solutions while programming with the Debenu Quick PDF Library and Debenu PDF Viewer SDK
URL: http://www.quickpdf.org/forum/forum_posts.asp?TID=2845
Printed Date: 14 Jun 25 at 10:27PM
Software Version: Web Wiz Forums 11.01 - http://www.webwizforums.com


Topic: Extract Metadata
Posted By: Guna
Subject: Extract Metadata
Date Posted: 06 Mar 14 at 5:12PM
Hi,

I want to know how to create a specific action to extract metadata from the PDF. This action must be automated so that I can extract 100 document titles. Please help!! 

Regards,
Guna



Replies:
Posted By: AndyD
Date Posted: 07 Mar 14 at 9:28AM
This solution is For VB6.
 
One example of this would be if you wanted to read the Title data from a list of PDF's and display them in a Listbox.
 
I use this personally in a program because many PDF filenames are quite random whereas you can store meaningful info in the title and use that instead.
 
First I have a form with a basic listbox on it.
 
Then at runtime just set the column headers.
 
Private Sub Form_Load()
 
    Set colX = ListView1.ColumnHeaders.add()
        colX.Text = "Filename"
        colX.Width = 1
' I set this to 1 to hide this column as the Filename isn't useful to me visually but is used elsewhere.
   
    Set colX = ListView1.ColumnHeaders.add()
        colX.Text = "Document Description"
        colX.Width = 9100
 
End Sub
 
Then either within the form load or from a button call, the following routine will loop through all the PDF's in a specific folder, using the Call ReadPDF function it extracts the Title information from each PDF and displays it in the listbox.
 
 
Dim sFile As String
Dim FullPath as String
 
sFile = Dir$("PDFLocation\*.*")
    

Do Until sFile = ""

If Left$(sFile, 1) <> "." Then
     FullPath = "PDFLocation\" & sFile
     Call ReadPDF(FullPath)
     Set ItmX = ListView1.ListItems.add(, , sFile)
     ItmX.SubItems(1) = msTitle
End If
sFile = Dir$
Loop
ListView1.Sorted = True
ListView1.SortOrder = lvwAscending ' This just sorts the titles alphabetically
ListView1.SortKey = 1
 
 
Function ReadPDF(ByVal sFile As String) As Boolean
    ClassName = "DebenuPDFLibraryAX0914.PDFLibrary"
    LicenseKey = "Your Licence info here"
    Set QP = CreateObject(ClassName)
    Result = QP.UnlockKey(LicenseKey)
If result = 1 then    
    Call QP.LoadFromFile(sFile, "")
    msTitle = QP.GetInformation(2)
    Set QP = Nothing
End If
End Function
 
 
Using the .GetInformation() function you can retrieve the following info:
 
(0) = PDF Version
(1) = Author
(2) = Title
(3) = Subject
(4) = Keywords
(5) = Creator
(6) = Producer
(7) = Creation Date
(8) = Modification Date
 
 
Hopefully this will help someway to achieving what you need.



Print Page | Close Window

Forum Software by Web Wiz Forums® version 11.01 - http://www.webwizforums.com
Copyright ©2001-2014 Web Wiz Ltd. - http://www.webwiz.co.uk