diff options
Diffstat (limited to 'Master/texmf-dist/tex/context/base/back-pdf.mkiv')
-rw-r--r-- | Master/texmf-dist/tex/context/base/back-pdf.mkiv | 169 |
1 files changed, 169 insertions, 0 deletions
diff --git a/Master/texmf-dist/tex/context/base/back-pdf.mkiv b/Master/texmf-dist/tex/context/base/back-pdf.mkiv new file mode 100644 index 00000000000..2d3ba85248b --- /dev/null +++ b/Master/texmf-dist/tex/context/base/back-pdf.mkiv @@ -0,0 +1,169 @@ +%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] +%C +%C This module is part of the \CONTEXT\ macro||package and is +%C therefore copyrighted by \PRAGMA. See mreadme.pdf for +%C details. + +\writestatus{loading}{ConTeXt Backend Macros / PDF} + +\registerctxluafile{back-pdf}{1.001} % this will change + +\unprotect + +%D We will minimize the number of calls to \PDF\ specific primitives +%D and delegate all management and injection of code to the backend. +%D +%D Here we initialize some internal quantities. + +\pdfoutput = 1 +\pdfhorigin = 1 true in +\pdfvorigin = 1 true in +\pdfimageresolution = 300 +\pdfpkresolution = 600 +\pdfdecimaldigits = 10 +\pdfinclusionerrorlevel = 0 +\pdfminorversion = 5 +%pdfuniqueresname = 1 + +%D This one can be consulted by users although the suffix is also +%D a system mode. + +\setjobsuffix{pdf} + +%D For the moment we keep these. + +\newtoks \pdfbackendeveryximage +\newtoks \pdfbackendeveryxform + +%D These are the only official methods to add stuff to the resources. + +\def\pdfbackendsetcatalog #1#2{\ctxlua{lpdf.addtocatalog ("#1",\!!bs#2\!!es)}} \newtoks\pdfcatalog +\def\pdfbackendsetinfo #1#2{\ctxlua{lpdf.addtoinfo ("#1",\!!bs#2\!!es)}} \newtoks\pdfinfo +\def\pdfbackendsetname #1#2{\ctxlua{lpdf.addtonames ("#1",\!!bs#2\!!es)}} \newtoks\pdfnames + +\def\pdfbackendsetpageattribute #1#2{\ctxlua{lpdf.addtopageattributes ("#1",\!!bs#2\!!es)}} \newtoks\pdfpageresources +\def\pdfbackendsetpagesattribute#1#2{\ctxlua{lpdf.addtopagesattributes("#1",\!!bs#2\!!es)}} \newtoks\pdfpageattr +\def\pdfbackendsetpageresource #1#2{\ctxlua{lpdf.addtopageresources ("#1",\!!bs#2\!!es)}} \newtoks\pdfpagesattr + +\def\pdfbackendsetextgstate #1#2{\ctxlua{lpdf.adddocumentextgstate ("#1",lpdf.verbose(\!!bs#2\!!es))}} +\def\pdfbackendsetcolorspace #1#2{\ctxlua{lpdf.adddocumentcolorspace("#1",lpdf.verbose(\!!bs#2\!!es))}} +\def\pdfbackendsetpattern #1#2{\ctxlua{lpdf.adddocumentpattern ("#1",lpdf.verbose(\!!bs#2\!!es))}} +\def\pdfbackendsetshade #1#2{\ctxlua{lpdf.adddocumentshade ("#1",lpdf.verbose(\!!bs#2\!!es))}} + +\def\pdfbackendcurrentresources {\ctxlua{lpdf.collectedresources()}} + +%D An example of usage is: + +\appendtoks % will change ... + \pdfbackendsetinfo{ConTeXt.Version}{(\contextversion)}% + \pdfbackendsetinfo{ConTeXt.Time} {(\number\normalyear.\twodigits\normalmonth.\twodigits\normalday\space \twodigits\currenthour:\twodigits\currentminute)}% + \pdfbackendsetinfo{ConTeXt.Jobname}{(\jobname)}% + \pdfbackendsetinfo{ConTeXt.Url} {(www.pragma-ade.com)}% +\to \everylastbackendshipout + +%D Unfortunately this is still needed (also for \METAPOST\ to +%D \PDF\ converter): + +\def\doresetmapfilelist + {\global\let\doresetmapfilelist\relax + \pdfmapfile{original-empty.map}} + +\def\doloadmapfile #1#2{\pdfmapfile{#1#2}} +\def\doloadmapline #1#2{\pdfmapline{#1#2}} + +\appendtoksonce \loadallfontmapfiles \to \pdfbackendeveryxform +\appendtoksonce \loadallfontmapfiles \to \pdfbackendeveryximage + +%D Transformations. Some day we will use primitives (once they're fixed). + +\def\dostartrotation#1% grouped + {\forcecolorhack + \pdfliteral{q \ctxlua{lpdf.rotationcm(#1)}}} + +\def\dostoprotation + {\pdfliteral{Q}} + +\def\dostartscaling#1#2% the test is needed because acrobat is bugged! + {\forcecolorhack + \pdfliteral{q \ifdim#1\points=\zeropoint.0001\else#1\fi\space 0 0 + \ifdim#2\points=\zeropoint.0001\else#2\fi\space 0 0 cm}} + +\def\dostopscaling + {\pdfliteral{Q}} + +\def\dostartmirroring{\pdfliteral{-1 0 0 1 0 0 cm}} +\def\dostopmirroring {\pdfliteral{-1 0 0 1 0 0 cm}} + +\def\dostartclipping#1#2#3% todo + {\PointsToBigPoints{#2}\width + \PointsToBigPoints{#3}\height + \grabMPclippath{#1}{1}\width\height{0 0 m \width\space 0 l \width \height l 0 \height l}% + \pdfliteral{q 0 w \MPclippath\space W n}} + +\def\dostopclipping + {\pdfliteral{Q n}} + +%D The following will move to the backend \LUA\ code: + +\appendtoks \ctxlua{backends.codeinjections.finalizepage ()}\to \everybackendshipout % is immediate +\appendtoks \ctxlua{backends.codeinjections.finalizedocument()}\to \everylastbackendshipout % is immediate + +%D Temporary hack, will be removed or improved. + +\def\TransparencyHack{\ctxlua{backends.codeinjections.addtransparencygroup()}} + +%D \macros +%D {dostartobject,dostopobject,doinsertobject} + +%D This will change: + +\newbox\objectbox + +\def\dostartobject#1#2#3#4#5% + {\bgroup + \setbox\objectbox\vbox\bgroup + \def\dodostopobject{\egroup\doregisterobject{#1}{#2}}} + +\def\dostopobject + {\dodostopobject + \egroup} + +\def\doregisterobject#1#2% + {\the\pdfbackendeveryxform + \finalizeobjectbox\objectbox + \immediate\pdfxform resources {\pdfbackendcurrentresources}\objectbox + \dosetobjectreference{#1}{#2}{\the\pdflastxform}} + +\def\doresetobjects + {} + +\def\doinsertobject#1#2% + {\begingroup + \doifobjectreferencefoundelse{#1}{#2} + {\dogetobjectreference{#1}{#2}\PDFobjectreference\pdfrefxform\PDFobjectreference}% + \donothing + \endgroup} + +\def\doPDFgetobjectpage#1#2#3% + {\dogetobjectreferencepage{#1}{#2}#3% + \ifx#3\empty\def#3{\realfolio}\fi} + +\def\doPDFgetobjectpagereference#1#2#3% + {\dogetobjectreferencepage{#1}{#2}#3% + \doPDFgetpagereference{\ifx#3\empty\realfolio\else#3\fi}#3} + +\def\predefinesymbol[#1]% + {\begingroup + \settightobject{SYM}{#1}\hbox{\symbol[#1]}% to be checked ... maybe only fitting + \dogetobjectreference{SYM}{#1}\lastref + \ctxlua{backends.codeinjections.registersymbol("#1",\lastref)}% + \endgroup} + +\protect \endinput |