back-pdf.mkxl /size: 5622 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
-
lmt
}{
optimize
}
22 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
-
img
}{
optimize
}
39
\registerctxluafile
{
lpdf
-
epa
}{}
40
\registerctxluafile
{
lpdf
-
emb
}{
optimize
}
41
\registerctxluafile
{
lpdf
-
fnt
}{}
42 43
\registerctxluafile
{
back
-
pdp
}{}
44
\registerctxluafile
{
back
-
pdf
}{}
% some code will move to lpdf-*
45 46
\loadmarkfile
{
back
-
u
3
d
}
% this will become a module
47
\loadmarkfile
{
back
-
swf
}
% this will become a module
48 49
\unprotect
50 51
%D We will minimize the number of calls to \PDF\ specific primitives and delegate
52
%D all management and injection of code to the backend.
53
%D
54
%D Because we do a lot in \LUA\ and don't want interferences, we nil most of the
55
%D \PDFTEX\ primitives. Of course one can always use the \type {\pdfvariable},
56
%D \type {\pdfextension} and \type {\pdffeedback} primitives but it will probably
57
%D have bad side effects.
58 59
\unexpanded
\def
\pdfextension
{
\clf_pdfextension
}
60
\def
\pdffeedback
{
\clf_pdffeedback
}
61 62
%D For the moment we keep this for tikz but hopefully it will at some point use
63
%D the proper ones. Consider them obsolete:
64 65
\unexpanded
\def\pdfliteral
{
\clf_pdfliteral
}
66
\unexpanded
\def\pdfobj
{
\clf_pdfobj
}
%
67
\unexpanded
\def\pdflastobj
{
\numexpr
\clf_pdflastobj
\relax
}
68
\unexpanded
\def\pdfrefobj
{
\clf_pdfrefobj
}
69 70
\unexpanded
\def\pdfrestore
{
\pdfextension
restore
}
71
\unexpanded
\def\pdfsave
{
\pdfextension
save
}
72
\unexpanded
\def\pdfsetmatrix
{
\pdfextension
setmatrix
}
73 74
\let\pdfxform
\saveboxresource
75
\let\pdflastxform
\lastsavedboxresourceindex
76
\let\pdfrefxform
\useboxresource
77 78
%D Here are quick and dirty compression flippers, mostly used when testing something
79
%D as one can best stick to the defaults that also adapt to specific standards.
80 81
\unexpanded
\def
\nopdfcompression
{
\clf_setpdfcompression
\zerocount\zerocount
}
82
\unexpanded
\def
\onlypdfobjectcompression
{
\clf_setpdfcompression
\zerocount\plusthree
}
83
\unexpanded
\def
\maximumpdfcompression
{
\clf_setpdfcompression
\plusnine
\plusnine
}
84
\unexpanded
\def
\normalpdfcompression
{
\clf_setpdfcompression
\plusthree\plusthree
}
85 86
%D PDF/X (maybe combine the two lua calls)
87 88
\setupbackend
89
[
xmpfile
=]
90 91
\appendtoks
92
\edef
\p_file
{
\backendparameter
{
xmpfile
}}
%
93
\ifempty
\p_file
\else
94
\clf_setxmpfile
{
\p_file
}
%
95
\fi
96
\to
\everysetupbackend
97 98
%D This will change:
99 100
\appendtoks
101
\clf_setformat
102
format
{
\backendparameter
\c!format
}
%
103
level
{
\backendparameter
\c!level
}
%
104
option
{
\backendparameter
\c!option
}
%
105
profile
{
\backendparameter
\c!profile
}
%
106
intent
{
\backendparameter
\c!intent
}
%
107
file
{
\backendparameter
\c!file
}
%
108
\relax
109
\to
\everysetupbackend
110 111
%D These are the only official methods to add stuff to the resources. If more is
112
%D needed for third party low level code, it can be added.
113 114
\unexpanded
\def
\pdfbackendsetcatalog
#
1
#
2
{
\clf_lpdf_addtocatalog
{
#
1
}{
#
2
}}
115
\unexpanded
\def
\pdfbackendsetinfo
#
1
#
2
{
\clf_lpdf_addtoinfo
{
#
1
}{
#
2
}}
116
\unexpanded
\def
\pdfbackendsetname
#
1
#
2
{
\clf_lpdf_addtonames
{
#
1
}{
#
2
}}
117 118
\unexpanded
\def
\pdfbackendsetpageattribute
#
1
#
2
{
\clf_lpdf_addtopageattributes
{
#
1
}{
#
2
}}
119
\unexpanded
\def
\pdfbackendsetpagesattribute
#
1
#
2
{
\clf_lpdf_addtopagesattributes
{
#
1
}{
#
2
}}
120
\unexpanded
\def
\pdfbackendsetpageresource
#
1
#
2
{
\clf_lpdf_addtopageresources
{
#
1
}{
#
2
}}
121 122
\unexpanded
\def
\pdfbackendsetextgstate
#
1
#
2
{
\clf_lpdf_adddocumentextgstate
{
#
1
}{
#
2
}}
123
\unexpanded
\def
\pdfbackendsetcolorspace
#
1
#
2
{
\clf_lpdf_adddocumentcolorspace
{
#
1
}{
#
2
}}
124
\unexpanded
\def
\pdfbackendsetpattern
#
1
#
2
{
\clf_lpdf_adddocumentpattern
{
#
1
}{
#
2
}}
125
\unexpanded
\def
\pdfbackendsetshade
#
1
#
2
{
\clf_lpdf_adddocumentshade
{
#
1
}{
#
2
}}
126 127
\def
\pdfbackendcurrentresources
{
\clf_lpdf_collectedresources
}
128
\def
\pdfcolor
#
1
{
\clf_lpdf_color
\numexpr
\thecolorattribute
{
#
1
}
\relax
}
129 130
%D This is a temporary hack mthat will be removed, improved or somehow can become
131
%D default.
132 133
\def
\TransparencyHack
{
\setupcolors
[
\c!pagecolormodel
=
\v!auto
]
}
134 135
%D Just in case one needs this \unknown:
136
%D
137
%D \starttyping
138
%D text \pdfbackendactualtext{Meier}{Müller} text
139
%D \stoptyping
140 141
\unexpanded
\def
\pdfbackendactualtext
#
1
#
2
% not interfaced
142
{
\clf_startactualtext
{
#
2
}
%
143
#
1
%
144
\clf_stopactualtext
}
145 146
\let
\pdfactualtext\pdfbackendactualtext
147 148
%D Bah, this is also needed for tikz:
149 150
\ifdefined
\pdfsavepos\else
151
\let\pdfsavepos
\savepos
152
\let\pdflastxpos
\lastxpos
153
\let\pdflastypos
\lastypos
154
\fi
155 156
\protect
\endinput
157