Page 1 of 1
Read PDF information
Posted: Tue Jul 24, 2018 8:48 am
by Puffolino
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...
Re: Read PDF information
Posted: Wed Jul 25, 2018 11:52 pm
by Michael Vogel
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")