summaryrefslogtreecommitdiff
path: root/Master/texmf-dist/tex/latex/intopdf/intopdf.sty
blob: 42c0b6c3ab898e922bc75625f7e7eb570a6045ff (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
%%
%% This is file `intopdf.sty',
%% generated with the docstrip utility.
%%
%% The original source files were:
%%
%% intopdf.dtx  (with options: `package')
%% 
%% Copyright (C) 2020 by Marcel Krueger
%%
%% This file may be distributed and/or modified under the
%% conditions of the LaTeX Project Public License, either
%% version 1.3c of this license or (at your option) any later
%% version. The latest version of this license is in:
%%
%% http://www.latex-project.org/lppl.txt
%%
%% and version 1.3 or later is part of all distributions of
%% LaTeX version 2005/12/01 or later.
\NeedsTeXFormat{LaTeX2e}
\RequirePackage{expl3,xparse}
\ProvidesExplPackage
  {intopdf}
  {2020/03/13}
  {0.3.0}
  {Embed non-PDF files into PDF with hyperlink}

\RequirePackage{l3pdf,hyperref}
\msg_new:nnnn{intopdf}{engine-unsupported}
  {Your~TeX~engine~is~not~supported~by~intopdf.}
  {To~use~intopdf,~you~have~to~use~pdfLaTeX~or~LuaLaTeX.}
\cs_generate_variant:Nn\str_case:nnF{VnF}
\str_case:VnF\c_sys_engine_str{
  {pdftex}{
    \cs_new:Nn\__intopdf_escape_name:n{\pdfescapename{#1}}
    \cs_new:Nn\__intopdf_escape_string:n{(\pdfescapestring{#1})}
  }
  {luatex}{
    \RequirePackage{pdftexcmds}
    \cs_new:Nn\__intopdf_escape_name:n{\pdf@escapename{#1}}
    \cs_new:Nn\__intopdf_escape_string:n{(\pdf@escapestring{#1})}
  }
}{
  \msg_critical:nn{intopdf}{engine-unsupported}
}
\cs_new_protected:Nn\intopdf_attach_link:nnnnn{
  \pdf_object_now:nx {fstream} { {
    /Subtype /\__intopdf_escape_name:n { #3 }
  } { #2 } }
  \pdf_object_now:nx {dict} {
    /Type /Filespec
    /F \__intopdf_escape_string:n { #1 }
    /EF << /F~\pdf_object_last: >>
    /Desc \__intopdf_escape_string:n { #4 }
  }
  \__pdf_backend_link_begin_user:nnw {
    \Hy@setpdfborder
    \tl_if_empty:NF\@pdfhighlight{
      /H\@pdfhighlight
    }
    \cs_if_free:NF\@urlbordercolor{
      /C[\@urlbordercolor]
    }
  }{
    /Subtype /Link
  }
    \__pdf_backend_link_begin_user:nnw { } {
      /Subtype /FileAttachment
      /FS~\pdf_object_last:
      /F~416
      /CA~0
      /Contents \__intopdf_escape_string:n{#4}
    }
      #5
    \__pdf_backend_link_end:
  \__pdf_backend_link_end:
}
\cs_new_protected:Npn \intopdf_attach_link:nnnn #1{
  \intopdf_attach_link:nnnnn{#1}{#1}
}
\NewDocumentCommand\attachandlink{O{#2}mr[]mm}{
  \intopdf_attach_link:nnnnn{#1}{#2}{#3}{#4}{#5}
}
\endinput
%%
%% End of file `intopdf.sty'.