Difference between revisions of "ReNamer:Scripts:Xpdf"
Jump to navigation
Jump to search
(Created page with 'Script integrates [http://www.foolabs.com/xpdf/ Xpdf] command line tool in order to extract PDF tags. == Requirements == * ReNamer 5.10 Beta * [http://www.foolabs.com/xpdf/downl...') |
(→Code: source tag) |
||
Line 9: | Line 9: | ||
Author: Denis Kozlov. Date: 10 Oct 2007. Modify the PDF_TAG constant to specify which tag you want to extract. For the list of available tags consult Xpdf web site or pdfinfo.exe command line tool. | Author: Denis Kozlov. Date: 10 Oct 2007. Modify the PDF_TAG constant to specify which tag you want to extract. For the list of available tags consult Xpdf web site or pdfinfo.exe command line tool. | ||
− | < | + | <source> |
{ Extract PDF tag } | { Extract PDF tag } | ||
Line 45: | Line 45: | ||
FileName := TagValue + WideExtractFileExt(FileName); | FileName := TagValue + WideExtractFileExt(FileName); | ||
end. | end. | ||
− | </ | + | </source> |
Revision as of 02:04, 3 August 2009
Script integrates Xpdf command line tool in order to extract PDF tags.
Requirements
- ReNamer 5.10 Beta
- pdfinfo.exe 3.02 in ReNamer's folder
Code
Author: Denis Kozlov. Date: 10 Oct 2007. Modify the PDF_TAG constant to specify which tag you want to extract. For the list of available tags consult Xpdf web site or pdfinfo.exe command line tool.
{ Extract PDF tag }
const
PDF_INFO = 'pdfinfo.exe';
PDF_TAG = 'Title';
function ExtractTagPDF(const Info, Tag: string): string;
var
Lines: TStringsArray;
I, Delim: Integer;
begin
Result := '';
Lines := WideSplitString(Info, #13#10);
for I := 0 to Length(Lines)-1 do
if WideSameText(Tag, Copy(Lines[i], 1, Length(Tag))) then
begin
Delim := WidePos(':', Lines[i]);
if Delim > 0 then
begin
Result := WideCopy(Lines[i], Delim+1, WideLength(Lines[i]));
Result := Trim(Result);
end;
end;
end;
var
Command, Output: string;
TagValue: string;
begin
Command := '"'+PDF_INFO+'" "'+FilePath+'"';
ExecConsoleApp(Command, Output);
TagValue := ExtractTagPDF(Output, PDF_TAG);
FileName := TagValue + WideExtractFileExt(FileName);
end.