Difference between revisions of "Command/ attachment"

From Wiki
Jump to navigation Jump to search
Line 25: Line 25:
 
<cd:description><!-- the long description of the command goes here -->
 
<cd:description><!-- the long description of the command goes here -->
 
</cd:description>
 
</cd:description>
<cd:examples><cd:example title="Use of attachment with customized symbol (you need to create a file &quot;myattachment.txt&quot;), that why the demo here doesn't show attachment."><context source="yes" text="produces">
+
<cd:examples><cd:example title="Use of attachment with customized symbol (the file &quot;myattachment.txt&quot; should exists, that why the demo here does not show attachment...)"><context source="yes" text="produces">
 
\setuppapersize[A6,landscape]
 
\setuppapersize[A6,landscape]
  
Line 34: Line 34:
 
%------------------------------------------------------------------------------
 
%------------------------------------------------------------------------------
  
\startuseMPgraphic{myattachmentsymbol}  % #1 - Draw a symbol, here a paperclip!                  
+
\startuseMPgraphic{myattachmentsymbol}  % #1 - Draw a symbol, here a paperclip!
path pa;
+
path pa;
 
numeric u; u=1mm;
 
numeric u; u=1mm;
 
numeric Ra; Ra=u/2;  numeric Rb; Rb=1.5Ra;  numeric Rc; Rc=1.35Rb;
 
numeric Ra; Ra=u/2;  numeric Rb; Rb=1.5Ra;  numeric Rc; Rc=1.35Rb;
Line 56: Line 56:
 
\stopuseMPgraphic
 
\stopuseMPgraphic
  
%------------------------------------------------------------------------------        
+
%------------------------------------------------------------------------------
  
 
\definesymbol                            % #2 - Define the drawing as a symbol
 
\definesymbol                            % #2 - Define the drawing as a symbol
Line 71: Line 71:
 
\starttext                                                        % #4 - Use it
 
\starttext                                                        % #4 - Use it
  
Text before  
+
Text before
 
\attachment
 
\attachment
 
   [file={myattachment.txt},
 
   [file={myattachment.txt},

Revision as of 11:20, 28 November 2020


\attachment

Summary

The instances of \attachment are used for inclusion of attachment files into the PDF output.

Instances

\attachment

Settings instance

\ATTACHMENT[...][...=...,...]
[...]name
...=...,...inherits from \setupattachment

Description

Examples

Use of attachment with customized symbol (the file "myattachment.txt" should exists, that why the demo here does not show attachment...)

\setuppapersize[A6,landscape]

%------------------------------------------------------------------------------

\setupinteraction[state=start]                      % #0 - Activate interaction

%------------------------------------------------------------------------------

\startuseMPgraphic{myattachmentsymbol}  % #1 - Draw a symbol, here a paperclip!
path pa;
numeric u; u=1mm;
numeric Ra; Ra=u/2;  numeric Rb; Rb=1.5Ra;  numeric Rc; Rc=1.35Rb;
numeric La; La=3.5u; numeric Lb; Lb=-La/10; numeric Lc; Lc=1.2*La;

pair a[];
a0=(0,0);
a1=(La,0);        a2=(La+Ra,-Ra);         a3=(La,-2Ra);
a4=(Lb,-2Ra);     a5=(Lb-Rb,-2Ra+Rb);     a6=(Lb,-2Ra+2Rb);
a7=(Lc,-2Ra+2Rb); a8=(Lc+Rc,-2Ra+2Rb-Rc); a9=(Lc,-2Ra+2Rb-2Rc);
a10=(1u,-2Ra+2Rb-2Rc);

pa := (a0--a1..a2..a3--a4..a5..a6--a7..a8..a9--a10) rotated 45;

path pb;
pb := fullcircle scaled (2.2*(Lc-Lb-Rb)) shifted (center(pa)) ;
fill pb withcolor 0.5white;
pickup pencircle scaled (1.5*(Rb-Ra))   ;
draw pa  withcolor white;
\stopuseMPgraphic

%------------------------------------------------------------------------------

\definesymbol                             % #2 - Define the drawing as a symbol
  [myattachmentsym]
  [\useMPgraphic{myattachmentsymbol}]

%------------------------------------------------------------------------------

\setupattachments                          % #3 - Use the symbol for attachment
  [symbol=myattachmentsym]

%------------------------------------------------------------------------------

\starttext                                                        % #4 - Use it

Text before
\attachment
  [file={myattachment.txt},
   title={attachment title},
   location=rightmargin]
and after.

\stoptext

produces

Notes

See also

Help from ConTeXt-Mailinglist/Forum

All issues with: