質問

I am trying to create a table in pdf using PDF codes . I have successfully created a table and its working fine in LinuX(Ubuntu) but when am trying to opening in windows its showing me an error message that "the file has been damaged".Here is my edited code,

    %PDF-1.5
%âãÏÓ
1 0 obj 
<<
/PageLayout /OneColumn
/MarkInfo 
<<
/Marked true
>>
/Outlines 2 0 R
/Lang <feff0045004e002d00550053>
/Pages 3 0 R
/StructTreeRoot 4 0 R
/Type /Catalog
>>
endobj 
2 0 obj 
<<
/First 5 0 R
/Type /Outlines
/Count 1
/Last 5 0 R
>>
endobj 
3 0 obj 
<<
/Kids [6 0 R]
/Type /Pages
/Count 1
>>
endobj 
4 0 obj 
<<
/ParentTree 7 0 R
/RoleMap 8 0 R
/ParentTreeNextKey 1
/K 9 0 R
/Type /StructTreeRoot
>>
endobj 
5 0 obj 
<<
/Title (Example table)
/Parent 2 0 R
/A 10 0 R
>>
endobj 
6 0 obj 
<<
/CropBox [0.0 0.0 612.0 792.0]
/Rotate 0
/StructParents 0
/Parent 3 0 R
/Resources 
<<
/ColorSpace 
<<
/CS1 11 0 R
/CS0 12 0 R
>>
/Font 
<<
/TT2 13 0 R
/TT1 14 0 R
/TT0 15 0 R
>>
>>
/MediaBox [0.0 0.0 612.0 792.0]
/Type /Page
/Contents [16 0 R 17 0 R]
>>
endobj 
9 0 obj 
<<
/P 4 0 R
/K [18 0 R 19 0 R 20 0 R 21 0 R]
/S /Sect
>>
endobj 
7 0 obj 
<<
/Nums [0 22 0 R]
>>
endobj 
8 0 obj 
<<
/Subscript /Span
/Diagram /Figure
/Strikeout /Span
/Outline /Span
/DropCap /Figure
/InlineShape /Figure
/Footnote /Note
/Annotation /Span
/Underline /Span
/Superscript /Span
/Chart /Figure
/Endnote /Note
/TextBox /Art
>>
endobj 
10 0 obj 
<<
/D [6 0 R /XYZ 72 720 0.0]
/S /GoTo
>>
endobj 
16 0 obj 
<<
/Length 1991
>>
stream
BT
/H1 <</MCID 0 >>BDC 
/CS0 cs 0.212 0.373 0.569  scn
/TT0 1 Tf
0.002 Tw 14.04 0 0 14.04 72 682.8 Tm
[(E)-3(x)4(a)-3(m)1(p)-1(le)10( t)6(a)-3(b)1(le)]TJ
0 Tw 6.496 0 Td
( )Tj
EMC 
/P <</MCID 1 >>BDC 
/CS1 cs 0  scn
/TT1 1 Tf
0.001 Tc -0.001 Tw 15.96 0 0 15.96 72 664.44 Tm
[(T)-1(hi)-3(s)1( )1(i)-3(s)1( )1(a)-1(n e)3(x)-2(a)-1(m)3(pl)-3(e)3( )-7(o)2(f)-2( )1(a)-1( da)-1(t)-2(a)-1( t)-2(a)-1(bl)-3(e)3(.)]TJ
0 Tc 0 Tw 13.789 0 Td
( )Tj
EMC 
ET
/TH <</MCID 3 >>BDC 
/CS0 cs 0.553 0.702 0.886  scn
84.84 632.64 76.68 14.88 re
f*
84.84 591.36 5.16 41.28 re
f*
156.36 591.36 5.16 41.28 re
f*
84.84 576.48 76.68 14.88 re
f*
EMC 
/P <</MCID 4 >>BDC 
90 618 66.36 14.64 re
f*
BT
/CS1 cs 0  scn
/TT2 1 Tf
0.004 Tc -0.004 Tw 12 0 0 12 90 621.24 Tm
[(D)4(is)3(a)8(b)1(il)10(it)1(y)8( )]TJ
ET
/CS0 cs 0.553 0.702 0.886  scn
90 591.36 66.36 26.64 re
f*
BT
/CS1 cs 0  scn
/TT2 1 Tf
-0.004 Tc 0.004 Tw 12 0 0 12 90 606.6 Tm
[(C)-5(at)-7(e)-1(go)-6(r)-9(y)]TJ
0 Tc 0 Tw ( )Tj
ET
EMC 
/TH <</MCID 7 >>BDC 
/CS0 cs 0.553 0.702 0.886  scn
162 625.32 71.76 22.2 re
f*
162 598.68 5.16 26.64 re
f*
228.6 598.68 5.16 26.64 re
f*
162 576.48 71.76 22.2 re
f*
EMC 
/P <</MCID 8 >>BDC 
167.16 598.68 61.44 26.64 re
f*
BT
/CS1 cs 0  scn
/TT2 1 Tf
0.003 Tc -0.003 Tw 12 0 0 12 167.16 613.92 Tm
[(P)5(a)7(r)-2(ti)-1(c)1(i)9(pa)7(nts)]TJ
0 Tc 0 Tw 4.95 0 Td
( )Tj
ET
EMC 
/TH <</MCID 11 >>BDC 
/CS0 cs 0.553 0.702 0.886  scn
234.24 632.64 71.52 14.88 re

