Note: "opening in windows" is a non-statement. You cannot "open" a PDF in Windows, you need certain software to do so. Presumably, you tried using Acrobat Reader or something alike (the error message you quote is from Acrobat Reader).
It works in Mac OS X Preview, but then again that doesn't really tell us very much. Preview is written by Apple, and it's not a really conforming PDF reader (much to the dismay of anyone using, for example, transparency or color spaces). You did not provide an image of what your document is supposed to look like; is it anything like this?
But it does not open in Acrobat X.(a) Inspecting the PDF offsets -- the most likely place for an error -- I found the xref
offsets are wrong from 11 0 obj
onwards. This leads to a wrong offset of +89 bytes for all next objects, up to and including the ending startxref 6616
, which IMO should be 6527
.
I manually fixed the 34 wrong offsets by comparing the position of every X 0 obj
with a hex editor, and saved with cr
line endings. I got an error from my own inspecting tool:
The keyword stream that follows the stream dictionary should be followed by either a carriage return and a line feed or by just a line feed, and not by a carriage return alone. (PDF Reference 1.7, §3.2.7)
so I resaved with lf
line endings. No errors, it shows correctly in Preview but still not in Acrobat X.
I noticed the /Length
keys for objects 16 and 17, the Page Contents objects, were off as well. After correcting them to 1887
and 648
, respectively, it still displays in Preview but still not in Acrobat X.
The problem appears to lie in these contents. Requesting for an Inventory shows the error message: "An error occurred while parsing a contents stream. Unable to analyze the PDF file.", and browsing the internal PDF structure I get to see a first handful of text formatting commands from 16 0 obj
but they stop at the 15th command:
/CS1 cs 0 scn
and the next command, /TT1 1 Tf
, never gets seen.
Ooo-kay. Checking the parameters for scn
, I see their number depends on the color space set using cs
; and there is your problem.
Both 11 0 obj
and 12 0 obj
set color spaces, and they both set it to /DeviceRGB
. So the number of parameters for /CS1
(defined in 11 0 obj
) is wrong -- you only supply one. It's safe to assume you meant this one to be /DeviceGray
, and lo and behold, after that final change I got to see this in Acrobat X:
and a proper Inventory and fully browsable PDF structure.
There were lots of minor problems with this file, but the PDF format in itself is quite resilient. The bad offsets, and possibly the lengths, may have been silently corrected (the PDF specification allows that) but the bad parameters for the color space were killing it.
(a) Clarification after re-reading: it does open in Acrobat but silently shows a blank page only; no error message of any kind.
Addition
This made me think: was the /DeviceRGB
the only cause of it failing in Acrobat X? No: after reloading the original PDF and changing just that one line, Acrobat says the file is damaged beyond repair. So all that extra checking I did wasn't for nothing, fortunately.