Latex - input file in pdf comment

Hello,

In Latex, I'm trying to include a file into a PDF comment.
I'm using the \input and \pdfmarginpar commands for that, but I don't get the expected results. Here is my code:
\pdfmarginpar{\input{test}}

Open in new window


The file "test.tex" contains only a few lines of text, without latex commands.
I would like to have the content of test.tex in the generated PDF annotation, but the \input command is not interpreted, so the content of the annotation is textually "\input{test}".
In fact, \pdfmarginpar doesn't interpret any command (I tried with \pdfmarginpar{\texbf{mytext}} that displays "\texbf{mytext}" in the annotation). I understand that we don't need formatting in annotations but not every command is for formatting purposes.

I've tried with some \expandafter, by defining a temporary command to hold the content of the file, but it still doesn't want to interpret the commands within \pdfmarginpar.

\renewcommand{tmpcmd}{\input{test}}
\pdfmarginpar{\tmpcmd}

Open in new window


Also, passing through a command parameter doesn't work:
\newcommand{\putannot}[1]{\pdfmarginpar{#1}}
\putannot{\input{test}}

Open in new window


I've tried to use \marginpar insted of \pdfmarginpar and the content of test.tex is correctly displayed in the margin of my document.


Would someone have an idea on how to extract the content of the \input command in order to pass this result to \pdfmarginpar? How can we interpret a command, store the value and pass it to \pdfmarginpar. Or how can we tell to latex to execute the inner command before the outer one? Or maybe there is another way to make them work together...

It's disappointing because it's like saying to a kid: - "Say goodbye without yelling" - "GOODBYE WITHOUT YELLIIING"

Thank you in advance,
Kind regards,

Alexandre Péclat
peclatAsked:
Who is Participating?

Improve company productivity with a Business Account.Sign Up

x
 
peclatConnect With a Mentor Author Commented:
Hello,

Thank you for the tools listing, but I was trying to automatically add content from external .tex files as annotations to the PDF I'm generating with LaTeX.

I used "was" because I finally found a solution: Instead of using \input{myfile} that is not expanded within the \pdfcomment or \pdfmarginpar commands, I now use \CatchFileDef{\mytext}{myfile} from the "catchfile" package that expands the content of the file into the \mytext argument. Note that it only works with \pdfcomment.

A little "trick", you can't use \CatchFileDef directly followed by \pdfcomment. That will make the \pdfcomment command inactive (I like little latex delights like that :-).
The issue can be resolved by using a command between them, or simply by adding 2 backslashes after the \CatchFileDef command.

So, to summarize:
\usepackage{catchfile}
\usepackage{pdfcomment}

\CatchFileDef{\sometext}{myfile.tex}\\
\pdfcomment{\sometext}

Open in new window


And here you have a pdf annotation with the content of the external file. Fairly simple isn't it?

Thank you anyway for your time.

Kind regards,
Alexandre Péclat
0
 
peclatAuthor Commented:
Hi,

The test.tex file just contains some text (3 lines), there are no commands inside.
But the problem is that  \pdfmarginpar doesn't interpret any command.
Take this simple example:
\newcommand{\myname}{alex}
\pdfmarginpar{\myname}

Open in new window

will produce an annotation with "myname" instead of "alex" written.


However, I came with a solution: using pdfcomment package with command \pdfcomment{\myname} produces the expected result: "alex".
BUT it doesn't work with \include. That's not funny if it's too easy...
Now I have this code:
\pdfcomment{\input{test}}

Open in new window

That produces an annotation with "test" written inside. So this \pdfcomment command interprets \myname, but not \input{}. Maybe putting the result of \input in a temporary command, or using some expandafters (I don't really understand how they work though) will do the trick.

If you have any suggestion, they are welcome. I'll post the solution if I find it.

Thanks for your time.
Kind regards,

Alexandre Péclat
0
 
peclatAuthor Commented:
Hello,

Yes I'm editing a PDF file and I want to integrate PDF annotations (standards from Acrobat) in it. I have the Miktex 2.9 distribution and I use TeXnicCenter 1.0 as editing tool.

Kind regards,
Alexandre Péclat
0
 
aikimarkCommented:
you can upload your PDF file to pdfescape.com and add your annotations
http://www.pdfescape.com/

Inkscape also allows you to annotate your files.  This tool runs on your PC and is a slick image editor (in general).

There are also third-party tools that will allow you to edit PDFs, most of them cheaper than Adobe Acrobat.
0
 
peclatAuthor Commented:
I accepted my own solution because no other solution within the purpose was provided. I finally found the solution and posted it in order to help people with the same problem.
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.