Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

XML error; Location: Part: /word/document.xml, Line:4, Column:2888 #1484

Open
zubairsultan786 opened this issue Oct 9, 2018 · 2 comments
Open

Comments

@zubairsultan786
Copy link

Hi troosan,
I am facing same error "Document cannot open because problems with the content"
Location: Part: /word/document.xml line 2 column 2694.

$zip = new \PhpOffice\PhpWord\Shared\ZipArchive();
$setting = new \PhpOffice\PhpWord\Settings();

$setting->setOutputEscapingEnabled(true); 
//This is the main document in a .docx file.
$fileToModify = 'word/document.xml';
//$file = "Full IB Diploma Predicted Score Form A-G.docx";
$temp_file = 'results/re'.date('Ymdhis').'.docx';
copy($file,$temp_file);

if ($zip->open($temp_file) === TRUE) {
    //Read contents into memory
    $oldContents = $zip->getFromName($fileToModify);

    //echo $oldContents;
	
	$Contents = preg_replace($patterns, $replace, $oldContents);
	$Contents1 = preg_replace($patterns1, $replace1, $Contents); 
	  
		echo '<br><br>'.$Contents1;
    //Delete the old...
    $zip->deleteName($fileToModify);
    //Write the new...
    $zip->addFromString($fileToModify, $Contents1);
    //And write back to the filesystem.
    $return =$zip->close();
    If ($return==TRUE){
        echo "Success!";
    }
} else {
    echo 'failed';
}

I added Settings::setOutputEscapingEnabled(true); but stills same error.

Please help me
error

@undereyes
Copy link

I have the same problem, any solution?

@ilyasbat
Copy link

solution?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

No branches or pull requests

3 participants