Corrupt Word docx (OpenXML) fixed by Libreoffice - how to identify possible root cause? - ms-word

I am trying to identify the root cause of a corrupted Microsoft Word docx, the file being the result of a PDF conversion using commercial software. When trying to open this doc in MS Word, I get an error message saying nothing specific, only that the file is corrupted and cannot be opened.
Now, the same file opens fine in Libreoffice. When saving the file as docx from within Libreoffice, I am also able open it in Word again. There are quite a few differences in the contents of the XML files in the unzipped docx file (checked with a diff tool) compared to the one created by Libreoffice. However, I am not sure which ones exactly would cause the file create by Libreoffice to be uncorrupted.
Also, if I unzip the docx and rezip it again, it also opens fine in Word afterwards. I checked the two files on the binary level using a Hexeditor and there were quite a few differences, but it is rather hard or even impossible to understand what these differences mean.
Has anyone has a similar situation and might be able to shed some light on this? I am not sure where to start. Tks.

Problem was solved by doing a roundtrip conversion using the Apache POI library (poi.apache.org)

Related

Where does VSCode store its Most Recently Used (MRU) list of .NET projects and solutions on Windows?

Where does VSCode store its Most Recently Used (MRU) list of .NET projects and solutions on Windows?
And also is there some open source code to fetch VSCode's MRUs?
I scanned all files in this dir (recursive) C:\Users\pat\AppData\Roaming\Code with no luck
For you it should be in C:\Users\pat\AppData\Roaming\Code\User\globalStorage\state.vscdb; this file is an SQLite database and you can look around for tools that open this kind of file (because it won't be readable as plain text) to see what's inside and decide whether you can sync it across machines (if that's what you're after).
Also reference this answer, there's very useful stuff over there.
Edit: Thanks this is indeed the file I was looking for.
It can be read with the tool SQLitebrowser.
I didn't easily found a .NET library to read the state.vscdb file + we are very reluctant in embedding a whole library in our product for a small feature.
Hopefully state.vscdb contains the MRU file list in clear textual JSON.
So what I did is just open this file as text, and locate the JSON and read it. Clearly it is ugly but JSON shouldn't be crypted anytime soon in such file and if it fails one day, this feature is not critical for us, just a convenient helper for the user.
The JSON to locate looks like:
{"entries":[
{"fileUri":"file:///c%3A/Dir/treeItem.ts"},
{"fileUri":"file:///c%3A/Dir/YourSolution.sln"},
...

Opening Simulink models created in newer versions of MATLAB

I have received a simulink model from one of my students, but as he is using a newer version of MATLAB (8.6) than the one i have installed (8.5) i get an error when i try to open it.
How can i open it without asking him to save in an older format?
If you have a .slx file that you need to convert, the process is a little different. Using a tool like 7Zip, open the .slx file (a .slx is really just a disguised .zip file) so you can edit it without extracting all the files. Go into the "metadata" folder. Edit each of the .xml files in there and change the tags for <cp:version> and <matlabVersion>. Save each and have 7Zip update the archive for you.
Like the other responder said though, if you used any part of your model uses features inherent to the newer version, those components will be broken.
It was actaully quite simple.
I opened the .mdl file in a text editor and search/replaced
8.6->8.5
and 2015b->2015a
Sometimes when doing this an error occurs when opening a model for the first time. After saving it the first time and reopening it this error dissapears.
It should however be noted that if the model contains a new component or if the functionality of a component has been changed this method will not work.
Sigurd

Any method to restore garbled/distorted text file by Matlab?

I got a very weird situation that highly needs your assistance. I appreciate your effort and time in advance.
I have a machine which produces a text file that records some information of the machine's working status such as, the coordinate of the drill head and the rotating speed used at that position. While we examine the text file, it appears to be unreadable because most of the contents are garbled. Please see the attached figure. http://ppt.cc/sA1I
If I open it with UltraEdit I see: http://ppt.cc/TrnV
As you can see some part of the file is readable; however many unrecognizable characters, which should be those numeric values we want.
Two reasons that I believe this problem should be solved by Matlab. First, I am sure this machine has many built-in matlab code inside for analysis purpose. Second, we have a .exe file, which is compiled by Matlab, can restore the garbled text file into arranged and readable format (the values of the coordinates are restored).
We desperately want to see the contents of this file by ourselves. Please kindly provide solution or idea or any direction for me to solve this issue.
Sincerely,
Old question without answer: For the record, a suggestion.
Sounds like a case of Mojibake, a problem with text encoding. Here's how I solved it.
Background: I had text files created on a Mac, others on a Windows, others still on Linux, each in different text encoding. So I got a text editor that would allow me to view the format and to change it. In my case, I used TextMate on MacOS, opened the files, picked the correct encoding upon opening, which sometimes was a Windows format, a Mac format, sometimes a Latin format -- had to use trial and error to figure it out based on a preview this particular piece of software gave me. Once I had the file opened in the correct encoding, I would save it in the utf-8format, which is not platform-specific and allows me to move my text files across various computers.
There may be more scalable methods, but I only had a hundred or so files to deal with, so I opted for the manual method, in order to personally visualize the rendering on screen, and because my files came in different encoding to begin with.

Unable to open PNG file with kview or PictureViewer; opens fine with other viewers

I have a PNG file created using libPNG library. The file opens perfectly on Windows picture viewer and MS Paint, but opening with kview (on Linux RHEL5) or QuickTime PictureViewer (on Windows) fails - the former reports a "libpng read error whereas the latter reports the file as being corrupted. A similar problem is seen when trying to process the PNG using ImageMagick library on Linux. Given that the PNG opens fine on some applications, it doesn't seem that the file is really corrupted; I therefore suspect some problem with version compatibility, but I am not sure. I tried searching the web but couldn't find any information on the root cause or a solution to this problem. Can someone please guide me on this?
Judging from the example image you posted in the comments, the problem is that your PNG lacks the ending IEND chunk -something you can test by opening it with tweakpng and inspecting the structure visually, or choosing "Check Validity-F5". It is somewhat predictable that those kind of PNG are displayed by some viewers and rejected by others.
If you are using libpng, it seems you forgot to call png_write_end()

Error when executing batch file from a .CHM file

I have a CHM help file that has a few clickable links to powerpoint presentations which are resting in the same directory. However, when I click the link from the CHM file, I get the following error:
Unable to start TestCase-play.bat
where TestCase-play.bat runs pptview.exe and opens a powerpoint presentation both of which are also in the same directory with all required libraries. I know CHM files work with external links as long as they are in the same directory, but is there any reason a BAT file won't be executed? And if so, is there a way around this?
Since CHM files are very limited in what you can do, we migrated our documentation to HTML so we could put in flash demos and embed PPT slides for certain topics. Doesn't really answer my original question, but even if I did solve it, I think this is a better route to go for help pages.