f*
234.24 591.36 5.16 41.28 re
f*
300.6 591.36 5.16 41.28 re
f*
234.24 576.48 71.52 14.88 re
f*
EMC 
/P <</MCID 12 >>BDC 
239.4 618 61.2 14.64 re
f*
BT
/CS1 cs 0  scn
/TT2 1 Tf
0.004 Tc -0.004 Tw 12 0 0 12 239.4 621.24 Tm
[(B)5(a)8(llo)2(t)1(s)13( )]TJ
ET
/CS0 cs 0.553 0.702 0.886  scn
239.4 591.36 61.2 26.64 re
f*
BT
/CS1 cs 0  scn
/TT2 1 Tf
-0.003 Tc 0.003 Tw 12 0 0 12 239.4 606.6 Tm
[(C)-4(o)-5(mp)-6(l)-7(et)-6(ed)]TJ
0 Tc 0 Tw 4.55 0 Td
( )Tj
ET
EMC 

endstream 
endobj 
17 0 obj 
<<
/Length 707
>>
stream

/P <</MCID 42 >>BDC 
q
84.84 550.56 76.68 25.44 re
W n
BT
/TT1 1 Tf
-0.001 Tc 0.001 Tw 11.04 0 0 11.04 90 565.56 Tm
[(Blin)2(d)]TJ
ET
Q
q
84.84 550.56 76.68 25.44 re
W n
BT
/TT1 1 Tf
11.04 0 0 11.04 112.56 565.56 Tm
( )Tj
ET
EMC 
/P <</MCID 46 >>BDC 
Q
q
162 550.56 71.76 25.44 re
W n
BT
/TT1 1 Tf
11.04 0 0 11.04 195.12 565.56 Tm
(5)Tj
ET
Q
q
162 550.56 71.76 25.44 re
W n
BT
/TT1 1 Tf
11.04 0 0 11.04 200.64 565.56 Tm
( )Tj
ET
EMC 
/P <</MCID 50 >>BDC 
Q
q
234.24 550.56 71.519 25.44 re
W n
BT
/TT1 1 Tf
11.04 0 0 11.04 267.24 565.56 Tm
(1)Tj
ET
Q
q
234.24 550.56 71.519 25.44 re
W n
BT
/TT1 1 Tf
11.04 0 0 11.04 272.76 565.56 Tm
( )Tj
ET
EMC 

