0

I wrote a program that creates a pdf file from scratch. The output is this:

%PDF-1.3
1 0 obj
<< /Type /Catalog
/Pages 2 0 R
/Outlines 20 0 R
>>
endobj
3 0 obj
<< /Type /Font
/Subtype /Type1
/Name /Fn1
/BaseFont /Arial.BoldItalic
/Encoding /UTF8
>>
endobj
2 0 obj
<< /Type /Pages
/Count 2
/Kids [4 0 R 5 0 R ]>>
endobj
4 0 obj
<< /Type /Page
/Parent 2 0 R
/Resources << /ProcSet [/PDF /Text] /Font <</Fn1 3 0 R>> >>
/MediaBox [0 0 595.2 842]
/Contents 5 0 
BT
/Fn1 24 Tf
100 400 Td
(Test) Tj
ET
>>
endobj
5 0 obj
<< /Type /Page
/Parent 2 0 R
/Resources << /ProcSet [/PDF /Text] /Font <</Fn1 3 0 R>> >>
/MediaBox [0 0 595.2 842]
/Contents 5 0 
BT
/Fn1 24 Tf
100 400 Td
(Test2) Tj
ET
>>
endobjtrailer
<< /Size 5
/Root 1 0 R
/Info 2 0 R
>>
startxref

1000
%%EOF

Now my problem is that when i write texy in the 4th and 5th objects the the pdf reader see only two blank pages. Can anyone tell to me which are my mistakes and how to fix it in the pdf format structure?

P.Carlino
  • 661
  • 5
  • 21
  • *I wrote a program that creates a pdf file from scratch* - but you don't seem to have had a look at the specification, have you? It looks like you have looked at some existing pdfs, then started wildly guessing around, and then started writing your program. That approach doesn't work with a format like pdf. – mkl Sep 03 '16 at 16:22
  • Don't worry. I have looked a lot of articles that talking about pdf format.. before write my programs i use to learn the topics. Maybe i didn't understand everything so this is the reason because i wrote my question. – P.Carlino Sep 03 '16 at 16:27
  • 1
    Strangely, your home grown PDF is missing a proper object cross reference index. (I call this "strange" because it is explicitly mentioned in the official PDF reference as an important part of the format.) – Jongware Sep 03 '16 at 18:06
  • Ok thaks indeed @Rad Lexus – P.Carlino Sep 03 '16 at 19:21
  • 1
    OK, some questions and issues immediately coming to mind. **a** Why do you use a `PDF-1.3` header in the times of ISO 32000-1? **b** a BaseFont `Arial.BoldItalic` is somewhat questionable. **c** Encoding `UTF8` is not specified **d** where are the widths of the font? **e** the page dictionaries erroneously contain content stream instructions **f** `endobjtrailer` misses a line break **g** where are the cross references? **h** Why do you reference non-existent outlines? **i** Why do you reference the pages root as info dictionary? – mkl Sep 03 '16 at 19:53

0 Answers0