[pdftex] Handwritten pdf graphics

Tobias Haustein tobias.haustein at aixigo.de
Mon Oct 14 14:48:32 CEST 2002


Hartmut Henkel wrote:

> Thanks a lot, Heiko! Yes, \pdfliteral works as desired; see the file
> below.

You've asked for examples for embedding handwritten PDF code in PDF documents.
We're using \pdfliteral to embed our own graphics in PDF documents. This works
very well. Until now I did not manage to embed the PDF code in an xform
object, but your/Heiko's solution seems to work very well. 

There are however a few subtle problems that remain if you want to embed your
own PDF code:

1) If you need color spaces, patterns, fonts or other external resources, it
is impossible to tell pdflatex to include these resources in the page
resources. Of course, you can use \pdfpageresources, but if you define
resources that are also used by pdflatex, both resource declarations go into
the resources table which results in undefined behaviour. It would be
excellent, if pdfTeX would allow to specify such resources.

2) For fonts, we've found a working solution. The problem here is that the
font needs to be defined. If pdfTeX does not use the font itself, it is not
included in the PDF document. We use \pdfliteral to define a new context with
an empty clip region, set the font in tex code, write one character and end
the local context by \pdfliteral. The other characters are declared using
\pdfincludechars, which works perfect. It would be nice if one could tell
pdftex to include a font even if it is not used in the tex code.

3) There remains a problem with the font mapping. If you embed your own text
output, you have to use the correct font encoding. For the fonts we're using,
it turns out that the font encoding is compatible with iso-8859-1 for common
characters. The only exception is "ß", which is mapped to a different glyph
(255). Until now, we've not figured out, how to deal with that problem.
Probably, we need to use freetype in order to find the correct mapping.

4) We can't include the space-character in the font. pdfTeX does not use this
character and seems to refuse to include it in the font. As far as I can see,
this worked with old versions of pdfTeX, but newer versions won't include the
character. Therefore, we need to use the TJ-Operator in order to use the
kerning parameter to get a space. It works well, but makes things more
complicated.

5) If you write PDF code that depends on exact text sizes, be sure to disable
font hinting when measuring the glyph size. The pdf viewer does not use font
hinting.

6) If you include embedded PDF images into the PDF document, the produced
document is not printable (at least with our printers here). I think that this
is a PDF problem and no pdfTeX problem, but it remains a problem. Of course,
one can use an external image file and include it using the graphicx package,
but then you don't have one self containing document.

Despite of these minor problems, pdfTeX is perfect for producing nice
documents with high quality graphics. Attached to this e-mail you find an
example. Since it makes use of true type fonts that are not part of the
default pdfTeX distribution, it will probably not work out of the box.



Ciao,

Tobias Haustein

--
Dipl. Inform. Tobias Haustein

aixigo AG - financial training, research and technology
Schloß-Rahe-Straße 15, 52072 Aachen, Germany
fon: +49 (0)241 936737-40, fax: +49 (0)241 936737-99
eMail: tobias.haustein at aixigo.de, web: http://www.aixigo.de
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% 
% AixigoMarkup
% 
%  Copyright (C) 2000, 2001, 2002
%    by aixigo AG, Schloß-Rahe-Str. 15, 52072 Aachen, Germany, all rights reserved.
% 
%  $RCSfile: pdf_latex_2_pdf.sty,v $
%  $Revision: 1.1 $
%  $Date: 2002/10/13 14:39:28 $
%  $Author: thaustein $
%

\NeedsTeXFormat{LaTeX2e}
\ProvidesPackage{pdf_latex_2_pdf}[2002/09/29]
\RequirePackage{ifthen}
\RequirePackage{calc}
\RequirePackage{graphics}

