This repository has been archived by the owner on Dec 14, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1
/
PDF-Cover-Generator.pl
executable file
·106 lines (89 loc) · 3.6 KB
/
PDF-Cover-Generator.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
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
#!/usr/bin/perl
#This file is part of NVRA-PDF-Generator .
#
# NVRA-PDF-Generator is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# NVRA-PDF-Generator is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with NVRA-PDF-Generator . If not, see <http://www.gnu.org/licenses/>.
# See below for information about argument order and usage!
use PDF::Reuse;
use PDF::Reuse::Util;
use strict;
use Switch;
# Personal Libraries
require "PDF-Multiline_Output_Functions.pl";
# Max Registration Text Width sets the maximum width in points
# that can fit on the Registration Date column/section. If this
# needs to be changed, you will have to test the new width using
# prStrWidth and carefully set the below variable!
my $maxRegTextWidth = 200;
my $maxRegTextLines = 10;
#Setup the font here -- see PDF:Reuse for options
my $font = 'H'; # Helvetica
my $boldFont = 'HB'; # Helvetica-Bold
my $fontSize = 12;
# Text output options
my $lineOffset = $fontSize + 1; # Try $fontSize + 1 or 2
my $error;
my $numArgs = $#ARGV + 1;
my $resultsFile = " ";
my $sourceFile = " ";
my $regDeadline = " ";
my $lineOne = " ";
my $lineTwo = " ";
my $lineThree = " ";
my $lineFour = " ";
# Check for minimum number of arguments
if ($numArgs >= 3) {
$sourceFile = $ARGV[0];
$resultsFile = $ARGV[1];
$regDeadline = $ARGV[2];
# Address lines 1-4 are optional, leave as default if not present
if ($numArgs >= 4) { $lineOne = $ARGV[3]; }
if ($numArgs >= 5) { $lineTwo = $ARGV[4]; }
if ($numArgs >= 6) { $lineThree = $ARGV[5]; }
if ($numArgs == 7) { $lineFour = $ARGV[6]; }
}else {
$error = "Error: Wrong number of Arguments! \n";
$error += "\n";
$error += "Options are (in order): \n";
$error += " 1. Source File Path \n";
$error += " 2. Results File Path \n";
$error += " 3. Registration Deadline \n";
$error += " 4. Line 1 of the Address (Optional) \n";
$error += " 5. Line 2 of the Address (Optional) \n";
$error += " 6. Line 3 of the Address (Optional) \n";
$error += " 7. Line 4 of the Address (Optional) \n";
$error += " \n\n";
}
if (!$error){ # If there were no errors execute the main program block
prFile($resultsFile); # Setup output file
# Font Options - Note that some of these are overridden in
# the multiline output function
blackText();
prFont( $font );
prFontSize ( $fontSize );
# Use function to take care of multi-line Reg dates
# Waring: may overrun space provided
my @txtArray = convLineToCol ( $maxRegTextWidth, $font, $fontSize, $regDeadline);
# Note that txtArray is being passed by reference!
writeMultiLineStr( 365, 450, $lineOffset, $font, $boldFont, \@txtArray);
# Write out the address lines on the PDF
prText( 365, 550, $lineOne); # 1st Address Line
prText( 365, 535, $lineTwo); # 2nd Address Line
prText( 365, 520, $lineThree); # 3rd Address Line
prText( 365, 505, $lineFour); # 4th Address Line
# Provide the source file to use as our starting point
prSinglePage($sourceFile);
prEnd(); # Flush the buffers and save the completed PDF
}else {
print $error;
}