back-pdf.mkiv /size: 5576 b    last modification: 2020-07-01 14:35
1
%D \module
2
%D [ file=back-pdf,
3
%D version=2009.04.15,
4
%D title=\CONTEXT\ Backend Macros,
5
%D subtitle=\PDF,
6
%D author=Hans Hagen,
7
%D date=\currentdate,
8
%D copyright={PRAGMA ADE \& \CONTEXT\ Development Team}]
9
%C
10
%C This module is part of the \CONTEXT\ macro||package and is
11
%C therefore copyrighted by \PRAGMA. See mreadme.pdf for
12
%C details.
13 14
%D The less there is here, the better. After a decade it is time to remove the \type
15
%D {\pdf*} ones completely. For the moment I keep them commented but even that will
16
%D go away.
17 18
\writestatus
{
loading
}{
ConTeXt
Backend
Macros
/
PDF
}
19 20
\registerctxluafile
{
lpdf
-
ini
}{
optimize
}
21
\registerctxluafile
{
lpdf
-
nod
}{}
22
\registerctxluafile
{
lpdf
-
eng
}{
optimize
}
23
\registerctxluafile
{
lpdf
-
col
}{}
24
\registerctxluafile
{
lpdf
-
xmp
}{}
25
\registerctxluafile
{
lpdf
-
ano
}{}
26
\registerctxluafile
{
lpdf
-
res
}{}
27
\registerctxluafile
{
lpdf
-
mis
}{}
28
\registerctxluafile
{
lpdf
-
ren
}{}
29
\registerctxluafile
{
lpdf
-
grp
}{}
30
\registerctxluafile
{
lpdf
-
wid
}{}
31
\registerctxluafile
{
lpdf
-
fld
}{}
32
\registerctxluafile
{
lpdf
-
mov
}{}
33
\registerctxluafile
{
lpdf
-
u
3
d
}{}
% this will become a module
34
\registerctxluafile
{
lpdf
-
swf
}{}
% this will become a module
35
\registerctxluafile
{
lpdf
-
tag
}{}
36
\registerctxluafile
{
lpdf
-
fmt
}{}
37
\registerctxluafile
{
lpdf
-
pde
}{}
38
\registerctxluafile
{
lpdf
-
epa
}{}
39
\registerctxluafile
{
lpdf
-
fnt
}{}
40 41
\registerctxluafile
{
back
-
pdp
}{}
42
\registerctxluafile
{
back
-
pdf
}{}
% some code will move to lpdf-*
43 44
\loadmarkfile
{
back
-
u
3
d
}
% this will become a module
45
\loadmarkfile
{
back
-
swf
}
% this will become a module
46 47
\unprotect
48 49
%D We will minimize the number of calls to \PDF\ specific primitives and delegate
50
%D all management and injection of code to the backend.
51
%D
52
%D Because we do a lot in \LUA\ and don't want interferences, we nil most of the
53
%D \PDFTEX\ primitives. Of course one can always use the \type {\pdfvariable},
54
%D \type {\pdfextension} and \type {\pdffeedback} primitives but it will probably
55
%D have bad side effects.
56 57
\unexpanded
\def
\pdfextension
{
\clf_pdfextension
}
58
\def
\pdffeedback
{
\clf_pdffeedback
}
59 60
%D For the moment we keep this for tikz but hopefully it will at some point use
61
%D the proper ones. Consider them obsolete:
62 63
\unexpanded
\def\pdfliteral
{
\clf_pdfliteral
}
64
\unexpanded
\def\pdfobj
{
\clf_pdfobj
}
%
65
\unexpanded
\def\pdflastobj
{
\numexpr
\clf_pdflastobj
\relax
}
66
\unexpanded
\def\pdfrefobj
{
\clf_pdfrefobj
}
67 68
\unexpanded
\def\pdfrestore
{
\pdfextension
restore
}
69
\unexpanded
\def\pdfsave
{
\pdfextension
save
}
70
\unexpanded
\def\pdfsetmatrix
{
\pdfextension
setmatrix
}
71 72
\let\pdfxform
\saveboxresource
73
\let\pdflastxform
\lastsavedboxresourceindex
74
\let\pdfrefxform
\useboxresource
75 76
%D Here are quick and dirty compression flippers, mostly used when testing something
77
%D as one can best stick to the defaults that also adapt to specific standards.
78 79
\unexpanded
\def
\nopdfcompression
{
\clf_setpdfcompression
\zerocount\zerocount
}
80
\unexpanded
\def
\onlypdfobjectcompression
{
\clf_setpdfcompression
\zerocount\plusthree
}
81
\unexpanded
\def
\maximumpdfcompression
{
\clf_setpdfcompression
\plusnine
\plusnine
}
82
\unexpanded
\def
\normalpdfcompression
{
\clf_setpdfcompression
\plusthree\plusthree
}
83 84
%D PDF/X (maybe combine the two lua calls)
85 86
\setupbackend
87
[
xmpfile
=]
88 89
\appendtoks
90
\edef
\p_file
{
\backendparameter
{
xmpfile
}}
%
91
\ifx
\empty
\p_file
\else
92
\clf_setxmpfile
{
\p_file
}
%
93
\fi
94
\to
\everysetupbackend
95 96
%D This will change:
97 98
\appendtoks
99
\clf_setformat
100
format
{
\backendparameter
\c!format
}
%
101
level
{
\backendparameter
\c!level
}
%
102
option
{
\backendparameter
\c!option
}
%
103
profile
{
\backendparameter
\c!profile
}
%
104
intent
{
\backendparameter
\c!intent
}
%
105
file
{
\backendparameter
\c!file
}
%
106
\relax
107
\to
\everysetupbackend
108 109
%D These are the only official methods to add stuff to the resources. If more is
110
%D needed for third party low level code, it can be added.
111 112
\unexpanded
\def
\pdfbackendsetcatalog
#
1
#
2
{
\clf_lpdf_addtocatalog
{
#
1
}{
#
2
}}
113
\unexpanded
\def
\pdfbackendsetinfo
#
1
#
2
{
\clf_lpdf_addtoinfo
{
#
1
}{
#
2
}}
114
\unexpanded
\def
\pdfbackendsetname
#
1
#
2
{
\clf_lpdf_addtonames
{
#
1
}{
#
2
}}
115 116
\unexpanded
\def
\pdfbackendsetpageattribute
#
1
#
2
{
\clf_lpdf_addtopageattributes
{
#
1
}{
#
2
}}
117
\unexpanded
\def
\pdfbackendsetpagesattribute
#
1
#
2
{
\clf_lpdf_addtopagesattributes
{
#
1
}{
#
2
}}
118
\unexpanded
\def
\pdfbackendsetpageresource
#
1
#
2
{
\clf_lpdf_addtopageresources
{
#
1
}{
#
2
}}
119 120
\unexpanded
\def
\pdfbackendsetextgstate
#
1
#
2
{
\clf_lpdf_adddocumentextgstate
{
#
1
}{
#
2
}}
121
\unexpanded
\def
\pdfbackendsetcolorspace
#
1
#
2
{
\clf_lpdf_adddocumentcolorspace
{
#
1
}{
#
2
}}
122
\unexpanded
\def
\pdfbackendsetpattern
#
1
#
2
{
\clf_lpdf_adddocumentpattern
{
#
1
}{
#
2
}}
123
\unexpanded
\def
\pdfbackendsetshade
#
1
#
2
{
\clf_lpdf_adddocumentshade
{
#
1
}{
#
2
}}
124 125
\def
\pdfbackendcurrentresources
{
\clf_lpdf_collectedresources
}
126
\def
\pdfcolor
#
1
{
\clf_lpdf_color
\numexpr
\thecolorattribute
{
#
1
}
\relax
}
127 128
%D This is a temporary hack mthat will be removed, improved or somehow can become
129
%D default.
130 131
\def
\TransparencyHack
{
\setupcolors
[
\c!pagecolormodel
=
\v!auto
]
}
132 133
%D Just in case one needs this \unknown:
134
%D
135
%D \starttyping
136
%D text \pdfbackendactualtext{Meier}{Müller} text
137
%D \stoptyping
138 139
\unexpanded
\def
\pdfbackendactualtext
#
1
#
2
% not interfaced
140
{
\clf_startactualtext
{
#
2
}
%
141
#
1
%
142
\clf_stopactualtext
}
143 144
\let
\pdfactualtext\pdfbackendactualtext
145 146
%D Bah, this is also needed for tikz:
147 148
\ifdefined
\pdfsavepos\else
149
\let\pdfsavepos
\savepos
150
\let\pdflastxpos
\lastxpos
151
\let\pdflastypos
\lastypos
152
\fi
153 154
\protect
\endinput
155