How to embedded source code on-demand into PDF?
Clash Royale CLAN TAG#URR8PPP
up vote
6
down vote
favorite
I wondered if its possible to embed source code of some software you are writing about into the PDF but not displayed by default. E.g. you have a long script I would be nice if the user/reader could click on a link if he needs details, and see the source code of that script.
Best would be if this can be rendered with syntax highlighting (by listings or minted package).
So far I am only aware of either use ECMAscript (which seems not supported by latex) or by OCG layers, as tooltips. For both I am unsure if they support syntax highlighting.
As a workaround I would do it as in the old days with an appendix and hyperref to it.
Do you have any better suggestion?
pdf sourcecode syntax-highlighting interaction
add a comment |Â
up vote
6
down vote
favorite
I wondered if its possible to embed source code of some software you are writing about into the PDF but not displayed by default. E.g. you have a long script I would be nice if the user/reader could click on a link if he needs details, and see the source code of that script.
Best would be if this can be rendered with syntax highlighting (by listings or minted package).
So far I am only aware of either use ECMAscript (which seems not supported by latex) or by OCG layers, as tooltips. For both I am unsure if they support syntax highlighting.
As a workaround I would do it as in the old days with an appendix and hyperref to it.
Do you have any better suggestion?
pdf sourcecode syntax-highlighting interaction
add a comment |Â
up vote
6
down vote
favorite
up vote
6
down vote
favorite
I wondered if its possible to embed source code of some software you are writing about into the PDF but not displayed by default. E.g. you have a long script I would be nice if the user/reader could click on a link if he needs details, and see the source code of that script.
Best would be if this can be rendered with syntax highlighting (by listings or minted package).
So far I am only aware of either use ECMAscript (which seems not supported by latex) or by OCG layers, as tooltips. For both I am unsure if they support syntax highlighting.
As a workaround I would do it as in the old days with an appendix and hyperref to it.
Do you have any better suggestion?
pdf sourcecode syntax-highlighting interaction
I wondered if its possible to embed source code of some software you are writing about into the PDF but not displayed by default. E.g. you have a long script I would be nice if the user/reader could click on a link if he needs details, and see the source code of that script.
Best would be if this can be rendered with syntax highlighting (by listings or minted package).
So far I am only aware of either use ECMAscript (which seems not supported by latex) or by OCG layers, as tooltips. For both I am unsure if they support syntax highlighting.
As a workaround I would do it as in the old days with an appendix and hyperref to it.
Do you have any better suggestion?
pdf sourcecode syntax-highlighting interaction
asked Aug 20 at 8:53
math
1,74021623
1,74021623
add a comment |Â
add a comment |Â
1 Answer
1
active
oldest
votes
up vote
8
down vote
accepted
Yes, you may embed your source code as a file in the pdf. I'm using usually the package attachfile, but there are some more, the embedfile package e.g. or attachfile2.
Using attachfile I'm printing an icon into the margin and explain in the PDF text that clicking on the symbol will provide the attached file.
Please note that there is a difference between attaching and embedding at the PDF file level, see the documentation of the packages.
â TeXnician
Aug 20 at 9:01
@TeXnician the documentation of attachfile says "This package defines an attachfile command that lets you attach arbitrary files to a pdf document. These files are embedded right in the pdf file, so they get transmitted along with it." That sounds like there is no difference?
â lucidbrot
Aug 20 at 11:14
1
@lucidbrot You need to read the right documentation (attachfile2/embedfile): "The PDF format ([3]) allows the inclusion of fies inside the PDF document. The included fies can be bound to an annotation on a page. Or they can be recorded in a sorted list of embedded fies. The packages attachfie or attachfie2 follow the fist approach, package embedfie uses the latter method." Of course that does not explain the technical details, but it gives the right hint.
â TeXnician
Aug 20 at 11:22
Yes this is quite cool. Unfortunately not all PDF readers can handle it, e.g. I tried to open with firefox builtin reader and no action took place. But with other readers I had success, very neat. Thank all of you so much.
â math
Aug 20 at 11:38
1
@lucidbrot If I remember correctly you'll find the PDF specification online which should contain these details. Concerning the linking I think they are quite equivalent.
â TeXnician
Aug 20 at 12:17
 |Â
