% Example how to use primitives added by pdftex. There are low-level % primitives; high-level macros for more comfortable use may be supported % later \input eplain \input pdfcolor.tex \doublecolumns \vsize=4.4in \font\f=ptmr8r\f \pdfoutput=1\relax % turn on PDF output; otherwise output DVI file % this primitive can not be specified *after* shipping % out the *first* page %\pdfpagesattr={/CropBox [36 36 558 866]} % optional attributes for root Pages object; see PDF % manual for it use. The specified text will be % written out before closing output file %\pdfpageattr={/CropBox [36 372 558 866]} % optional attributes for Page object; see PDF manual % for it use. The specified text will be written out % during shipout. It overwrites any attributes given % by `\pdfpagesattr' \pdfpagewidth=8.26in % page width of PDF file; if not specified then % it will be calculated as `\hsize + 2*(1in + % \hoffset)' when pdftex writes the *first* page \pdfpageheight=11.69in % page height of PDF file is similiar \pdfcompresslevel=0 % compression level for text and image; % 0 = no compression (default) % 1 = fastest compression % 9 = best compression % 2..8 = something between % If there is specified a number which is out of this % range then it will be fixed between 0..9 \pdfannottext % text annotation % width 10cm % optional dimension -- similiar to TeX rule height 3in % specification depth 10pt % % attr{/Open false} % optional attributes of text annotation; specified text % is simply included to corresponding object of text % annotation in PDF file. See PDF-1.2 manual for more % details how to specify it % {The following text % text contents of annotation was taken from the % first page of TeX - % The program, which % is the fine-listing % source of TeX} % \pdfdest % destination for link annotations and outlines % % identifier specification (only one of the following % can/must be specified) num 1 % num identifier %name {dest} % name identifier % % appearance of destination (one of the following % can/must be specified) %fit % fit whole page in window %fith % fit whole width of page %fitv % fit whole height of page %fitb % fit whole "Bounding Box" page fitbh % fit whole width of "Bounding Box" of page %fitbv % fit whole height of "Bounding Box" of page \pdfthreadhoffset=1em % thread margins \pdfthreadvoffset=1em % \pdfthread % start of article thread; the corresponding % `\pdfendthread' must be in the box in the same depth % as the box containing `\pdfthread' all boxes in this % depth level will be treated as part of this thread % % identifier specification (only one of the following % can/must be specified). Threads with same identifier % will be join to the only one. num 1 % num identifier %name {thread} % name identifier The main purpose of the following program is to explain the algorithms of \TeX\ as clearly as possible. As a result, the program will not necessarily be very efficient when a particular PASCAL compiler has translated it into a particular machine language. However, the program has been written so that it can be tuned to run efficiently in a wide variety of operating environments by making comparatively few changes. Such flexibility is possible because the documentation that follows is written in the WEB language, which is at a higher level than PASCAL; the preprocessing step that converts WEB to PASCAL is able to introduce most of the necessary refinements. Semi-automatic translation to other languages is also feasible, because the program below does not make extensive use of features that are peculiar to PASCAL. A large piece of software like TeX has inherent complexity that cannot be reduced below a certain level of difficulty, although each individual part is fairly simple by itself. The WEB language is intended to make the algorithms as readable as possible, by reflecting the way the individual program pieces fit together and by providing the cross-references that connect different parts. % \pdfannotlink % start of link annotation % height 10pt % optional dimension -- similiar to TeX rule depth 3pt % specification. If not specified then it will be depth 3pt % calculated from the box containing this link % attr{/C [0.9 0 0] % optional attributes of link annotation; specified text /Border [0 0 2]} % is simply included to corresponding object of link % annotation in PDF file. See PDF-1.2 manual for more % details how to specify it % % action specification % goto % goto action % %file{file.pdf} % optional file specification; can be used only with % `goto' action or `thread' action (see below). If % action identifier is name then there should be a % destination or a thread with same name identifier % in the file; if action identifier is number then it % means page number for `goto' action (in this case it % will take effect as `fitb' specification) and index % number of thread for `thread' action (the first one % in document has index number 0) % % goto action type (one of the following can/must be % specified) num 1 % goto destination with num identifier %name{dest} % goto destination with name identifier % % %thread % thread action; start to read a thread % %file{file.pdf} % optional file specification; see above % % thread action type (one of the following can/must be % specified) %num 1 % read thread with num identifier %name{thread} % read thread with name identifier % % %user{/S /URI /URI (http://www.tug.org/)}% user-defined action. See PDF-1.2 % manual for more details. In this case it is URI % action % % % end of `\pdfannotlink' parameters % % % \setcolor\cmykSeaGreen % turn on color (this is not a part of `pdfannotlink'); % see the file pdfcolor.tex for example how to specify % colors % Detailed comments about what is going on, and about why things were done in certain ways, have been liberally sprinkled throughout the program. These comments explain features of the implementation, but they rarely attempt to explain the % \pdfendlink % ends link annotation; all text between % `\pdfannotlink' and `\pdfendlink' will be treated as % part of this link annotation % \setcolor\cmykBlack % turn off color (this is not a part of `\pdfendlink') % TeX language itself, since the reader is supposed to be familiar with The TeX book.\par \pdfendthread % end of article thread % The outline specification is a bit more complicated: % \pdfoutline % Outline entry specification % goto num 1 % action specification. This is the same as the action % specification of `\pdfannotlink' % count 3 % number of direct subentries of this entry, 0 if this % entry has no subentries (in this case it may be % omitted). If after `count' follows an negative number % then all subentries will be closed and the absolute % value of this number specifies the number of % direct subentries (see the following entries) % {Outline 1} % text contents of outline entry \pdfoutline goto num 1 count -2{Outline 1.1} \pdfoutline goto num 1 {Outline 1.1.1} \pdfoutline goto num 1 {Outline 1.1.2} \pdfoutline goto num 1 {Outline 1.2} \pdfoutline goto num 1 {Outline 1.3} \pdfoutline goto num 1 {Outline 2} \vfil\eject \footline={\pdfannotlink user {/S /Named /N /GoBack}\Cyan Go Back\Black \pdfendlink\hfil \folio} %\pdfpageattr={} % reset Page attributes for remaining pages \pdfimage % this pridmitive creates a *hbox* contaning an image % height 5cm % optinal dimension of box contaning the image; this is width 8cm % similiar to TeX rule specification. Only height and %depth 0pt % width take effect; the dimension specified by depth is % ignored. Dimensions which are not specified will be % treated as zero. If both height and width are zero % then the box takes natural size of the image. If one % of them (width or height) is zero and the second is % not, then the first one (the zero one) will be set to % value corresponding to the second one to make the box % have the same proportion of width and height as the % image natural size. If both width and height are % positive then the image will be scaled to fit these % dimensions % image.png % the name of image file; the file should be in % $TEXPSHEADERS paths \bigskip \pdfimage % include an image and force its width to 6cm width 4cm % image.png % \bigskip \pdfimage % include an image at its natural size; resolution image.png % will be 72 dpi \bigskip %\vfil\eject % you may need to uncomment this line if you are using % Windows; otherwise you'll get a memory error. It % sometimes happens when a lot of images are used in a % page at once. % include an image at fixed resolution (in this % example 600 dpi) % \setbox0=\hbox{ % find out natural size (at 72 dpi) \pdfimage % image.png\relax} % % \dimen0=0.12\wd0 % scale width of image (72/600 = 0.12) % \pdfimage % include the image with resolution 600 dpi width \dimen0 % image.png % \vfil\eject \setbox0=\vbox{ % make a box \hbox{Box 1} \hbox{Box 2} \hbox{Box 3} } \pdfform % write out a TeX box as a Form object to PDF output % 0 % box number \newcount\n \n=\pdflastform % store the number of most recent Form object created by % `\pdfform' \pdfrefform % put a reference to a Form object which was created % by `\pdfform' \n % reference to the Form object, its object number is % stored in `\n' \hrule % Transformations are done by including transformation matrices. See PDF manual % for more details how to use it. Generally, a transformation matrix is given % as six real numbers followed by operator `cm'. Before doing any % transformation we must store current graphic state (by operator `q') % and restore it (by operator `Q') after transformation. See examples below. % Make sure that *no spacing* can be produced during transformation and % we must adjust spacing ourselves then. \setbox0=\vbox{ \hbox{Rotated text} \hbox{Rotated text} \hbox{Rotated text} } \setbox1=\vbox{ \hbox{Scaled text} \hbox{Scaled text} \hbox{Scaled text} } \setbox2=\vbox{ \hbox{Skewed text} \hbox{Skewed text} \hbox{Skewed text} } \newdimen\d \newbox\b \def\avoidboxdimen#1{% \setbox\b=\hbox{\box#1}% \wd\b=0pt \ht\b=0pt \dp\b=0pt \box\b} % rotation by `t' degrees counterclockwise is specified as % `cos(t) sin(t) -sin(t) cos(t) 0 0'. \vskip\wd0 \leftline{\hskip\ht0\hskip\dp0% \pdfliteral{q 0 1 -1 0 0 0 cm}% \avoidboxdimen0% \pdfliteral{Q}} \hrule % scaling is specified as `Sx 0 0 Sy 0 0' \d=\ht1 \advance\d by \dp1 \vskip3\d \pdfliteral{q 2 0 0 3 0 0 cm}% \avoidboxdimen1% \pdfliteral{Q}% \hrule % skewing x-axis by `u' degrees and y-axis by `v' degrees is specified as % `1 tan(u) tan(v) 1 0 0'. \d=\ht2 \advance\d by \dp2 \vskip\d \d=0.57735\wd2 %tan(30) = 0.57735 \pdfliteral{q 1 -0.57735 0 1 0 0 cm}% \avoidboxdimen2 \pdfliteral{Q} \vskip\d \hrule \leftline{\pdfannotlink goto %file {example.pdf} page 1 {/FitB} Click here to return to the first page\pdfendlink} \vfil\eject \bigskip \leftline{\pdfannotlink thread %file {example.pdf} num 1 %name{thread} \Blue Click here to read the thread \Black\pdfendlink} \bigskip \leftline{\pdfannotlink user{/S /URI /URI (http://www.fi.muni.cz/)} \Red Click here to visit out faculty\Black\pdfendlink} \pdfinfo % Info dictionary of PDF output % only following entries are allowed and all are % optinal author {Han The Thanh} title {example.pdf} subject {example} keywords {pdftex} \pdfcatalog % Catalog dictionary of PDF output. % only following entries are allowed and all are % optinal pagemode {/UseOutlines} uri {http://www.fi.muni.cz/} \bye