mPDF: Creating more pdf files in one script throws an error "Undefined offset: -1" in mpdf\src\CssManager.php - mpdf

This works:
$mpdf = new \Mpdf\Mpdf();
$mpdf->WriteHTML($html1);
$mpdf->Output("file1.pdf","F");
But I want to create two pdf files in one script.
This doesn't work:
$mpdf = new \Mpdf\Mpdf();
$mpdf->WriteHTML($html1);
$mpdf->Output("file1.pdf","F");
$mpdf = new \Mpdf\Mpdf();
$mpdf->WriteHTML($html2);
$mpdf->Output("file2.pdf","F");
It throws an error "Undefined offset: -1"
in file: ... mpdf\src\CssManager.php
Do I have to reset it after first output? How?
Thank you.

My workaround:
Into mpdf/mpdf/src/CssManager.php insert before line 1510:
$this->tbCSSlvl = $this->tbCSSlvl==0 ? 1 : $this->tbCSSlvl; // BUG REPAIR

Related

I imported a pokemon project to gmx

// but the code is throwing unexpected terminal operator new
function MovePokemon(argument0, argument1) {
old = argument0;
new = argument1;
TPartyID = global.PartyID[old]
global.PartyID[old] = global.PartyID[new]
global.PartyID[new] = TPartyID;
new is a keyword in the current versions of GameMaker, so you'll need to rename that variable (say, to _new).
The project in question may leave some to be desired given the complete absence of local variable declarations (var).
Try use this code in your script to avoid use "new"
function MovePokemon(argument0, argument1) {
TPartyID = global.PartyID[argument0]
global.PartyID[argument0] = global.PartyID[argument1]
global.PartyID[argument1] = TPartyID;

How to resolve an error with PhpExcel in CodeIgniter to read the date in Excel file?

//load the excel library
$this->load->library('excel');
//read file from path
$objPHPExcel = PHPExcel_IOFactory::load($file);
//get only the Cell Collection
$cell_collection = $objPHPExcel->getActiveSheet()->getCellCollection();
//extract to a PHP readable array format
foreach ($cell_collection as $cell) {
$column = $objPHPExcel->getActiveSheet()->getCell($cell)->getColumn();
$row = $objPHPExcel->getActiveSheet()->getCell($cell)->getRow();
$data_value = $objPHPExcel->getActiveSheet()->getCell($cell)->getValue();
//header will/should be in row 1 only. of course this can be modified to suit your need.
if ($row == 1) {
$header[$row][$column] = $data_value;
} else {
$arr_data[$row][$column] = $data_value;
}
}
This is my reader code. I'm not able to read the date in my Excel file using this code; it's returning the code like 030567 some thing.
My Excel file has the date value but this code is not returning the date. I don't know how to resolve this issue.
You need to use format like below code:
getCellByColumnAndRow($col, $row)->getValue())->format('m/d/Y');
Hope this will resolve your problem.
Or you can also try this:
$data_value = $objPHPExcel->getActiveSheet()->getCell($cell)->getValue();
$phpDateTimeObject = PHPExcel_Shared_Date::ExcelToPHPObject($data_value);
echo phpDateTimeObject->format('Y-m-d');

AVAssetExportSession add meta data after recording ends

The use case is like this: A video is recorded and saved at a temporary location using AVCaptureFileOutput. After the recording is completed some meta data is to be added to this video and saved with a new filename at a new location.
The recording part is working with the file getting stored at the temporary location. Now I have to rename it, add meta data and save it again to a different location.
1) Can I edit the meta data within the:
- (void)captureOutput:(AVCaptureFileOutput *)captureOutput didFinishRecordingToOutputFileAtURL:(NSURL *)outputFileURL fromConnections:(NSArray *)connections error:(NSError *)error;
delagate method?
2) My second approach was to use AVAssetExportSession to do this.
AVAssetExportSession *exportSession = [[AVAssetExportSession alloc] initWithAsset:asset presetName:AVAssetExportPresetMediumQuality];
exportSession.outputFileType = AVFileTypeQuickTimeMovie;
exportSession.metadata = NEW ARRAY OF METADATA;
NSString* outputPath = [[PLFileManager sharedFileManager] pathForAsset:_newAsset];
NSURL* url = [NSURL URLWithString:outputPath];
exportSession.outputURL = url;
[[NSFileManager defaultManager] removeItemAtURL:url error:nil];
[exportSession exportAsynchronouslyWithCompletionHandler:^(void){
NSLog(#"Exported to [%#] %#", exportSession.outputURL, exportSession.error);
}];
How ever with this approach I am getting the following error:
Exported to [///var/mobile/Applications/7F9BC121-6F58-436E-8DBE-33D8BC1A4D79/Documents/Temp/final.mov] Error Domain=AVFoundationErrorDomain Code=-11800 "The operation could not be completed" UserInfo=0x1555f440 {NSLocalizedDescription=The operation could not be completed, NSUnderlyingError=0x1555c7a0 "The operation couldn’t be completed. (OSStatus error -12780.)", NSLocalizedFailureReason=An unknown error occurred (-12780)}
Can someone tell me what I am doing wrong here? Or is there a better way to do this?
Ok I figured out what I was doing wrong. Instead of:
NSURL* url = [NSURL URLWithString:outputPath];
I had to use:
NSURL* outputUrl = [NSURL fileURLWithPath:outputPath];
Expanation

Undeclared namespace with o:allowincell in docx4j Differencer.diff() call

When comparing the results of a document transformation process to the original with docx4j, we're getting the following error for one of our test cases:
com.topologi.diffx.xml.UndeclaredNamespaceException: The namespace URI "urn:schemas-microsoft-com:office:office for allowincell" has not been mapped to any prefix.
I eliminated the possibility of errors introduced by the tranformation process by comparing the original document to itself using this method (based on this answer):
private static final String compareToSelf( File fileToCompare ) throws Docx4JException {
WordprocessingMLPackage olderPackage = WordprocessingMLPackage.load( fileToCompare );
WordprocessingMLPackage newerPackage = WordprocessingMLPackage.load( fileToCompare );
Body newerBody = newerPackage.getMainDocumentPart().getJaxbElement().getBody();
Body olderBody = olderPackage.getMainDocumentPart().getJaxbElement().getBody();
java.io.StringWriter sw = new java.io.StringWriter();
javax.xml.transform.stream.StreamResult result = new javax.xml.transform.stream.StreamResult(sw);
Calendar changeDate = null;
Differencer pd = new Differencer();
pd.setRelsDiffIdentifier("blagh"); // not necessary in this case
pd.diff( newerBody, olderBody, result, "someone", changeDate,
newerPackage.getMainDocumentPart().getRelationshipsPart(),
olderPackage.getMainDocumentPart().getRelationshipsPart() );
return sw.toString();
}
Stack trace:
com.topologi.diffx.xml.UndeclaredNamespaceException: The namespace URI "urn:schemas-microsoft-com:office:office for allowincell" has not been mapped to any prefix.
at com.topologi.diffx.xml.NSAwareXMLWriter.getQName(NSAwareXMLWriter.java:604)
at com.topologi.diffx.xml.NSAwareXMLWriter.attribute(NSAwareXMLWriter.java:527)
at com.topologi.diffx.event.impl.AttributeEventNSImpl.toXML(AttributeEventNSImpl.java:244)
at com.topologi.diffx.format.SmartXMLFormatter.format(SmartXMLFormatter.java:212)
at com.topologi.diffx.sequence.EventSequence.format(EventSequence.java:349)
at com.topologi.diffx.Docx4jDriver.diff(Docx4jDriver.java:230)
at org.docx4j.diff.Differencer.diffWorker(Differencer.java:320)
at org.docx4j.diff.Differencer.diff(Differencer.java:298)
at exec.DocxCompareTest.compareToSelf(DocxCompareTest.java:212)
at exec.DocxCompareTest.handleInputFile(DocxCompareTest.java:124)
at exec.ValidationTest.execute(ValidationTest.java:52)
at exec.BtbRoundtripTest.main(BtbRoundtripTest.java:13)
java.lang.NullPointerException
at org.docx4j.diff.Differencer.diffWorker(Differencer.java:377)
at org.docx4j.diff.Differencer.diff(Differencer.java:298)
at exec.DocxCompareTest.compareToSelf(DocxCompareTest.java:212)
at exec.DocxCompareTest.handleInputFile(DocxCompareTest.java:124)
at exec.ValidationTest.execute(ValidationTest.java:52)
at exec.BtbRoundtripTest.main(BtbRoundtripTest.java:13)
I've unzipped the *.docx file and the o:allowincell seems to be properly mapped with xmlns:o="urn:schemas-microsoft-com:office:office" in the <w:document> tag of the contained document.xml.
Test document can be dowloaded from here: https://docs.google.com/open?id=0B6_h2TfqvEdeZE43X3RSWnFIZHc
Any ideas on how to resolve this issue?
In Docx4jDriver at line 192 and 206 there is:
e.setAttributeNS("http://www.w3.org/2000/xmlns/", "xmlns:w",
"http://schemas.openxmlformats.org/wordprocessingml/2006/main");
You probably need to add xmlns:o. Ultimately, that code needs to be improved to add all relevant namespaces automatically.

PHPExcel : Error while reading cells

I'm trying to read a XLSX sheet with PHPExcel, and feed a MySQL table with its content.
My problem is that while reading the XLSX, I get the following error message :
Fatal error: Uncaught exception 'Exception' with message 'Cell coordinate must not be absolute.' in C:\Program Files\EasyPHP-5.3.3\www\alliance_run\phpexcel\Classes\PHPExcel\Worksheet.php:954 Stack trace: #0 C:\Program Files\EasyPHP-5.3.3\www\alliance_run\__essai_DB.php(22): PHPExcel_Worksheet->getCell('$col.$row') #1 {main} thrown in C:\Program Files\EasyPHP-5.3.3\www\alliance_run\phpexcel\Classes\PHPExcel\Worksheet.php on line 954
Here is my code :
mysql_connect("localhost", "root", "");
mysql_select_db("alliance_run");
// vidage de la table test_equipement
$query1 ="TRUNCATE TABLE `test_equipement` ";
$resultat = mysql_query($query1);
require_once 'phpexcel/Classes/PHPExcel.php';
$objReader = PHPExcel_IOFactory::createReader('Excel2007');
$objReader->setReadDataOnly(true);
$objPHPExcel = $objReader->load("edf/equipement.xlsx");
$objWorksheet = $objPHPExcel->getActiveSheet();
$highestRow = $objWorksheet->getHighestRow();
$highestColumn = $objWorksheet->getHighestColumn();
$highestColumnIndex = PHPExcel_Cell::columnIndexFromString($highestColumn);
for ($row = 1; $row <= $highestRow; ++$row) {
for ($col = 1; $col <= $highestColumnIndex; ++$col) {
$str.=$objPHPExcel->getActiveSheet()->getCell('$col.$row')->getValue().'\\';
}
$strs=explode("\\",$str);
$query ="INSERT INTO test_equipement (numero_serie, code_site, code_produit, tag, date_installation, date_acceptation, code_fournisseur, client) VALUES ('".
$strs[0]."','". // numero_serie
$strs[1]."','".// code_site
$strs[2]."','".// code_produit
$strs[3]."','".// tag
$strs[4]."','".// date_installation
$strs[5]."','".// date_acceptation
$strs[6]."','".// code_fournisseur
$strs[7]."')";// client
mysql_query($query);
}
The problem seems to be on this line :
$str.=$objPHPExcel->getActiveSheet()->getCell('$col.$row')->getValue().'\\';
I've tried the different following codes, without success :
$str.=$objPHPExcel->getActiveSheet()->getCell($col$row)->getValue().'\\';
$str.=$objPHPExcel->getActiveSheet()->getCell('$col.$row')->getValue().'\\';
$str.=$objPHPExcel->getActiveSheet()->getCell("$col.$row")->getValue().'\\';
$str.=$objPHPExcel->getActiveSheet()->getCell($col.$row)->getValue().'\\';
$str.=$objPHPExcel->getActiveSheet()->getCell('$col$row')->getValue().'\\';
$str.=$objPHPExcel->getActiveSheet()->getCell("$col$row")->getValue().'\\';`
I precise that my XSLX sheet is clean.
Did someone encounter the problem, and solved it ?
Thanks.
Your loop tries to get the cell 11, and 12, ... But as far as I remember, the getCell() method needs values like A1,A2 !
So you should use the method getCellByColumnAndRow($col,$row).
your code has
$str.=$objPHPExcel->getActiveSheet()->getCell('$col.$row')->getValue()
you should have double quotes for the values of $col and $row to be used. otherwise you use '$col.$row' as a string
it should be
$str.=$objPHPExcel->getActiveSheet()->getCell("$col.$row")->getValue()

Resources