on my windows machine this runs just fine, but when i load it to the server it fails and the only error I get is the execution error. I not sure what causeing it, I tried the dos2unix command with no avail, any Ideas?
#!/usr/bin/perl -wT
use PDF::API2;
use PDF::Table;
use perlchartdir;
use CGI;
use strict;
use warnings;
print header( "application/pdf" );
use constant mm => 25.4/72;
use constant in => 1/72;
use constant pt => 1;
sub setImage;
sub newText;
sub newTextRight;
sub checkCurrency;
sub GrabParams;
my $q = new CGI;
my %valueHash;
GrabParams();
my $ID = $q->param("ID");
######################################################
## Config Variable Edit this for Easy Configuration ##
######################################################
my $Template = qq(Dell_Deployment_Optimization_Report.pdf);
my $ChartImageName = "DellDOChart".$ID.".jpeg";
my $bubbleName = "Bubble".$ID.".jpeg";
## Text Vars
my $fontType = qq(Helvetica);
my $CurrencySymbol = $q->param("CurrencySymbol");
############### MAKE stack bar CHART ####################
# The data for the bar chart
my $data6 = [$valueHash{"ch1v11"}, $valueHash{"ch1v21"}, $valueHash{"c
+h1v31"}, $valueHash{"ch1v41"}];
my $data5 = [$valueHash{"ch1v12"}, $valueHash{"ch1v22"}, $valueHash{"c
+h1v32"}, $valueHash{"ch1v42"}];
my $data4 = [$valueHash{"ch1v13"}, $valueHash{"ch1v23"}, $valueHash{"c
+h1v33"}, $valueHash{"ch1v43"}];
my $data3 = [$valueHash{"ch1v14"}, $valueHash{"ch1v24"}, $valueHash{"c
+h1v34"}, $valueHash{"ch1v44"}];
my $data2 = [$valueHash{"ch1v15"}, $valueHash{"ch1v25"}, $valueHash{"c
+h1v35"}, $valueHash{"ch1v45"}];
my $data1 = [$valueHash{"ch1v16"}, $valueHash{"ch1v26"}, $valueHash{"c
+h1v36"}, $valueHash{"ch1v46"}];
my $data0 = [$valueHash{"ch1v17"}, $valueHash{"ch1v27"}, $valueHash{"c
+h1v37"}, $valueHash{"ch1v47"}];
# The labels for the bar chart
my $labels = [$valueHash{"ch1x1"}, $valueHash{"ch1x2"}, $valueHash{"ch
+1x3"}, $valueHash{"ch1x4"}];
# Create a XYChart object of size 500 x 320 pixels
my $c = new XYChart(540, 450);
# Set the plotarea at (100, 40) and of size 280 x 240 pixels
$c->setPlotArea(105, 45, 305, 375);
# Add a legend box at (400, 100)
$c->addLegend(349, 42)->setBackground(0xffffff);
#$c->LegendBox
# Add a title to the chart using 14 points Times Bold Itatic font
$c->addTitle($valueHash{"ch1title"}, "", 13);
# Add a title to the y axis. Draw the title upright (font angle = 0)
#$c->yAxis()->setTitle($q->param("Currency"))->setFontAngle(90);
# Set the labels on the x axis
$c->yAxis()->setLabelFormat("$CurrencySymbol"." "."{value|,}");
# Set the labels on the x axis
$c->xAxis()->setLabels($labels);
# Add a stacked bar layer and set the layer 3D depth to 8 pixels
my $layer = $c->addBarLayer2($perlchartdir::Stack, 8);
# Add the seven data sets to the bar layer
$layer->addDataSet($data6, 0x9999ff, $valueHash{"ch1s1"});
$layer->addDataSet($data5, 0x993366, $valueHash{"ch1s2"});
$layer->addDataSet($data4, 0xffffcc, $valueHash{"ch1s3"});
$layer->addDataSet($data3, 0xccffff, $valueHash{"ch1s4"});
$layer->addDataSet($data2, 0x660066, $valueHash{"ch1s5"});
$layer->addDataSet($data1, 0xff8080, $valueHash{"ch1s6"});
$layer->addDataSet($data0, 0x0066cc, $valueHash{"ch1s7"});
# Enable bar label for the whole bar
#$layer->setAggregateLabelStyle();
# Enable bar label for each segment of the stacked bar
#$layer->setDataLabelStyle();
# output the chart
$c->makeChart($ChartImageName);
######################### END CHART #############################
########################### BUBBLE CHART #############################
+################
# The XYZ points for the bubble chart
my $dataX0 = [150, 300, 1000, 1700];
my $dataY0 = [12, 60, 25, 65];
my $dataZ0 = [20, 50, 50, 85];
my $dataX1 = [500, 1000, 1300];
my $dataY1 = [35, 50, 75];
my $dataZ1 = [30, 55, 95];
# Create a XYChart object of size 450 x 420 pixels
my $ch = new XYChart(450, 420);
# Set the plotarea at (55, 65) and of size 350 x 300 pixels, with a li
+ght grey border
# (0xc0c0c0). Turn on both horizontal and vertical grid lines with lig
+ht grey color
# (0xc0c0c0)
$ch->setPlotArea(55, 65, 350, 300, -1, -1, 0xc0c0c0, 0xc0c0c0, -1);
# Add a legend box at (50, 30) (top of the chart) with horizontal layo
+ut. Use 12 pts
# Times Bold Italic font. Set the background and border color to Trans
+parent.
$ch->addLegend(50, 30, 0, "timesbi.ttf", 12)->setBackground($perlchart
+dir::Transparent
);
# Add a title to the chart using 18 pts Times Bold Itatic font.
$ch->addTitle("Product Comparison Chart", "timesbi.ttf", 18);
# Add a title to the y axis using 12 pts Arial Bold Italic font
$ch->yAxis()->setTitle("Capacity (tons)", "arialbi.ttf", 12);
# Add a title to the x axis using 12 pts Arial Bold Italic font
$ch->xAxis()->setTitle("Range (miles)", "arialbi.ttf", 12);
# Set the axes line width to 3 pixels
$ch->xAxis()->setWidth(3);
$ch->yAxis()->setWidth(3);
# Add (dataX0, dataY0) as a scatter layer with semi-transparent red (0
+x80ff3333)
# circle symbols, where the circle size is modulated by dataZ0. This c
+reates a bubble
# effect.
$ch->addScatterLayer($dataX0, $dataY0, "Technology AAA", $perlchartdir
+::CircleSymbol,
9, 0x80ff3333, 0x80ff3333)->setSymbolScale($dataZ0);
# Add (dataX1, dataY1) as a scatter layer with semi-transparent green
+(0x803333ff)
# circle symbols, where the circle size is modulated by dataZ1. This c
+reates a bubble
# effect.
$ch->addScatterLayer($dataX1, $dataY1, "Technology BBB", $perlchartdir
+::CircleSymbol,
9, 0x803333ff, 0x803333ff)->setSymbolScale($dataZ1);
# output the chart
$ch->makeChart($bubbleName);
########################### MAKE PDF ############################
my $pdftable = new PDF::Table;
my $pdf = PDF::API2->open($Template);
my $page = $pdf->openpage(1);
##### Set Font
###############
my %font = (
Helvetica => {
Bold => $pdf->corefont('Helvetica-Bold', -encoding =>
+'latin1'),
Roman => $pdf->corefont('Helvetica', -encoding => '
+latin1'),
Italic => $pdf->corefont('Helvetica-Oblique', -encoding =>
+'latin1'),
},
);
## Set Image( x, y, w, h)
###############
setImage($ChartImageName, 115/mm, 171/mm, 89/mm, 75/mm);
## Set Text
###############
#Title
newText($fontType, 'Roman', 12.5/pt, 'black', 13.5/mm, 263/mm, $value
+Hash{"repTitle"});
#ES
newText($fontType, 'Roman', 7/pt, 'black', 12.5/mm, 254/mm, $valueHas
+h{"ES1"});
newText($fontType, 'Roman', 7/pt, 'black', 12.5/mm, 251/mm, $valueHas
+h{"ES2"});
newText($fontType, 'Roman', 7/pt, 'black', 12.5/mm, 248/mm, $valueHas
+h{"ES3"});
newText($fontType, 'Roman', 7/pt, 'black', 12.5/mm, 245/mm, $valueHas
+h{"ES4"});
#Assumptions
newText($fontType, 'Roman', 8/pt, 'black', 12.5/mm, 230/mm, $valueHas
+h{"CompanyType"});
newText($fontType, 'Roman', 8/pt, 'black', 12.5/mm, 226/mm, $valueHas
+h{"Country"});
newText($fontType, 'Roman', 8/pt, 'black', 12.5/mm, 222/mm, $valueHas
+h{"Currency"});
newText($fontType, 'Roman', 8/pt, 'black', 12.5/mm, 215/mm, $valueHas
+h{"D9"});
#newText($fontType, 'Roman', 8/pt, 'black', 12.5/mm, 196/mm, $valueHa
+sh{"D11"});
#newText($fontType, 'Roman', 8/pt, 'black', 12.5/mm, 192/mm, $valueHa
+sh{"D12"});
newText($fontType, 'Roman', 8/pt, 'black', 12.5/mm, 211/mm, $valueHas
+h{"D14"});
newText($fontType, 'Roman', 8/pt, 'black', 12.5/mm, 207/mm, $valueHas
+h{"D15"});
#Current Optimization Practices
newText($fontType, 'Roman', 8/pt, 'black', 12.5/mm, 195/mm, "Deployme
+nt Management:");
newText($fontType, 'Roman', 6.75/pt, 'black', 12.5/mm, 191/mm, $value
+Hash{"COP1a"});
newText($fontType, 'Roman', 8/pt, 'black', 12.5/mm, 184/mm, "Staging
+and Logistics of deployed PCs:");
newText($fontType, 'Roman', 6.75/pt, 'black', 12.5/mm, 180/mm, $value
+Hash{"COP2a"});
newText($fontType, 'Roman', 8/pt, 'black', 12.5/mm, 173/mm, "Image Lo
+ading:");
newText($fontType, 'Roman', 6.75/pt, 'black', 12.5/mm, 169/mm, $value
+Hash{"COP3a"});
newText($fontType, 'Roman', 8/pt, 'black', 12.5/mm, 161/mm, "Methods
+used to install applications:");
newText($fontType, 'Roman', 6.75/pt, 'black', 12.5/mm, 157/mm, $value
+Hash{"COP41a"});
newText($fontType, 'Roman', 6.75/pt, 'black', 12.5/mm, 153/mm, $value
+Hash{"COP42a"});
newText($fontType, 'Roman', 6.75/pt, 'black', 12.5/mm, 149/mm, $value
+Hash{"COP43a"});
newText($fontType, 'Roman', 6.75/pt, 'black', 12.5/mm, 145/mm, $value
+Hash{"COP44a"});
newText($fontType, 'Roman', 8/pt, 'black', 12.5/mm, 138/mm, "User Sta
+te Migration:");
newText($fontType, 'Roman', 6.75/pt, 'black', 12.5/mm, 134/mm, $value
+Hash{"COP5a"});
newText($fontType, 'Roman', 8/pt, 'black', 12.5/mm, 127/mm, "Post Dep
+loyment End User Support:");
newText($fontType, 'Roman', 6.75/pt, 'black', 12.5/mm, 123/mm, $value
+Hash{"COP6a"});
#newText($fontType, 'Roman', 6.75/pt, 'black', 12.5/mm, 123/mm, "Remo
+te issue resolution; \"command center\" remotely monitors deployment/
+troubleshoots issues");
######################################################################
+#############################
$page = $pdf->openpage(2);
setImage($bubbleName, 115/mm, 100/mm, 89/mm, 75/mm);
######################################################################
+##########################
sub newText{
my $flashVars = $page->text;
$flashVars->font( $font{$_[0]}{$_[1]}, $_[2] );
$flashVars->fillcolor( $_[3] );
$flashVars->translate( $_[4], $_[5] );
$flashVars->text( $_[6] );
}
####################################
sub setImage{
my $photo_file=$pdf->image_jpeg($_[0]);
my $photo = $page->gfx;
## add photo to pdf include cordinates and size - image($photo, x,
+ y, width, hieght);
$photo->image($photo_file, $_[1], $_[2], $_[3], $_[4]);
}
############ END setImage FUNCTION #################
sub GrabParams{
my ( $paramName, $paramValue);
foreach $paramName ($q->param) {
$valueHash{$paramName};
foreach $paramValue ($q->param( $paramName )) {
$valueHash{ $paramName } = pack 'U0A*', $paramValue;
+
}
}
}
print $pdf->stringify;
binmode STDOUT;
$pdf->end;
unlink($ChartImageName, $bubbleName);
__END__