With my Laravel app, the PHPPresentation library I had is producing fine charts with no errors at all. Now when I'm applying it on a CodeIgniter app, I just copy pasted the code and installed a composer, the chart isn't working anymore
I tried to install the PHPPresentation manually and read the documents, but to no avail, not a single one succeeded
// Create new PHPPresentation object
$objPHPPresentation = new PhpPresentation();
// Set properties
$objPHPPresentation->getDocumentProperties()->setCreator('PHPOffice')
->setLastModifiedBy('PHPPresentation Team')
->setTitle('Sample 01 Title')
->setSubject('Sample 01 Subject')
->setDescription('Sample 01 Description')
->setKeywords('office 2007 openxml libreoffice odt php')
->setCategory('Sample Category');
// Point towards the last slide
$currentSlide = $objPHPPresentation->getActiveSlide();
//Data
$seriesData = array(
'Monday' => 12,
'Tuesday' => 15,
'Wednesday' => 13,
'Thursday' => 17,
'Friday' => 14,
'Saturday' => 9,
'Sunday' => 7
);
// Set Style
$oFill = new Fill();
$oFill->setFillType(Fill::FILL_SOLID)->setStartColor(new Color('ffe6e6'));
$oShadow = new Shadow();
$oShadow->setVisible(true)->setDirection(45)->setDistance(10);
//Define Line Chart lines
$oOutline = new Outline();
$oOutline->getFill()->setFillType(Fill::FILL_SOLID);
$oOutline->getFill()->setStartColor(new Color(Color::COLOR_BLACK));
$oOutline->setWidth(1);
// Create a line chart (that should be inserted in a shape)
$lineChart = new Line();
$series = new Series('Views', $seriesData);
$series->setShowSeriesName(false);
$series->setShowValue(true);
$series->getFont()->setSize(12);
$series->setOutline($oOutline);
$lineChart->addSeries($series);
Back in my Laravel app this PHPPresentation sample works perfectly fine, but when I placed it in my CodeIgniter app, it shows a blank image
Here's a sample output:
Related
I am using TCDPF to generate barcode in invoice. Thus, when I download invoice by clicking "View Invoice" from Orders page, it should download with a barcode generated. At the moment, I am just testing a random number.
In HTMLTemplateInvoice.php, I added the following codes:
// Random number for testing
$barcodeobj = new TCPDFBarcode('1234567890123', 'C39');
// Assign to template
// All other unnecessary variables not displayed
'barcode' => base64_encode($barcodeobj->getBarcodePNG(1, 30, array(255,255,255))),
);
For testing purpose, I added the following codes in invoice.addresses.tab.tpl
<img src="data:image/png;base64,{$barcode}>">
The barcode is displayed. Unfortunately, it is dislaying as a page and it is not generated in the invoice. The invoice will not download too.
I am using Prestashop 1.7.4.2 and upgraded to PHP 7.2.
I've tried this code
$barcodeobj = new TCPDFBarcode("123456789123", 'C39');
$Barcode = $barcodeobj->getBarcodePngData(2, 40, array(0,0,0));
and then i created a new pdf :
$Barcode_pdf = new TCPDF('P', 'mm', 'A5', true, 'UTF-8', false);
$Barcode_pdf->SetMargins(7, 10.4, 8);
$Barcode_pdf->setImageScale(0.5);
$Barcode_pdf->AddPage();
$Barcode_pdf->Image('#'.$Barcode,'10','20','60' );
$Barcode_pdf->Output('Barcode.pdf', 'I')
you can attach it to email if you want but change the output type to 'S':
$Barcode_attachment = array();
$Barcode_attachment['content'] = $Barcode_pdf->Output('Barcode.pdf', 'S');
$Barcode_attachment['name'] = 'Barcode.pdf'; // getting pdf file name
$Barcode_attachment['invoice']['mime'] = 'application/pdf';
$Barcode_attachment['mime'] = 'application/pdf';
and then just add $Barcode_attachment to your email .
I'm trying to hide the header page number on the first page using this example I found here. Which only works if I use it with footer-html and doesn't show/hide anything if I use it with header-html. Originally I was trying to augment this solution which also worked using footer-html, but since I couldn't get it to work in the header I kept on searching. I've tried it with and without 'header-center' => '[[page]]' in case using this with header-html caused conflicts. Anyone been able to get this to work in the headers recently? I'm using PHPWKHTMLtoPDF wrapper version 1.2.6-dev if that helps with a up to date version of WKHTMLtoPDF, since the newest version of PHPWKHTMLtoPDF uses namespaces and we're using CodeIgniter 2.x-dev, which doesn't support them (or play well can't remember).
// Create document PDF
$pdf = new $this->wkhtmltopdf;
// Locate WkHtmlToPdf executable for Windows
if( $pdf->getIsWindows() )
{
$pdf->setOptions( array( 'binPath' => 'C:\Program Files\wkhtmltopdf\bin\wkhtmltopdf.exe',
'no-outline',
'encoding' => 'UTF-8',
'margin-top' => 30,
'margin-right' => 20,
'margin-bottom' => 30,
'margin-left' => 20,
// Default page options
'disable-smart-shrinking',
'user-style-sheet' => 'pdf.css',
'header-html' => dirname(__FILE__) . '\..\views\wkhtmltopdf\header.html'
) );
}
// Generate document fields
$docInputs = $this->generate_inputs( $inputs, json_decode( $this->load->file( APPPATH . '/mapping/' . $document['mapping'], TRUE ), TRUE ) );
// Merge document fields into HTML exported Word files
$docHTML = $this->parser->parse( 'docs/' . $document['html'], $docInputs, TRUE );
// Add HTML as page, along with option for page header
$pdf->addPage( $docHTML, array( 'header-center' => '[[page]]',
'header-spacing' => '10',
'header-font-name' => 'Times New Roman'
) );
You need to add the <!DOCTYPE html> to the header file, WKHTMLtoPDF issue #46 for version 0.12
I'm posting this answer because this happened to me and this might also be a reason.
I'v also noticed if you set the header css to this. It will not show the header.
html{
width: 100%;
height: 100%;
}
Make sure you have version with patched qt
I'm trying to add a User Note while programmatically adding a user. I've been working quite successfully from Joomla 3.0 Register user with php script, but am unable to figure out how J32 adds a note - in model notes.php, the save function is commented out, so it's a deadend for me while I figure out all this marvelous new version of the best CMS out there.
Is there some method to do this - an equivalent to registering like $model->addnote,
i couldn't find a method but here is the script i have used within my own plugin. All seems to work correctly
protected function _addNote($vars) {
$now = new JDate();
$now = $now->toSql();
// Create and save the user note
$userNote = (object) array(
'user_id' => $vars['id'],
'catid' => 0,
'subject' => "User Information Update By Proworx",
'body' => "<p>User ".$vars['name']." has been updated to:</p><p>Name: ".$vars['name']."</p><p>Email: ".$vars['email']."</p><p>Password: Not Telling... check proworx</p>",
'state' => 1,
'created_user_id' => 332, //DONT FORGET TO CHANGE THIS VALUE TO YOUR SITES ADMIN
'created_time' => $now
);
$db = JFactory::getDbo();
$db->insertObject('#__user_notes', $userNote, 'id');
}
Reject? I am sure I am not the first that has ran into this issue.
I am trying to create a chart using PHPExcel and the Excel5 library to produce an .xls file of the '95 format.
All goes well except for the creation/save of the chart itself. The file is saved/downloaded/opened without any errors alerted by either, PHPExcel during creation/save, or by Excel during opening the file.
The only real issue is, there is no chart visible within the Excel '95 .xls file created.
I have checked to be sure the MIME type is being set to the '95 .xls format application/vnd.ms-excel. It is.
Here is the code relating to the chart creation, its a little messy currently, but like I said, works like a charm for the 2007 version:
//ADD THE REPORT SUMMARY CHART
$labels = array(
new PHPExcel_Chart_DataSeriesValues('String', "'Report Summary'!C1", null, 1),
new PHPExcel_Chart_DataSeriesValues('String', "'Report Summary'!D1", null, 1)
);
$chrtCols = "'Report Summary'!B2:B$rowNum";
$chrtVals = "'Report Summary'!C2:C$rowNum";
$chrtVals2 = "'Report Summary'!D2:D$rowNum";
$periods = new PHPExcel_Chart_DataSeriesValues('String', $chrtCols, null, $rowNum-1);
$values = new PHPExcel_Chart_DataSeriesValues('Number', $chrtVals, null, $rowNum-1);
$values2 = new PHPExcel_Chart_DataSeriesValues('Number', $chrtVals2, null, $rowNum-1);
$series = new PHPExcel_Chart_DataSeries(
PHPExcel_Chart_DataSeries::TYPE_LINECHART,
PHPExcel_Chart_DataSeries::GROUPING_STANDARD,
array(0,1),
$labels,
array($periods,$periods),
array($values,$values2)
);
$series->setPlotDirection(PHPExcel_Chart_DataSeries::DIRECTION_COL);
$layout = new PHPExcel_Chart_Layout();
$plotarea = new PHPExcel_Chart_PlotArea($layout, array($series));
$chart = new PHPExcel_Chart('sample', null, null, $plotarea);
$chart->setTopLeftPosition('A1', 24, 24);
$chart->setBottomRightPosition('B18', -24);
$actSheet->addChart($chart);
The issue seems to be with the '95 version only as the exact same code works to create a valid 2007 version of the file (using the Excel_2007 class rather than Excel5).
Any thoughts? Are line-charts constructed differently (or labels defined differently) in Excel_07 as compared to Excel_95? Any other declarations in the $series array I should add/modify/delete to get the chart to appear Excel_95?
Yes, I am including $objWriter->setIncludeCharts(TRUE); prior to writing the file.
$rowNum is the last row of data.
PHPExcel only supports charts for the Excel2007 Reader/Writer; that feature has not been written for the Excel5 Reader/Writer
Hello People here is my Google scattered chart code what I am using:
require '/lib/GoogleChart.php';
require '/lib/markers/GoogleChartShapeMarker.php';
require '/lib/markers/GoogleChartTextMarker.php';
$Variance=array();
$Emp_RecFactor=array();
$Emp_Id=array();
//$Emp_FirstName=array();
$EquityGraph=new EquityGraph();
$EquityGraph->Graph();
$DrawGraph=$EquityGraph->DrawGraph;
foreach($DrawGraph as $key=>$value)
{
$Variance[]=$value["Variance"];//for multiple values ,array
$Emp_RecFactor[]=$value["Emp_RecFactor"];//single value
$Emp_Id[]=$value["Emp_Id"];//single value
}
$_GET['Variance']=$Variance;
$_GET['Emp_RecFactor']=$Emp_RecFactor;
print_r($Emp_RecFactor);
$chart = new GoogleChart('lc', 500, 200);
// manually forcing the scale to [0,100]
$chart->setScale(0,100);
// add one line
$data = new GoogleChartData($Variance);
$chart->addData($data);
// customize y axis
$y_axis = new GoogleChartAxis('y');
$y_axis->setDrawTickMarks(false)->setLabels(array(-5,0,5));
$chart->addAxis($y_axis);
// customize x axis
$x_axis = new GoogleChartAxis('x');
$x_axis->setTickMarks(5);
$chart->addAxis($x_axis);
// add a shape marker with a border
$shape_marker = new GoogleChartShapeMarker(GoogleChartShapeMarker::CIRCLE);
$shape_marker->setSize(6);
$shape_marker->setBorder(2);
$shape_marker->setData($data);
$chart->addMarker($shape_marker);
// add a value marker
$value_marker = new GoogleChartTextMarker(GoogleChartTextMarker::VALUE);
$value_marker->setData($data);
$chart->addMarker($value_marker);
//~ header('Content-Type: image/png');
echo $chart->toHtml();
As you can see in the code I have used $Variance array passing to $data now I need to use one more array $Emp_RecFactor and I need to draw a graph between those two...
I also want to add mouse over feature to this so that if someone hovers over the selected point it should display different things for different selected points -how do I do that?
To draw a Google scattered chart between two arrays you have to use code as below
var data = google.visualization.arrayToDataTable([
['Age', 'Array1', 'Array2'],
[8, 12, 15],
[4, 5.5, 0],
[11, 0, 14],
[4, 9, 5],
[3, 3.5, 9],
[6.5, 7, 13]
]);
And it has a default tooltip to show the data while hovering the selected point. We can also customize Tooltip content by using html tags.
To view a working sample for this go to the site jqfaq.com(Sample) and a customization of Tooltip content go to the site jqfaq.com(customizing Tooltip)