home *** CD-ROM | disk | FTP | other *** search
/ No Fragments Archive 10: Diskmags / nf_archive_10.iso / MAGS / CHOSNECK / CHOS2.ZIP / CHOSNECK.2ND / STUFF / DATAS.ZIP / ART44.SCR < prev    next >
Encoding:
Text File  |  1994-10-03  |  7.0 KB  |  182 lines

  1. <head>
  2. <title="...forever...">
  3. <font=monaco10.fnt>
  4. <font=newy36.fnt>
  5. <font=time24.fnt>
  6. <image=back.raw w=256 h=256 t=-1>
  7. <buf=2621>
  8. <bgcolor=-1>
  9. <background=0> 
  10. <link_color=253>
  11. <module=console.mod>
  12. <pal=back.pal>
  13. colors:
  14. 251 - black
  15. </head>
  16. <body>
  17. <frame x=0 y=0 w=640 h=2621 b=-1 c=-1>
  18.  
  19.  
  20.                 - -- - --------------------------------------
  21.  <f1><c000>           <link=pic42_2.scr>PDF - what's this?</l> <f0>
  22.              <f1><c000>            part #2 <f0>
  23.                 ----------------------------- -- - --- --- -- 
  24.   
  25. In the first part I have written  few  words  about PDF documents. What you can
  26. and what you can do with this. It was  about 2 weeks ago and I still can't find
  27. things which you can't do in PDFs :)  It's  really good for the user.  But it's
  28. also a huge source of possible problems.
  29.  
  30. Let's start with some fundamental information about the PDF structure.
  31.  
  32. A PDF document consists of  many,  many,  many  dictionaries  :) So, there is a
  33. dictionary  with  pages,   contents,   fonts,   pictures,   thumbnails,  forms,
  34. interactive forms etc. Each  dictionary  can  be  stored  "online" or relative.
  35. Each dictionary can consist of many  other  dictionaries (the best example is a
  36. font  dictionary)  -  nested   structure.    Relative   information  is  always
  37. accompanied by a list of object  numbers  with  offsets  to the place where the
  38. object is stored (for example the object  number  100 is stored 1300 bytes from
  39. the beginning of  the  file).   It's  a  so  called  cross-reference table.  So
  40. reading a PDF document  is  effectively  like  jumping  from  one dictionary to
  41. another.
  42.  
  43. In practice it looks like this:
  44.  
  45. 1. some general operations (document information, object list etc.)
  46. 2. reading of page tree
  47. 3. each page has a resource dictionary with fonts, pictures, annotations etc. -
  48.    it is necessarily to read it
  49. 4. reading of resources, example of font  (some steps are optional, but if they
  50. are you have to make it)
  51.  - main dictionary
  52.  - font file dictionary
  53.  - encoding dictionary etc. etc.
  54. 6. unpacking and rendering of page contents
  55.  - each command is stored _after_ variables.  It  means  that we first read the
  56.    variables and then the command.  It  makes  the whole thing much harder than
  57.    you can imagine.
  58. 7. displaying
  59.  
  60. Generally the structure of each PDF looks like this:
  61.  
  62. +-----------------+
  63. | File header     |
  64. +-----------------+
  65. |                 |
  66. | Body            |
  67. |                 |
  68. +-----------------+
  69. | Cross-reference |
  70. | table           |
  71. +-----------------+
  72. | Trailer         |
  73. +-----------------+
  74.  
  75. Trailers give the  location  of  the  cross-reference  table  and  some special
  76. objects within the body of the file.
  77.  
  78. And the document structure is organized in this way:
  79.                      +-----------+
  80.                 +----| Page tree |
  81.                 |    +-----------+
  82.                 |
  83.                 |    +----------+
  84.                 |----| Outlines |
  85.                 |    +----------+
  86.                 |
  87. +----------+    |    +-----------------+
  88. | Document |    |----| Article threads |
  89. | catalogue|----|    +-----------------+
  90. +----------+    |
  91.                 |    +--------------------+
  92.                 |----| Named destinations |
  93.                 |    +--------------------+
  94.                 |
  95.                 |    +------------------+
  96.                 |----| Interactive form |
  97.                      +------------------+
  98.  
  99. Outlines and article threads are also  much  more complicated - they consist of
  100. many other subdictionaries.   The  page  tree  block  consists  of  many blocks
  101. representing each page in the document.   So,  the  page tree is organized just
  102. like pages in a normal book. For example:
  103.  
  104. page1
  105.  |
  106.  +--->Chapter 1
  107.  |       |
  108.  |       |->page2
  109.  |       |->page3
  110.  |       |->page4
  111.  |       |->page5
  112.  |
  113.  |--->Chapter 2
  114.  |       |
  115.  |       |->page6
  116.  |       |->page7
  117.  |       |->page8
  118.  |       |->page9
  119.  
  120. and so on. It means, that each page can also have sub-pages.
  121.  
  122. Each page consists of: resources  (fonts,  pictures), content stream, thumbnail
  123. images (if present) and annotations (optional).
  124.  
  125. I don't want to talk about details, we don't  have so much time and space - the
  126. reference book has 1172 pages!!
  127.  
  128. Does it look so hard? No, of course not ;)
  129.  
  130. So, why's it not so perfect as it appears? There are just three reasons.
  131.  
  132.  
  133. 1. It is too  complicated  -  it  means  that  the  reading  time could be much
  134. shorter.   Especially the page contents  where  the variables are stored before
  135. the command (like "0 0 100 100 re"  -  for a rectangle).  Better form would be:
  136. "re 0 0 100 100".
  137. The other problem is that each command  "line"  can have at the end either œ\rœ
  138. or œ\r\nœ or œ\nœ or nothing.  So you never know where the next "line" starts.
  139. There are however few tricks which can speed it up a little :)
  140.  
  141. 2. Fonts. This is the hardest part in each PDF document. Just imagine that even
  142. Acrobat Reader has problems  with  it!!  (example  in  pictures)   On the first
  143. picture you see the screenshot  from  Adobe  Acrobat  Reader and the second one
  144. from GhostScript 8.x  So, when you'll  look  at  the details of some characters
  145. you'll see the difference. One can ask  which  one  is the correct one?  Try to
  146. guess ;)  A small tip: the correct one comes from the application whose version
  147. is 8.x ;)
  148.  
  149. Another example. This time 4 pictures  (Adobe Acrobat, GhostScript, Porthos and
  150. MyPDF). So, you see how many problems  Acrobat  has - even one single character
  151. can't be displayed!!!   GhostScript  is  better,  but  it's  still not perfect.
  152. Porthos quite good :) MyPDF -  hmmm,  some  problems with text positioning (I'm
  153. actually working on it). But at least all characters are displayed.  Especially
  154. with the last example you  see  how  many  problems different readers have with
  155. different documents.
  156.  
  157. 3. Each "distiller" (this name is reserved for Acrobat Distiller) produces PDFs
  158. in different way. For example  the  ending  of  lines  or  the way each font is
  159. stored etc. Then look at 1. and 2. ;) For example there is a distiller, that is
  160. converting text to vector graphic!  Both  1.  and  2.  can really slow down the
  161. reading process on each platform. Particularly on our beloved Atari.  Also some
  162. new or rare commands can produce many problems.
  163.  
  164. So, now you know the structure  of  PDF  document  and know the problems we can
  165. have while reading it.  Even if you think that these problems are easy to solve
  166. - you just think so ;)
  167.  
  168. In the next part I'll try to  tell  you  how  MyPDF works and how I solved some
  169. speed problems.
  170.  
  171.                                                            cu next time
  172.                                                            Rafael Kawecki
  173.  
  174.  
  175. -- - --- -- -------------------------------------------------------------------
  176.  CHOSNECK 4th appearance                                           contact us:
  177.  done by the dream survivors                                 greymsb@poczta.fm
  178. ----------------------------------------------------------------- -- - --- ----
  179. </frame>
  180. </body>
  181.  
  182.