Quantcast
Channel: Adobe Community : Popular Discussions - PDF Language and Specifications
Viewing all articles
Browse latest Browse all 46145

Simple Text String Example in specification broken.

$
0
0
I am a fortran programmer, contemplating writing a simple PDF creator. Like a previous poster, I am trying to get a handle on the PDF spec by typing in the examples from appendix G. I understand I need to tweak the stream lengths and xref byte offsets. I got the "Simple Graphics Example" to work on my first try.

I believe the "Simple Text String Example" is broken somehow. I've re-typed it a couple different times, I don't think I have a typo. I do have several flavors of viewers available to me: kpdf, xpdf, gv and Adobe Reader 7. kpdf and xpdf seem to be more lenient, and show me the text. gv gives an error and Reader displays a blank page without comment.

I've also saved a simple text file as a PDF from OpenOffice, which works with all four viewers, and I've been slowly modifying it to be more similar to the broken example, but I cannot find the difference/problem.

I did notice that the Simple Example uses the /Name string in the Font specification, which has been deprecated.

Here's the Simple Example (broken):

%PDF-1.4
1 0 obj
<< /Type /Catalog /Outlines 2 0 R /Pages 3 0 R >>
endobj
2 0 obj
<< /Type /Outlines /Count 0 >>
endobj
3 0 obj
<< /Type /Pages /Kids [4 0 R] /Count 1 >>
endobj
4 0 obj
<< /Type /Page /Parent 3 0 R /MediaBox [0 0 612 792] /Contents 5 0 R /Resources << /ProcSet 6 0 R /Font << /F1 7 0 R >> >> >>
endobj
5 0 obj
<< /Length 43 >>
stream
BT /F1 24 Tf 100 100 Td (Hello World) Tj ET
endstream
endobj
6 0 obj
[/PDF /Text]
endobj
7 0 obj
<< /Type /Font /Subtype /Type1 /Name /F1 /Basefont /Helvetica /Encoding /MacRomanEncoding >>
endobj
xref
0 8
0000000000 65535 f
0000000009 00000 n
0000000074 00000 n
0000000120 00000 n
0000000177 00000 n
0000000318 00000 n
0000000411 00000 n
0000000439 00000 n
trailer
<< /Size 8 /Root 1 0 R >>
startxref
547
%%EOF

Here's the file that works:

%PDF-1.4
1 0 obj
<< /Type /Catalog /Pages 2 0 R /PageLayout /SinglePage >>
endobj
2 0 obj
<< /Type /Pages /Resources 4 0 R /MediaBox[0 0 595 842] /Kids [3 0 R] /Count 1>>
endobj
3 0 obj
<< /Type /Page /Parent 2 0 R /Resources 4 0 R /MediaBox[0 0 612 792] /Group<</S/Transparency/CS/DeviceRGB/I true>> /Contents 8 0 R>>
endobj
4 0 obj
<< /Font 5 0 R /ProcSet[/PDF/Text]>>
endobj
5 0 obj
<< /F1 6 0 R >>
endobj
6 0 obj
<< /Type /Font /Subtype /Type1 /BaseFont /Helvetica /Encoding /MacRomanEncoding >>
endobj
7 0 obj
43
endobj
8 0 obj
<< /Length 7 0 R >>
stream
BT /F1 24 Tf 100 100 Td (Hello World) Tj ET
endstream
endobj
xref
0 9
0000000000 65535 f
0000000009 00000 n
0000000082 00000 n
0000000178 00000 n
0000000326 00000 n
0000000378 00000 n
0000000409 00000 n
0000000507 00000 n
0000000525 00000 n
trailer
<< /Size 9 /Root 1 0 R >>
startxref
621
%%EOF

Any help is appreciated. I've wasted way too much time on this.

-Charles

Viewing all articles
Browse latest Browse all 46145

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>