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?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

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:
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

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
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
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Page Layout Software

From novice to tech pro — start learning today.