Read PDF information
Read PDF information
Hi, I'd like to see zhe metainformation like title and author of my PDF files, could this be done using Purebasic? PurePDF seems to have functions to create PDF's only, did not find a function in Ghostsscript either. There's a commercial command line tool A-Pdf Info Changer...
- Michael Vogel
- Addict
- Posts: 2797
- Joined: Thu Feb 09, 2006 11:27 pm
- Contact:
Re: Read PDF information
A quick start (will definitely not work with encrypted files)...
Code: Select all
Procedure GetPdfInfo(file.s)
Protected n
Protected s.s
Protected info.s
Protected exit
Protected scan
If ReadFile(0,file,#PB_File_NoBuffering)
While exit+Eof(0)=#Null
s=ReadString(0)
If scan
s=Trim(s)
s=Trim(s,#TAB$)
If s="</x:xmpmeta>"
exit=#True
ElseIf Left(s,4)="<dc:"
info=StringField(Mid(s,5),1,">")
ElseIf Left(s,7)="<rdf:li"
info+": "+StringField(StringField(s,2,">"),1,"<")
Debug info
EndIf
ElseIf Left(s,16)="<x:xmpmeta xmlns"
scan=1
EndIf
Wend
EndIf
EndProcedure
GetPdfInfo("C:\Users\...\Desktop\Test.pdf")