diff options
Diffstat (limited to 'Master/texmf-dist/tex/context/base/spec-fdf.mkii')
-rw-r--r-- | Master/texmf-dist/tex/context/base/spec-fdf.mkii | 229 |
1 files changed, 158 insertions, 71 deletions
diff --git a/Master/texmf-dist/tex/context/base/spec-fdf.mkii b/Master/texmf-dist/tex/context/base/spec-fdf.mkii index 6579a9247f6..30e15ff34eb 100644 --- a/Master/texmf-dist/tex/context/base/spec-fdf.mkii +++ b/Master/texmf-dist/tex/context/base/spec-fdf.mkii @@ -191,6 +191,26 @@ \def\appendtoPDFdocumentextgstates#1% {\xdef\docuPDFextgstates{\docuPDFextgstates\space#1}} +%D Patterns (for tikz) + +\let\docuPDFpatterns\empty + +\def\checkPDFpatterns + {\ifx\docuPDFpatterns\empty \else + \ifnum\realpageno=\lastpage\relax + \doPDFdictionaryobject{FDF}{docupatterns}{\docuPDFpatterns}% + \fi + \doPDFgetobjectreference{FDF}{docupatterns}\PDFobjectreference + \doPDFpageresource{/Pattern \PDFobjectreference}% + \fi} + +\appendtoksonce + \checkPDFpatterns +\to \everyshipout + +\def\appendtoPDFdocumentpatterns#1% + {\xdef\docuPDFpatterns{\docuPDFpatterns\space#1}} + %D Another special mechanism (needed for color separation): \let\docuPDFcolorspaces\empty @@ -301,10 +321,20 @@ \addPDFdocumentinfo \to \everyfirstshipout -\def\PDFversion{1.5} +\ifx\pdfminorversion\undefined + \ifx\pdfoptionpdfminorversion\undefined + \newcount\pdfminorversion + \else + \let\pdfminorversion\pdfoptionpdfminorversion + \fi +\fi + +\pdfminorversion=5 + +\def\PDFversion{1.\number\pdfminorversion} \appendtoksonce - \def\PDFversion{1.5}% + \def\PDFversion{1.\the\pdfminorversion}% \let\addPDFdocumentinfo\relax \to \everyresetspecials @@ -347,21 +377,39 @@ \flushPDFpageboxes \to \everyshipout +% \def\doPDFsetupidentity#1#2#3#4#5#6% +% {\bgroup +% \enablePDFdocencoding +% \edef\!!stringa{#5}% +% \ifx\!!stringa\empty \ifx\pdfdate\undefined\else +% \edef\!!stringa{D:\pdfdate}% +% \fi \fi +% \expanded{\doPDFaddtoinfo +% {/Title (#1) +% /Subject (#2) +% /Author (#3) +% /Creator (#4) +% /ModDate (\!!stringa) +% /ID (\jobname.\!!stringa) % needed for pdf/x +% /Keywords (#6)}}% +% \egroup} + \def\doPDFsetupidentity#1#2#3#4#5#6% {\bgroup \enablePDFdocencoding - \edef\!!stringa{#5}% - \ifx\!!stringa\empty \ifx\pdfdate\undefined\else - \edef\!!stringa{D:\pdfdate}% - \fi \fi + \sanitizePDFencoding#1\to\idtitle \stripstring\idtitle + \sanitizePDFencoding#2\to\idsubject\stripstring\idsubject + \sanitizePDFencoding#3\to\idauthor \stripstring\idauthor + \sanitizePDFencoding#4\to\idcreator\stripstring\idcreator + \sanitizePDFencoding#6\to\idkeyword\stripstring\idkeyword \expanded{\doPDFaddtoinfo - {/Title (#1) - /Subject (#2) - /Author (#3) - /Creator (#4) - /ModDate (\!!stringa) - /ID (\jobname.\!!stringa) % needed for pdf/x - /Keywords (#6)}}% + {/Title \ifPDFunicode<\idtitle >\else(\idtitle )\fi + /Subject \ifPDFunicode<\idsubject>\else(\idsubject)\fi + /Author \ifPDFunicode<\idauthor >\else(\idauthor )\fi + /Creator \ifPDFunicode<\idcreator>\else(\idcreator)\fi + /ModDate (#4) + /ID (\jobname.#5) % needed for pdf/x + /Keywords \ifPDFunicode<\idkeyword>\else(\idkeyword)\fi}}% \egroup} %D \macros @@ -1149,10 +1197,8 @@ \def\doPDFinsertbookmark#1#2#3#4#5% level sublevels text page open=1 {\bgroup - % todo, unicode - \sanitizePDFdocencoding#3\to\bookmarktext % uses scratchcounter + \sanitizePDFencoding#3\to\bookmarktext % uses scratchcounter \stripstring\bookmarktext - %\sanitizePDFstring#3\to\bookmarktext \doPDFbookmark{#1}{#2}{\bookmarktext}{#4}{#5}% \egroup} @@ -1171,7 +1217,7 @@ \def\FDFflagMultiLine {4096} % 13 \def\FDFflagNoToggleToOff {16384} % 15 -\def\FDFflagRadio {32768} % 16 +\def\FDFflagRadio {32768} % 16 (not used as such) \def\FDFflagPushButton {65536} % 17 \def\FDFflagPopUp {131072} % 18 \def\FDFflagEdit {262144} % 19 @@ -1376,66 +1422,31 @@ \let\FDFactions\empty -%\def\setFDFactions[#1,#2,#3,#4,#5,#6,#7,#8]% -% {\global\let\FDFactions\empty -% \setFDFaction D#1% mousedown -% \setFDFaction U#2% mouseup -% \setFDFaction E#3% enterregion -% \setFDFaction X#4% exitregion -% \setFDFaction K#5% afterkeystroke -% \setFDFaction F#6% formatresult -% \setFDFaction V#7% validateresult -% \setFDFaction C#8% calculatewhatever -% \ifx\FDFactions\empty\else -% \xdef\FDFactions{/AA << \FDFactions >>}% since 1.3 no longer inherited -% \fi} -%% {\setFDFaction A#2}% mouseup % changed for version 5 - -% \def\setFDFactions[#1,#2,#3,#4,#5,#6,#7,#8,% -% {\global\let\FDFactions\empty -% \setFDFaction D#1% mousedown -% %\setFDFaction U#2% mouseup -% \setFDFaction E#3% enterregion -% \setFDFaction X#4% exitregion -% \setFDFaction K#5% afterkeystroke -% \setFDFaction F#6% formatresult -% \setFDFaction V#7% validateresult -% \setFDFaction C#8% calculatewhatever -% \setFDFactionsmore#2,} - -% \def\setFDFactionsmore#1,#2,#3]% -% {\setFDFaction{Fo}#2% focusin -% \setFDFaction{Bl}#3% focusout % was I (now pdf ref manual explicitly talks about lowercase l) -% \ifx\FDFactions\empty\else -% \xdef\FDFactions{/AA << \FDFactions >>}% since 1.3 no longer inherited -% \fi -% \setFDFaction A#1}% mouseup - \def\setFDFactions[#1,#2,#3,#4,#5,#6,#7,#8,% {\global\let\FDFactions\empty - \setFDFaction D#1% mousedown - \setFDFaction U#2% mouseup - \setFDFaction E#3% enterregion - \setFDFaction X#4% exitregion - \setFDFaction K#5% afterkeystroke - \setFDFaction F#6% formatresult - \setFDFaction V#7% validateresult - \setFDFaction C#8% calculatewhatever + \setFDFaction D#1\relax% mousedown + \setFDFaction U#2\relax% mouseup + \setFDFaction E#3\relax% enterregion + \setFDFaction X#4\relax% exitregion + \setFDFaction K#5\relax% afterkeystroke + \setFDFaction F#6\relax% formatresult + \setFDFaction V#7\relax% validateresult + \setFDFaction C#8\relax% calculatewhatever \setFDFactionsmore} \def\setFDFactionsmore#1,#2]% - {\setFDFaction{Fo}#1% focusin - \setFDFaction{Bl}#2% focusout % was I (now pdf ref manual explicitly talks about lowercase l) + {\setFDFaction{Fo}#1\relax% focusin + \setFDFaction{Bl}#2\relax% focusout % was I (now pdf ref manual explicitly talks about lowercase l) \ifx\FDFactions\empty\else \xdef\FDFactions{/AA << \FDFactions >>}% since 1.3 no longer inherited \fi} % todo, when new var scheme is implemented % -% \setFDFaction{PO}\@@DriverFieldPageOpen -% \setFDFaction{PC}\@@DriverFieldPageClose -% \setFDFaction{PV}\@@DriverFieldPageVisible -% \setFDFaction{PI}\@@DriverFieldPageInVisible +% \setFDFaction{PO}\@@DriverFieldPageOpen\relax +% \setFDFaction{PC}\@@DriverFieldPageClose\relax +% \setFDFaction{PV}\@@DriverFieldPageVisible\relax +% \setFDFaction{PI}\@@DriverFieldPageInVisible\relax %D The event handler becomes something: %D @@ -1444,7 +1455,7 @@ %D /A << /S /JavaScript /JS (...) >> %D \stoptyping -% \def\setFDFaction#1#2% +% \def\setFDFaction#1#2\relax% % {\bgroup % \global\let\sanitizedJScode\empty % \def\setFDFaction##1% @@ -1466,7 +1477,7 @@ % % acrobat 5 supports other that JS actions too -\def\setFDFaction#1#2% +\def\setFDFaction#1#2\relax% {\bgroup \def\docommand{\xdef\FDFactions{\FDFactions /#1 << \lastPDFaction >> }}% \@EA\handlereferenceactions\@EA{#2}\docommand % one level expansion @@ -1486,7 +1497,7 @@ %D a message to the console. \def\testFDFactions - {\def\setFDFaction##1##2% + {\def\setFDFaction##1##2\relax% {\doPSsanitizeJScode console.show();console.println("executing:##1"); \to\sanitizedJScode \edef\FDFactions{\FDFactions /##1 << /S /JavaScript /JS (\sanitizedJScode) >> }}} @@ -1919,6 +1930,11 @@ \def\doFDFpresetcheckfield#1#2#3#4#5#6#7% {\doFDFpresetpushcheckfield{#1}{#2}{#3}{#4}{#5}{#6}{#7}{1}} +% As pdf widgets are rather consistently upward incompatible +% especially with regards to inheritance, the following code is not +% quite okay. I've decided no longer to bother about in it in MkII +% and use a flat model in MkIV which somehow seems to work better. + \def\doFDFpresetradiofield#1#2#3#4#5#6#7#8% {\bgroup \setFDFlayer\@@DriverFieldLayer @@ -2003,13 +2019,19 @@ % seems to be more important than compatibility of documents, which in % turn renders acrobat useless for forms.] Anyway, synchronization is % broken or not depending on the combination pdfversion/acrobatversion. +% +% Hm, nowadays Radio will overload RadiosInUnison so we need to use only one +% of them. \def\doFDFpresetradiorecord#1#2#3#4#5% {\bgroup % < pdf 1.5 (1.5 was broken) % \setFDFswitches[Radio,NoToggleToOff,RadiosInUnison,#3]% % > pdf 1.5 - \setFDFswitches[Radio,RadiosInUnison,#3]% + % \setFDFswitches[Radio,RadiosInUnison,#3]% + % > pdf 1.6 + \setFDFswitches[RadiosInUnison,#3]% + %setFDFswitches[PushButton,RadiosInUnison,#3]% this is what acrobat itself does % older, else fatal error % \setFDFkids[#4][]% % newer @@ -2358,7 +2380,69 @@ \let^^M=\\} \egroup -\let\sanitizePDFencoding\sanitizePDFdocencoding +% \let\sanitizePDFencoding\sanitizePDFdocencoding + +%D The conversions comes down to (for the sake of speed the +%D implementation combines steps): +%D +%D \startitemize +%D \item we expand the \UTF\ sequences into \type {\unicodechar}'s +%D \item spaces become character 255's (so that they are not +%D gobbled in argument fetching +%D \item normal \ASCII\ chars are unchanged +%D \item \par's and alike are converted to \type {\unicodechar}'s +%D \stopitemize +%D +%D This happens by expansion; next we convert the resulting +%D sequence by interpreting the stream. + +\long\def\sanitizePDFuniencoding#1\to#2% + {\enablePDFunicrlf + \simplifycommands % added due to Dohyun Kim + \let\unicodechar\relax % prevent further expansion + \retainlccodes\lccode32=255 % slooow + \lowercasestring\PDFunicodetrigger#1\to#2% + \edef#2{\expandafter\doPDFuni#2\empty\empty}} % slooow + +%D Handling of empty lines: + +\bgroup +\catcode`\^^M=\@@active +\gdef\enablePDFunicrlf% + {\def\\{\unicodechar{13}}% + \def\par{\\\\}% + \catcode`\^^M=\@@active% + \let^^M=\\} +\egroup + +%D Conversion to 16 bit \UNICODE: + +\def\PDFunicodechar#1% + {\@EA\lchexnumbers\@EA{\number\utfdiv{#1}}% + \@EA\lchexnumbers\@EA{\number\utfmod{#1}}} + +\def\PDFunicodetrigger + {\unicodechar{65279}} + +%D The postprocessor: + +\def\doPDFuni#1% + {\ifx#1\relax + \@EA\dodoPDFuni + \else\ifx#1\empty + % quit + \else + \@EAEAEA\nodoPDFuni + \fi\fi#1} + +\def\nodoPDFuni#1% + {\PDFunicodechar{\ifnum`#1=255 32\else`#1\fi}\doPDFuni} + +\def\dodoPDFuni#1#2% + {\PDFunicodechar{#2}\doPDFuni} + +\def\sanitizePDFencoding + {\doifelse\currentregime{utf}{\PDFunicodetrue\sanitizePDFuniencoding}\sanitizePDFdocencoding} %D A bit out of place, but useful: @@ -3279,6 +3363,9 @@ \doifobjectreferencefoundelse{FDF}{docuextgstates} {\doPDFgetobjectreference{FDF}{docuextgstates}\PDFobjectreference \xdef\collectedPDFresources{\collectedPDFresources/ExtGState \PDFobjectreference}}\donothing + \doifobjectreferencefoundelse{FDF}{docupatterns} + {\doPDFgetobjectreference{FDF}{docupatterns}\PDFobjectreference + \xdef\collectedPDFresources{\collectedPDFresources/Pattern \PDFobjectreference}}\donothing \doifobjectreferencefoundelse{FDF}{colorspaces} {\doPDFgetobjectreference{FDF}{colorspaces}\PDFobjectreference \xdef\collectedPDFresources{\collectedPDFresources/ColorSpace \PDFobjectreference}}\donothing |