\long\def\aixigoPdfDrawing#1#2#3{%
\penalty-100
\ifGin at draft{%
\parbox[b][#2]{#1}{\hrule\rule{\fboxrule}{#2}\hfill\raisebox{#2 / 2}{PDF drawing}\hfill\vrule\vfill\hrule}}%
\else{%
\parbox[b][#2]{#1}{\makebox[0cm][c]{}\pdfliteral{q 0.8 w 1 J 1 j}#3\pdfliteral{Q}}}%
\penalty-100
\fi}

\tracingmacros=1
\def\aixigoDeclareFont#1#2#3{%
\expandafter\font\csname#1\endcsname=#2%
\pdfincludechars\csname#1\endcsname{#3}%
\pdfliteral{q 0 0 0 0 re W n}\makebox[0cm][c]{\csname#1\endcsname .}\pdfliteral{Q}%
}

\aixigoPdfDrawing{412.50bp}{142.50bp}{\aixigoDeclareFont{aixigoGfxFontAA}{arialr16t}{\%(),-.38ABCDEFHILMNORSTU_abcdefghiklmnopqrstuwz ä}\pdfliteral{
q 0 0 412.50 142.50 re W n
1.0000 g 0.00 142.50 412.50 -142.50 re f
q 0.00 142.50 412.50 -142.50 re W n
Q 0.9529 G 4.00 w 245.47 43.54 m 250.91 42.09 l 344.06 42.09 l S
235.77 26.73 m 239.74 22.76 l 289.88 22.76 l S
218.96 17.03 m 220.41 11.59 l 283.78 11.59 l S
199.54 17.03 m 198.09 11.59 l 180.05 11.59 l S
182.73 26.73 m 178.76 22.76 l 92.74 22.76 l S
173.03 43.54 m 167.59 42.09 l 142.36 42.09 l S
173.03 62.96 m 167.59 64.41 l 122.65 64.41 l S
182.73 79.77 m 178.76 83.74 l 147.23 83.74 l S
199.54 89.47 m 197.76 96.13 l 93.56 96.13 l S
218.96 89.47 m 220.74 96.13 l 277.12 96.13 l S
235.77 79.77 m 239.74 83.74 l 291.28 83.74 l S
245.47 62.96 m 250.91 64.41 l 276.42 64.41 l S
0.8902 g 235.77 26.73 m 221.12 12.09 197.38 12.09 182.73 26.73 c 168.09 41.38 168.09 65.12 182.73 79.77 c 197.38 94.41 221.12 94.41 235.77 79.77 c 250.41 65.12 250.41 41.38 235.77 26.73 c h B
0.0000 G 0.45 w 242.47 46.54 m 247.91 45.09 l 341.06 45.09 l S
0.8000 g 0.70 w 243.75 56.25 m 243.75 49.67 242.02 43.20 238.73 37.50 c 206.25 56.25 l B
0.0000 g BT /F\pdffontname\aixigoGfxFontAA\space8.40 Tf 344.54 42.29 Td [<4c69717569646974e474>] TJ ET
BT 379.77 42.29 Td [<28382c33> -2.32 <2529>] TJ ET
0.45 w 232.77 29.73 m 236.74 25.76 l 286.88 25.76 l S
0.6000 g 0.70 w 238.73 37.50 m 235.43 31.80 230.70 27.07 225.00 23.77 c 206.25 56.25 l B
0.0000 g BT 290.36 24.19 Td [<4f6666656e65>] TJ ET
BT 317.43 24.19 Td [<496d6d6f62696c69656e666f6e6473>] TJ ET
BT 379.77 24.19 Td [<28382c33> -2.32 <2529>] TJ ET
0.45 w 215.96 20.03 m 217.41 14.59 l 280.78 14.59 l S
0.4000 g 0.70 w 225.00 23.77 m 219.30 20.48 212.83 18.75 206.25 18.75 c 206.25 56.25 l B
0.0000 g BT 284.26 11.80 Td [<536f6e7374696765>] TJ ET
BT 318.48 11.80 Td [<73696368657265>] TJ ET
BT 347.21 11.80 Td [<416e6c6167656e>] TJ ET
BT 379.77 11.80 Td [<28382c33> -2.32 <2529>] TJ ET
0.45 w 196.54 20.03 m 195.09 14.59 l 177.05 14.59 l S
0.7333 0.7333 1.0000 rg 0.70 w 206.25 18.75 m 199.67 18.75 193.20 20.48 187.50 23.77 c 206.25 56.25 l B
0.0000 g BT 6.48 11.80 Td [<416e6c656968656e>] TJ ET
BT 40.91 11.80 Td [<627a772e>] TJ ET
BT 61.23 11.80 Td [<52656e74656e666f6e6473>] TJ ET
BT 110.12 11.80 Td [<4575726f7a6f6e65>] TJ ET
BT 147.32 11.80 Td [<28382c33> -2.32 <2529>] TJ ET
0.45 w 179.73 29.73 m 175.76 25.76 l 89.74 25.76 l S
0.6000 0.6000 0.9725 rg 0.70 w 187.50 23.77 m 181.80 27.07 177.07 31.80 173.77 37.50 c 206.25 56.25 l B
0.0000 g BT 6.48 24.19 Td [<424f4e44535f555344>] TJ ET
BT 60.01 24.19 Td [<28382c33> -2.32 <2529>] TJ ET
0.45 w 170.03 46.54 m 164.59 45.09 l 139.36 45.09 l S
0.4667 0.4667 0.9098 rg 0.70 w 173.77 37.50 m 170.48 43.20 168.75 49.67 168.75 56.25 c 206.25 56.25 l B
0.0000 g BT 6.48 42.29 Td [<424f4e44535f494e5445524e4154494f4e414c>] TJ ET
BT 109.63 42.29 Td [<28382c33> -2.32 <2529>] TJ ET
0.45 w 170.03 65.96 m 164.59 67.41 l 119.65 67.41 l S
0.9882 0.7451 0.5922 rg 0.70 w 168.75 56.25 m 168.75 62.83 170.48 69.30 173.77 75.00 c 206.25 56.25 l B
0.0000 g BT 6.48 64.61 Td [<416b7469656e>] TJ ET
BT 29.24 64.61 Td [<282d666f6e647329>] TJ ET
BT 61.56 64.61 Td [<4575726f7061>] TJ ET
BT 89.92 64.61 Td [<28382c33> -2.32 <2529>] TJ ET
0.45 w 179.73 82.77 m 175.76 86.74 l 144.23 86.74 l S
0.9882 0.6235 0.3922 rg 0.70 w 173.77 75.00 m 177.07 80.70 181.80 85.43 187.50 88.73 c 206.25 56.25 l B
0.0000 g BT 6.48 83.95 Td [<46554e44535f4e4f5254485f414d4552494341>] TJ ET
BT 114.50 83.95 Td [<28382c33> -2.32 <2529>] TJ ET
0.45 w 196.54 92.47 m 194.76 99.13 l 90.56 99.13 l S
0.9961 0.5098 0.1961 rg 0.70 w 187.50 88.73 m 193.20 92.02 199.67 93.75 206.25 93.75 c 206.25 56.25 l B
0.0000 g BT 6.48 96.33 Td [<46554e44535f41534941>] TJ ET
BT 60.83 96.33 Td [<28382c33> -2.32 <2529>] TJ ET
0.45 w 215.96 92.47 m 217.74 99.13 l 274.12 99.13 l S
0.9333 0.3765 0.1490 rg 0.70 w 206.25 93.75 m 212.83 93.75 219.30 92.02 225.00 88.73 c 206.25 56.25 l B
0.0000 g BT 277.61 96.33 Td [<46554e44535f494e5445524e4154494f4e414c>] TJ ET
BT 379.77 96.33 Td [<28382c33> -2.32 <2529>] TJ ET
0.45 w 232.77 82.77 m 236.74 86.74 l 288.28 86.74 l S
0.6275 0.4000 0.3294 rg 0.70 w 225.00 88.73 m 230.70 85.43 235.43 80.70 238.73 75.00 c 206.25 56.25 l B
0.0000 g BT 291.76 83.95 Td [<536f6e7374696765>] TJ ET
BT 325.98 83.95 Td [<526973696b6f616e6c6167656e>] TJ ET
BT 379.77 83.95 Td [<28382c33> -2.32 <2529>] TJ ET
0.45 w 242.47 65.96 m 247.91 67.41 l 273.42 67.41 l S
0.5020 0.3137 0.2510 rg 0.70 w 238.73 75.00 m 242.02 69.30 243.75 62.83 243.75 56.25 c 206.25 56.25 l B
0.0000 g BT 276.90 64.61 Td [<536f6e7374696765>] TJ ET
BT 311.12 64.61 Td [<416b7469656e>] TJ ET
BT 336.20 64.61 Td [<6f646572>] TJ ET
BT 355.11 64.61 Td [<466f6e6473>] TJ ET
BT 379.77 64.61 Td [<28382c33> -2.32 <2529>] TJ ET
Q }}%

--- StripMime Report -- processed MIME parts ---
multipart/mixed
  text/plain (text body -- kept)
  application/x-sh
  text/plain (text body -- kept)
  text/plain (text body -- kept)
---



More information about the pdftex mailing list