User Tools

Site Tools


pdf:paintingapage

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revisionPrevious revision
Next revision
Previous revision
pdf:paintingapage [2015/04/02 14:48] – [Comments] christianpdf:paintingapage [2016/02/24 17:49] (current) – [Hello World - How text gets onto a page] christian
Line 1: Line 1:
-====== How does text get onto a PDF page ======+====== Hello World - How text gets onto a page ======
  
 A PDF page has a content stream (**''/Contents''**) containing a list of graphics operator with their parameters. The operators are sequentially executed and can set aspects of the **GraphicsState** or paint in the context of the current GraphicsState. A PDF page has a content stream (**''/Contents''**) containing a list of graphics operator with their parameters. The operators are sequentially executed and can set aspects of the **GraphicsState** or paint in the context of the current GraphicsState.
Line 25: Line 25:
 To achieve this in Smalltalk you can write the following: To achieve this in Smalltalk you can write the following:
 <code smalltalk> <code smalltalk>
-page := Page newInBounds: (0 @ 0 corner: 50 @ 20) colorspace: DeviceCMYK new render: [:renderer |+page := Page newInBounds: (0 @ 0 corner: 70 @ 20) colorspace: DeviceCMYK new render: [:renderer |
   renderer fillColor: CmykColor black.   renderer fillColor: CmykColor black.
   renderer textObjectDo: [   renderer textObjectDo: [
Line 32: Line 32:
     renderer showString: 'Hello World']].     renderer showString: 'Hello World']].
 </code> </code>
 +{{demo01_HelloWorld.pdf}} See the class method ''demo01_HelloWorld'' in class ''Document''.
 +
 You notice that I did not use the font ID **''/F1''** but the font directly (referenced as the global #Helvetica). ''renderer **setFont:**'' takes care of that and puts the font into the resources and assigns it to an internal name which is used in the content stream. This mechanism works for all resource types so that the programmer can always use the appropriate object directly and never needs to care about the internal IDs. You notice that I did not use the font ID **''/F1''** but the font directly (referenced as the global #Helvetica). ''renderer **setFont:**'' takes care of that and puts the font into the resources and assigns it to an internal name which is used in the content stream. This mechanism works for all resource types so that the programmer can always use the appropriate object directly and never needs to care about the internal IDs.
  
/var/www/virtual/code4hl/html/dokuwiki/data/attic/pdf/paintingapage.1427978919.txt.gz · Last modified: 2015/04/02 14:48 by christian