Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
menu search
person
Welcome To Ask or Share your Answers For Others

Categories

I'm trying to generate a simple PDF file (text only) programmatically. With most PDF reader the file looks exactly like I want but some PDF readers won't open the file and report it as damaged. I've removed every elements from the file leaving only the first void page to debug the code and found the problem but without any results, it's still recognized as damaged.

This is the raw PDF data:

%PDF-1.4
1 0 obj
<< /Type /Catalog
   /Pages 2 0 R
>>
endobj
2 0 obj
<< /Type /Pages
   /Count 1
   /Kids [ 3 0 R ]
>>
endobj
3 0 obj
<< /Type /Page
   /Parent 2 0 R
   /Resources <<
   >>
   /MediaBox [ 0 0 595 842 ]
>>
endobj
xref
0 4
0000000000 65536 f 
0000000010 00000 n 
0000000067 00000 n 
0000000138 00000 n 
trailer
<< /Size 4
   /Root 1 0 R
>>
startxref
248
%%EOF

Can anyone tell me what's wrong with this PDF?

Thanks in advance.

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
336 views
Welcome To Ask or Share your Answers For Others

1 Answer

Per spec /Resources is required although it can be empty. Adding /Resources <<>> to object 2 or 3 should suffice.

EDIT

The PDF below with the updated /Resources entry passes Acrobat's preflight when I run it. Do you get a preflight error message?

%PDF-1.4
1 0 obj
<< /Type /Catalog
   /Pages 2 0 R
>>
endobj
2 0 obj
<< /Type /Pages
   /Count 1
   /Kids [ 3 0 R ]
>>
endobj
3 0 obj
<< /Type /Page
   /Parent 2 0 R
   /MediaBox [ 0 0 595 842 ]
   /Resources <<>>
>>
endobj
xref
0 4
0000000000 65536 f 
0000000010 00000 n 
0000000067 00000 n 
0000000138 00000 n 
trailer
<< /Size 4
   /Root 1 0 R
>>
startxref
243
%%EOF

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
...