summaryrefslogtreecommitdiff
path: root/tex/context/base/mkiv/back-pdf.mkiv
blob: 697aa311f4982be4a57557199719659b99d77fbf (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
%D \module
%D   [       file=back-pdf,
%D        version=2009.04.15,
%D          title=\CONTEXT\ Backend Macros,
%D       subtitle=\PDF,
%D         author=Hans Hagen,
%D           date=\currentdate,
%D      copyright={PRAGMA ADE \& \CONTEXT\ Development Team}]
%C
%C This module is part of the \CONTEXT\ macro||package and is
%C therefore copyrighted by \PRAGMA. See mreadme.pdf for
%C details.

%D The less there is here, the better. After a decade it is time to remove the \type
%D {\pdf*} ones completely. For the moment I keep them commented but even that will
%D go away.

\writestatus{loading}{ConTeXt Backend Macros / PDF}

\registerctxluafile{lpdf-ini}{optimize}
\registerctxluafile{lpdf-nod}{}
\registerctxluafile{lpdf-eng}{optimize}
\registerctxluafile{lpdf-col}{}
\registerctxluafile{lpdf-xmp}{}
\registerctxluafile{lpdf-ano}{}
\registerctxluafile{lpdf-res}{}
\registerctxluafile{lpdf-mis}{}
\registerctxluafile{lpdf-ren}{}
\registerctxluafile{lpdf-grp}{}
\registerctxluafile{lpdf-wid}{}
\registerctxluafile{lpdf-fld}{}
\registerctxluafile{lpdf-mov}{}
\registerctxluafile{lpdf-u3d}{} % this will become a module
\registerctxluafile{lpdf-swf}{} % this will become a module
\registerctxluafile{lpdf-tag}{}
\registerctxluafile{lpdf-fmt}{}
\registerctxluafile{lpdf-pde}{}
\registerctxluafile{lpdf-epa}{}
\registerctxluafile{lpdf-fnt}{}

\registerctxluafile{back-pdp}{}
\registerctxluafile{back-pdf}{} % some code will move to lpdf-*

\loadmarkfile{back-u3d} % this will become a module
\loadmarkfile{back-swf} % this will become a module

\unprotect

%D We will minimize the number of calls to \PDF\ specific primitives and delegate
%D all management and injection of code to the backend.
%D
%D Because we do a lot in \LUA\ and don't want interferences, we nil most of the
%D \PDFTEX\ primitives. Of course one can always use the \type {\pdfvariable},
%D \type {\pdfextension} and \type {\pdffeedback} primitives but it will probably
%D have bad side effects.

\unexpanded\def\pdfextension{\clf_pdfextension}
           \def\pdffeedback {\clf_pdffeedback}

%D For the moment we keep this for tikz but hopefully it will at some point use
%D the proper ones. Consider them obsolete:

\unexpanded\def\pdfliteral  {\clf_pdfliteral}
\unexpanded\def\pdfobj      {\clf_pdfobj}%
\unexpanded\def\pdflastobj  {\numexpr\clf_pdflastobj\relax}
\unexpanded\def\pdfrefobj   {\clf_pdfrefobj }

\unexpanded\def\pdfrestore  {\pdfextension restore}
\unexpanded\def\pdfsave     {\pdfextension save}
\unexpanded\def\pdfsetmatrix{\pdfextension setmatrix}

           \let\pdfxform     \saveboxresource
           \let\pdflastxform \lastsavedboxresourceindex
           \let\pdfrefxform  \useboxresource

%D Here are quick and dirty compression flippers, mostly used when testing something
%D as one can best stick to the defaults that also adapt to specific standards.

\unexpanded\def\nopdfcompression        {\clf_setpdfcompression\zerocount\zerocount}
\unexpanded\def\onlypdfobjectcompression{\clf_setpdfcompression\zerocount\plusthree}
\unexpanded\def\maximumpdfcompression   {\clf_setpdfcompression\plusnine \plusnine }
\unexpanded\def\normalpdfcompression    {\clf_setpdfcompression\plusthree\plusthree}

%D PDF/X (maybe combine the two lua calls)

\setupbackend
  [xmpfile=]

\appendtoks
    \edef\p_file{\backendparameter{xmpfile}}%
    \ifx\p_file\empty\else
      \clf_setxmpfile{\p_file}%
    \fi
\to \everysetupbackend

%D This will change:

\appendtoks
    \clf_setformat
         format  {\backendparameter\c!format}%
         level   {\backendparameter\c!level}%
         option  {\backendparameter\c!option}%
         profile {\backendparameter\c!profile}%
         intent  {\backendparameter\c!intent}%
         file    {\backendparameter\c!file}%
    \relax
\to \everysetupbackend

%D These are the only official methods to add stuff to the resources. If more is
%D needed for third party low level code, it can be added.

\unexpanded\def\pdfbackendsetcatalog       #1#2{\clf_lpdf_addtocatalog{#1}{#2}}
\unexpanded\def\pdfbackendsetinfo          #1#2{\clf_lpdf_addtoinfo{#1}{#2}}
\unexpanded\def\pdfbackendsetname          #1#2{\clf_lpdf_addtonames{#1}{#2}}

\unexpanded\def\pdfbackendsetpageattribute #1#2{\clf_lpdf_addtopageattributes{#1}{#2}}
\unexpanded\def\pdfbackendsetpagesattribute#1#2{\clf_lpdf_addtopagesattributes{#1}{#2}}
\unexpanded\def\pdfbackendsetpageresource  #1#2{\clf_lpdf_addtopageresources{#1}{#2}}

\unexpanded\def\pdfbackendsetextgstate     #1#2{\clf_lpdf_adddocumentextgstate{#1}{#2}}
\unexpanded\def\pdfbackendsetcolorspace    #1#2{\clf_lpdf_adddocumentcolorspace{#1}{#2}}
\unexpanded\def\pdfbackendsetpattern       #1#2{\clf_lpdf_adddocumentpattern{#1}{#2}}
\unexpanded\def\pdfbackendsetshade         #1#2{\clf_lpdf_adddocumentshade{#1}{#2}}

           \def\pdfbackendcurrentresources     {\clf_lpdf_collectedresources}
           \def\pdfcolor                     #1{\clf_lpdf_color\numexpr\thecolorattribute{#1}\relax}

%D This is a temporary hack mthat will be removed, improved or somehow can become
%D default.

\def\TransparencyHack{\setupcolors[\c!pagecolormodel=\v!auto]}

%D Just in case one needs this \unknown:
%D
%D \starttyping
%D text \pdfbackendactualtext{Meier}{Müller} text
%D \stoptyping

\unexpanded\def\pdfbackendactualtext#1#2% not interfaced
  {\clf_startactualtext{#2}%
   #1%
   \clf_stopactualtext}

\let\pdfactualtext\pdfbackendactualtext

%D Bah, this is also needed for tikz:

\ifdefined\pdfsavepos\else
    \let\pdfsavepos \savepos
    \let\pdflastxpos\lastxpos
    \let\pdflastypos\lastypos
\fi

\protect \endinput