X-Git-Url: https://git.ucc.asn.au/?p=ipdf%2Fsam.git;a=blobdiff_plain;f=chapters%2FBackground%2FStandards%2FInterpreted.tex;fp=chapters%2FBackground%2FStandards%2FInterpreted.tex;h=2c58f254c5fe38fb4e2f62ea151b118eebbc7297;hp=0000000000000000000000000000000000000000;hb=9fcf44a0c34f393689118e913a2d17d907036c85;hpb=d5e7e14d2ec624cfe0febcccd81e95082ef1c175 diff --git a/chapters/Background/Standards/Interpreted.tex b/chapters/Background/Standards/Interpreted.tex new file mode 100644 index 0000000..2c58f25 --- /dev/null +++ b/chapters/Background/Standards/Interpreted.tex @@ -0,0 +1,74 @@ +Adobe's PostScript Language Reference Manual defines a turing complete language for producing graphics output on an abstract ``output device''\cite{plrm}. A PostScript document is treated as a procedural program; an interpreter executes instructions in the order they are written by the programmer. In particular, the document specifies the locations of enclosed curves using B\'{e}zier splines (Section \ref{}), whilst text is treated as vector fonts described in Section \ref{}. +\begin{comment} +Each symbol is pushed onto a stack as it is read. Special symbols called ``operators'' can act upon this stack and/or the output device. An internal ``graphics state'' stack can be constructed to store styling information (such as colour, line thickness, the current cursor position). It is possible for the language to define new operators.\end{comment} +PostScript was and is still widely used in printing of documents onto paper; many printers execute postscript directly, and newer formats including PDF must still be converted into PostScript by printer drivers\cite{pdfref17, cheng2002portable}. + + + +Adobe's Portable Document Format (PDF) is currently used almost universally for sharing documents; the ability to export or print to PDF can be found in most graphical document editors and even some plain text editors\cite{cheng2002portable}. + +Hayes describes PDF as ``... essentially 'flattened' PostScript; it’s what’s left when you remove all the procedures and loops in a program, replacing them with sequences of simple drawing commands.''\cite{hayes2012pixels}. %Consultation of the PDF 1.7 standard shows that this statement does not a give a complete picture --- despite being based on the Adobe PostScript model of a document as a series of ``pages'' to be printed by executing sequential instructions, from version 1.5 the PDF standard began to borrow some ideas from the Document Object Model. + +%For example, interactive elements such as forms may be included as XHTML objects and styled using CSS. ``Actions'' are objects used to modify the data structure dynamically. In particular, it is possible to include Javascript Actions. Adobe defines the API for Javascript actions seperately to the PDF standard\cite{js_3d_pdf}. There is some evidence in the literature of attempts to exploit these features, with mixed success\cite{barnes2013embedding, hayes2012pixels}. + +%Figure \ref{PS} shows a vector image and one possible way to express this image in PostScript. + +%There are some limitations in PostScript's model. As mentioned in Section \ref{Compositing}, since PostScript predates Porter and Duff Compositing, there is no concept of transparency. In fact, using tools to convert between the SVG image in Figure \ref{SVG} and PostScript will simply rasterise the image and embed the rastered image in PostScript\footnote{For Figure \ref{SVG} converted using the Inkscape SVG editor: \url{http://szmoore.net/ipdf/figures/shape-svg-converted-to.ps}} + +%Another limitation of PostScript is that the model of a document as a static page, convenient for printers which literally produce static pages, is unable to include interactive or dynamic elements. Dynamic PostScript attempted to fix this problem, but ``never caught on''\cite{hayes2012pixels}. + +\begin{comment} +\begin{figure}[H] +\begin{minipage}[t]{0.65\textwidth} +\begin{minted}{postscript} +%!PS-Adobe-3.0 EPSF-3.0 +%%BoundingBox: 0 -1 85 150 +% These lines are comments to aid in human understanding +% Define an operator to produce a rectangular path +/re { exch dup neg 3 1 roll 5 3 roll moveto 0 rlineto + 0 exch rlineto 0 rlineto closepath } bind def +% Operator to produce the path for the first rectangle +/re1 { 24.613 133.001 24 -120 re } bind def +% Operator to produce the path for the second rectangle +/re2 { 10.215 45.001 48 -16 re } bind def +% Operator which will produce the curved path +/curve { 46.215 1.001 moveto + 46.215 1.001 91.812 11.399 71.812 35.399 curveto + 51.812 59.399 29.414 33.802 51.812 59.399 curveto + 74.215 85.001 93.414 45.802 74.215 85.001 curveto + 55.016 125.001 61.414 49.802 46.215 75.399 curveto + 31.016 101.001 56.613 126.598 56.613 126.598 curveto + 56.613 126.598 88.613 166.598 56.613 137.802 curveto + 24.613 109.001 -18.586 83.399 9.414 50.598 curveto + 37.414 17.802 45.414 1.001 45.414 1.001 curveto +closepath } bind def +% Set stroke properties +0.8 setlinewidth 0 setlinecap 0 setlinejoin [] + 0.0 setdash 4 setmiterlimit +% Draw the straight line +0 setgray 0.613 149.001 moveto 83.812 0.2 lineto fill +% Fill and outline the first rectangular path +0 0 1 setrgbcolor re1 fill 0 setgray re1 stroke +% Fill and outline the curved shape +1 0 0 setrgbcolor curve fill 0 setgray curve stroke +% Fill and outline the second rectangle +0 1 0 setrgbcolor re2 fill 0 setgray re2 stroke +showpage +\end{minted} +\end{minipage} +\begin{minipage}[t]{0.3\textwidth} + \begin{figure}[H] + \centering + \includegraphics[width=1\textwidth]{figures/shape.eps} + \end{figure} +\end{minipage} + \caption{Vector image and a possible PostScript representation}\label{PS} +\end{figure} + + +\subsubsection{{\TeX}, METAFONT and {\LaTeX}} + +Knuth's ``The {\TeX}book''\cite{knuth1984texbook} and ``The METAFONT book''\cite{knuth1983metafont} define two complementary programming languages for typesetting documents. Wheras PostScript may be considered an interpreted language, in that it can be produced in a human readable form which is also readable by an interpreter, {\TeX} is a compiled language; a program parses human readable {\TeX} to produce a machine readable format DVI (``DeVice Independent''). A DVI interpreter might be thought of as a virtual ``Display Processor'' for drawing vector graphics directly (as defined in the earlier editions of ``Computer Graphics''\cite{computergraphics2}). + +DVI itself is not a widely used format for sharing documents. However, an system based upon {\TeX} called {\LaTeX} which includes libraries for advanced typesetting and programs that ultimately produce PDF output is particularly popular for producing technical reports and papers\footnote{The site \url{http://tex.stackexchange.com} (accessed 2014-05-22) is devoted to {\TeX} and {\LaTeX}} --- this report itself has been produced using the CTAN {\LaTeX} packages\footnote{The complete {\TeX} source code to produce this document can be found at \url{http://szmoore.net/ipdf/sam/}}. +\end{comment}