show 5 more comments
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
up vote
8
down vote
accepted
Yes, you may embed your source code as a file in the pdf. I'm using usually the package attachfile, but there are some more, the embedfile package e.g. or attachfile2.
Using attachfile I'm printing an icon into the margin and explain in the PDF text that clicking on the symbol will provide the attached file.
Please note that there is a difference between attaching and embedding at the PDF file level, see the documentation of the packages.
â TeXnician
Aug 20 at 9:01
@TeXnician the documentation of attachfile says "This package defines an attachfile command that lets you attach arbitrary files to a pdf document. These files are embedded right in the pdf file, so they get transmitted along with it." That sounds like there is no difference?
â lucidbrot
Aug 20 at 11:14
1
@lucidbrot You need to read the right documentation (attachfile2/embedfile): "The PDF format ([3]) allows the inclusion of fies inside the PDF document. The included fies can be bound to an annotation on a page. Or they can be recorded in a sorted list of embedded fies. The packages attachfie or attachfie2 follow the fist approach, package embedfie uses the latter method." Of course that does not explain the technical details, but it gives the right hint.
â TeXnician
Aug 20 at 11:22
Yes this is quite cool. Unfortunately not all PDF readers can handle it, e.g. I tried to open with firefox builtin reader and no action took place. But with other readers I had success, very neat. Thank all of you so much.
â math
Aug 20 at 11:38
1
@lucidbrot If I remember correctly you'll find the PDF specification online which should contain these details. Concerning the linking I think they are quite equivalent.
â TeXnician
Aug 20 at 12:17
 |Â
show 5 more comments
up vote
8
down vote
accepted
Yes, you may embed your source code as a file in the pdf. I'm using usually the package attachfile, but there are some more, the embedfile package e.g. or attachfile2.
Using attachfile I'm printing an icon into the margin and explain in the PDF text that clicking on the symbol will provide the attached file.
Please note that there is a difference between attaching and embedding at the PDF file level, see the documentation of the packages.
â TeXnician
Aug 20 at 9:01
@TeXnician the documentation of attachfile says "This package defines an attachfile command that lets you attach arbitrary files to a pdf document. These files are embedded right in the pdf file, so they get transmitted along with it." That sounds like there is no difference?
â lucidbrot
Aug 20 at 11:14
1
@lucidbrot You need to read the right documentation (attachfile2/embedfile): "The PDF format ([3]) allows the inclusion of fies inside the PDF document. The included fies can be bound to an annotation on a page. Or they can be recorded in a sorted list of embedded fies. The packages attachfie or attachfie2 follow the fist approach, package embedfie uses the latter method." Of course that does not explain the technical details, but it gives the right hint.
â TeXnician
Aug 20 at 11:22
Yes this is quite cool. Unfortunately not all PDF readers can handle it, e.g. I tried to open with firefox builtin reader and no action took place. But with other readers I had success, very neat. Thank all of you so much.
â math
Aug 20 at 11:38
1
@lucidbrot If I remember correctly you'll find the PDF specification online which should contain these details. Concerning the linking I think they are quite equivalent.
â TeXnician
Aug 20 at 12:17
 |Â
show 5 more comments
up vote
8
down vote
accepted
up vote
8
down vote
accepted
Yes, you may embed your source code as a file in the pdf. I'm using usually the package attachfile, but there are some more, the embedfile package e.g. or attachfile2.
Using attachfile I'm printing an icon into the margin and explain in the PDF text that clicking on the symbol will provide the attached file.
Yes, you may embed your source code as a file in the pdf. I'm using usually the package attachfile, but there are some more, the embedfile package e.g. or attachfile2.
Using attachfile I'm printing an icon into the margin and explain in the PDF text that clicking on the symbol will provide the attached file.
edited Aug 20 at 9:03
answered Aug 20 at 8:58
Keks Dose
19.8k35190
19.8k35190
Please note that there is a difference between attaching and embedding at the PDF file level, see the documentation of the packages.
â TeXnician
Aug 20 at 9:01
@TeXnician the documentation of attachfile says "This package defines an attachfile command that lets you attach arbitrary files to a pdf document. These files are embedded right in the pdf file, so they get transmitted along with it." That sounds like there is no difference?
â lucidbrot
Aug 20 at 11:14
1
@lucidbrot You need to read the right documentation (attachfile2/embedfile): "The PDF format ([3]) allows the inclusion of fies inside the PDF document. The included fies can be bound to an annotation on a page. Or they can be recorded in a sorted list of embedded fies. The packages attachfie or attachfie2 follow the fist approach, package embedfie uses the latter method." Of course that does not explain the technical details, but it gives the right hint.
â TeXnician
Aug 20 at 11:22
Yes this is quite cool. Unfortunately not all PDF readers can handle it, e.g. I tried to open with firefox builtin reader and no action took place. But with other readers I had success, very neat. Thank all of you so much.
â math
Aug 20 at 11:38
1
@lucidbrot If I remember correctly you'll find the PDF specification online which should contain these details. Concerning the linking I think they are quite equivalent.
â TeXnician
Aug 20 at 12:17
 |Â
