forked from mamintoosi/persian-bib
-
Notifications
You must be signed in to change notification settings - Fork 0
/
gen_pdf.pl
executable file
·57 lines (49 loc) · 1.39 KB
/
gen_pdf.pl
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
#!/usr/bin/env perl
##########################################################
# Author: Mahmood Amintoosi #
# Date: 10 Feb 2011 #
# Version: .10 #
# Application: Produce pdf files of Persian-bib styles #
##########################################################
use File::Copy;
open(INFILE,"bibtex-example.tex");
@styleList = ("acm-fa","plain-fa","unsrt-fa","ieeetr-fa","asa-fa","chicago-fa","plainnat-fa");
@natbibStyles = ("asa-fa","chicago-fa","plainnat-fa");
@lines = <INFILE>;
foreach $style (@styleList)
{
$fileName = $style.".pdf";
$tmpFile = "tmp";
open(OUTFILE,">".$tmpFile.".tex");
print $fileName;
foreach $line(@lines)
{
$a = $line;
#Checking wether natbib package is required or not
$natbibRequired = 0;
foreach $natbibStyle(@natbibStyles)
{
if($style eq $natbibStyle)
{
$natbibRequired = 1;
#last;
}
}
# print $natbibRequired;
if ($natbibRequired==1 && $a =~ /usepackage{xepersian}/)
{
print OUTFILE "\\usepackage{natbib}\n";
}
$a =~ s/acm-fa/$style/;
print OUTFILE $a;
}
close (OUTFILE);
system("xelatex",$tmpFile);
system("bibtex8","-W","-c","cp1256fa",$tmpFile);
system("xelatex",$tmpFile);
system("xelatex",$tmpFile);
copy($tmpFile.".pdf",$fileName) or die "Copy failed: $!";
unlink <tmp.*>;
#seek(INFILE,0,SEEK_SET);
}
close (INFILE);