docxlibreofficelibreoffice-writer

Recover .docx file from 'SAXParseException: "No namespace defined for pic"'


I cannot open a .docx file that I stored in a USB pendrive. I get following error and LibreOffice doesn't open the document:

File format error found at 
SAXParseException: "No namespace defined for pic"
SAXParseException: '[word/document.xml line 2]: Namespace prefix pic on txbx is not defined
', Stream 'word/document.xml', Line 2, Column 30767(row,col).

Is there any way to recover the file?


Solution

  • Decompress the .docx file. If you don't know how to do it, check it here:

    https://superuser.com/a/1356829/707698

    In the decompressed directory, look for the file word/document.xml and open it with a text editor. In the second line you'll see something like:

    <w:document xmlns:o="urn:schemas-microsoft-com:office:office" 
    xmlns:r="http://schemas.openxmlformats.org/officeDocument/2006/relationships" 
    xmlns:v="urn:schemas-microsoft-com:vml" 
    xmlns:w="http://schemas.openxmlformats.org/wordprocessingml/2006/main" 
    xmlns:w10="urn:schemas-microsoft-com:office:word" 
    xmlns:wp="http://schemas.openxmlformats.org/drawingml/2006/wordprocessingDrawing" 
    xmlns:wps="http://schemas.microsoft.com/office/word/2010/wordprocessingShape" 
    xmlns:wpg="http://schemas.microsoft.com/office/word/2010/wordprocessingGroup" 
    xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" 
    xmlns:wp14="http://schemas.microsoft.com/office/word/2010/wordprocessingDrawing" 
    xmlns:w14="http://schemas.microsoft.com/office/word/2010/wordml" 
    mc:Ignorable="w14 wp14">
    

    You have to include following attribute in that statement:

    xmlns:pic="http://schemas.openxmlformats.org/drawingml/2006/picture"
    

    After that you'll have something like this:

    <w:document xmlns:o="urn:schemas-microsoft-com:office:office" 
    xmlns:r="http://schemas.openxmlformats.org/officeDocument/2006/relationships" 
    xmlns:v="urn:schemas-microsoft-com:vml" 
    xmlns:w="http://schemas.openxmlformats.org/wordprocessingml/2006/main" 
    xmlns:w10="urn:schemas-microsoft-com:office:word" 
    xmlns:wp="http://schemas.openxmlformats.org/drawingml/2006/wordprocessingDrawing" 
    xmlns:wps="http://schemas.microsoft.com/office/word/2010/wordprocessingShape" 
    xmlns:wpg="http://schemas.microsoft.com/office/word/2010/wordprocessingGroup" 
    xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" 
    xmlns:wp14="http://schemas.microsoft.com/office/word/2010/wordprocessingDrawing" 
    xmlns:w14="http://schemas.microsoft.com/office/word/2010/wordml" 
    xmlns:pic="http://schemas.openxmlformats.org/drawingml/2006/picture" 
    mc:Ignorable="w14 wp14">
    

    Now you just need to rebuild the .docx file from the decompressed directory. If you don't know how to do it, check it here:

    https://superuser.com/a/1356829/707698