show 5 more comments
Please note that there is a difference between attaching and embedding at the PDF file level, see the documentation of the packages.
â TeXnician
Aug 20 at 9:01
@TeXnician the documentation of attachfile says "This package defines an attachfile command that lets you attach arbitrary files to a pdf document. These files are embedded right in the pdf file, so they get transmitted along with it." That sounds like there is no difference?
â lucidbrot
Aug 20 at 11:14
1
@lucidbrot You need to read the right documentation (attachfile2/embedfile): "The PDF format ([3]) allows the inclusion of fies inside the PDF document. The included fies can be bound to an annotation on a page. Or they can be recorded in a sorted list of embedded fies. The packages attachfie or attachfie2 follow the fist approach, package embedfie uses the latter method." Of course that does not explain the technical details, but it gives the right hint.
â TeXnician
Aug 20 at 11:22
Yes this is quite cool. Unfortunately not all PDF readers can handle it, e.g. I tried to open with firefox builtin reader and no action took place. But with other readers I had success, very neat. Thank all of you so much.
â math
Aug 20 at 11:38
1
@lucidbrot If I remember correctly you'll find the PDF specification online which should contain these details. Concerning the linking I think they are quite equivalent.
â TeXnician
Aug 20 at 12:17
Please note that there is a difference between attaching and embedding at the PDF file level, see the documentation of the packages.
â TeXnician
Aug 20 at 9:01
Please note that there is a difference between attaching and embedding at the PDF file level, see the documentation of the packages.
â TeXnician
Aug 20 at 9:01
@TeXnician the documentation of attachfile says "This package defines an attachfile command that lets you attach arbitrary files to a pdf document. These files are embedded right in the pdf file, so they get transmitted along with it." That sounds like there is no difference?
â lucidbrot
Aug 20 at 11:14
@TeXnician the documentation of attachfile says "This package defines an attachfile command that lets you attach arbitrary files to a pdf document. These files are embedded right in the pdf file, so they get transmitted along with it." That sounds like there is no difference?
â lucidbrot
Aug 20 at 11:14
1
1
@lucidbrot You need to read the right documentation (attachfile2/embedfile): "The PDF format ([3]) allows the inclusion of fies inside the PDF document. The included fies can be bound to an annotation on a page. Or they can be recorded in a sorted list of embedded fies. The packages attachfie or attachfie2 follow the fist approach, package embedfie uses the latter method." Of course that does not explain the technical details, but it gives the right hint.
â TeXnician
Aug 20 at 11:22
@lucidbrot You need to read the right documentation (attachfile2/embedfile): "The PDF format ([3]) allows the inclusion of fies inside the PDF document. The included fies can be bound to an annotation on a page. Or they can be recorded in a sorted list of embedded fies. The packages attachfie or attachfie2 follow the fist approach, package embedfie uses the latter method." Of course that does not explain the technical details, but it gives the right hint.
â TeXnician
Aug 20 at 11:22
Yes this is quite cool. Unfortunately not all PDF readers can handle it, e.g. I tried to open with firefox builtin reader and no action took place. But with other readers I had success, very neat. Thank all of you so much.
â math
Aug 20 at 11:38
Yes this is quite cool. Unfortunately not all PDF readers can handle it, e.g. I tried to open with firefox builtin reader and no action took place. But with other readers I had success, very neat. Thank all of you so much.
â math
Aug 20 at 11:38
1
1
@lucidbrot If I remember correctly you'll find the PDF specification online which should contain these details. Concerning the linking I think they are quite equivalent.
â TeXnician
Aug 20 at 12:17
@lucidbrot If I remember correctly you'll find the PDF specification online which should contain these details. Concerning the linking I think they are quite equivalent.
â TeXnician
Aug 20 at 12:17
 |Â
show 5 more comments
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2ftex.stackexchange.com%2fquestions%2f446779%2fhow-to-embedded-source-code-on-demand-into-pdf%23new-answer', 'question_page');
);
Post as a guest
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password