endstream 
endobj 
12 0 obj /DeviceRGB
endobj 
11 0 obj /DeviceRGB
endobj 
15 0 obj 
<<
/BaseFont /Times-Roman
/Subtype /Type1
/Type /Font
/Encoding /WinAnsiEncoding
>>
endobj 
14 0 obj 
<<
/BaseFont /Helvetica
/Subtype /Type1
/Type /Font
/Encoding /WinAnsiEncoding
>>
endobj 
13 0 obj 
<<
/BaseFont /Courier
/Subtype /Type1
/Type /Font
/Encoding /WinAnsiEncoding
>>
endobj 
18 0 obj 
<<
/Pg 6 0 R
/P 9 0 R
/K 0
/S /H1
>>
endobj 
19 0 obj 
<<
/Pg 6 0 R
/P 9 0 R
/K 1
/S /P
>>
endobj 
20 0 obj 
<<
/P 9 0 R
/A 23 0 R
/K [24 0 R 25 0 R]
/S /Table
>>
endobj 
21 0 obj 
<<
/Pg 6 0 R
/P 9 0 R
/K 144
/S /P
>>
endobj 
22 0 obj [18 0 R 19 0 R null 26 0 R 27 0 R null null 28 0 R 29 0 R null null 30 0 R 31 0 R null null null null null null null null null 24 0 R null null null null null null null null null null null null null null null null null null null 32 0 R null null null 33 0 R null null null 34 0 R null null null null null null null null null null null null null 25 0 R null null null null null null null null null null null null null null null null null null null null null null null null null null null null null null null 35 0 R null null null 36 0 R null null null 37 0 R null null null null null null null null null null null null null 38 0 R null null null null null null null null null null null null null null null null null null null null null null null null null 21 0 R]
endobj 
23 0 obj 
<<
/O /Layout
/Placement /Block
/BBox [84.11 446.51 545.89 648.25]
>>
endobj 
24 0 obj 
<<
/Pg 6 0 R
/P 20 0 R
/K [26 0 R 28 0 R 30 0 R]
/S /TR
>>
endobj 
25 0 obj 
<<
/Pg 6 0 R
/P 20 0 R
/K [39 0 R 40 0 R 41 0 R]
/S /TR
>>
endobj 
38 0 obj 
<<
/Pg 6 0 R
/P 20 0 R
/K [42 0 R 43 0 R 44 0 R]
/S /TR
>>
endobj 
26 0 obj 
<<
/Pg 6 0 R
/P 24 0 R
/K [27 0 R]
/S /TH
>>
endobj 
27 0 obj 
<<
/Pg 6 0 R
/P 26 0 R
/K 4
/S /P
>>
endobj 
28 0 obj 
<<
/Pg 6 0 R
/P 24 0 R
/K [29 0 R]
/S /TH
>>
endobj 
29 0 obj 
<<
/Pg 6 0 R
/P 28 0 R
/K 8
/S /P
>>
endobj 
30 0 obj 
<<
/Pg 6 0 R
/P 24 0 R
/K [11 31 0 R]
/S /TH
>>
endobj 
31 0 obj 
<<
/Pg 6 0 R
/P 30 0 R
/K 12
/S /P
>>
endobj 
32 0 obj 
<<
/Pg 6 0 R
/P 39 0 R
/K 42
/S /P
>>
endobj 
33 0 obj 
<<
/Pg 6 0 R
/P 40 0 R
/K 46
/S /P
>>
endobj 
34 0 obj 
<<
/Pg 6 0 R
/P 41 0 R
/K 50
/S /P
>>
endobj 
35 0 obj 
<<
/Pg 6 0 R
/P 42 0 R
/K 96
/S /P
>>
endobj 
36 0 obj 
<<
/Pg 6 0 R
/P 43 0 R
/K 100
/S /P
>>
endobj 
37 0 obj 
<<
/Pg 6 0 R
/P 44 0 R
/K 104
/S /P
>>
endobj 
39 0 obj 
<<
/P 25 0 R
/K 32 0 R
/S /TD
>>
endobj 
40 0 obj 
<<
/P 25 0 R
/K 33 0 R
/S /TD
>>
endobj 
41 0 obj 
<<
/P 25 0 R
/K 34 0 R
/S /TD
>>
endobj 
42 0 obj 
<<
/P 38 0 R
/K 35 0 R
/S /TD
>>
endobj 
43 0 obj 
<<
/P 38 0 R
/K 36 0 R
/S /TD
>>
endobj 
44 0 obj 
<<
/P 38 0 R
/K 37 0 R
/S /TD
>>
endobj xref
0 45
0000000000 65535 f 
0000000015 00000 n 
0000000190 00000 n 
0000000263 00000 n 
0000000322 00000 n 
0000000430 00000 n 
0000000500 00000 n 
0000000849 00000 n 
0000000889 00000 n 
0000000775 00000 n 
0000001130 00000 n 
0000004027 00000 n 
0000003999 00000 n 
0000004203 00000 n 
0000004130 00000 n 
0000004055 00000 n 
0000001190 00000 n 
0000003237 00000 n 
0000004274 00000 n 
0000004329 00000 n 
0000004383 00000 n 
0000004460 00000 n 
0000004516 00000 n 
0000005296 00000 n 
0000005384 00000 n 
0000005461 00000 n 
0000005615 00000 n 
0000005678 00000 n 
0000005733 00000 n 
0000005796 00000 n 
0000005851 00000 n 
0000005917 00000 n 
0000005973 00000 n 
0000006029 00000 n 
0000006085 00000 n 
0000006141 00000 n 
0000006197 00000 n 
0000006254 00000 n 
0000005538 00000 n 
0000006311 00000 n 
0000006362 00000 n 
0000006413 00000 n 
0000006464 00000 n 
0000006515 00000 n 
0000006566 00000 n 
trailer

<<
/Root 1 0 R
/Size 45
>>
startxref
6616
%%EOF
役に立ちましたか?

解決

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?

sample pdf screen grab

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:

corrected PDF

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.

ライセンス: CC-BY-SA帰属
所属していません StackOverflow
scroll top