Solved

Latex - input file in pdf comment

Posted on 2012-03-30
8
860 Views
Last Modified: 2012-06-27
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
0
Comment
Question by:peclat
  • 4
8 Comments
 

Author Comment

by:peclat
Comment Utility
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
 

Author Comment

by:peclat
Comment Utility
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
 
LVL 45

Expert Comment

by:aikimark
Comment Utility
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
 

Accepted Solution

by:
peclat earned 0 total points
Comment Utility
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
 

Author Closing Comment

by:peclat
Comment Utility
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

Featured Post

What Security Threats Are You Missing?

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

Join & Write a Comment

Workplace bullying has increased with the use of email and social media. Retain evidence of this with email archiving to protect your employees.
If you’re thinking to yourself “That description sounds a lot like two people doing the work that one could accomplish,” you’re not alone.
The viewer will learn how to successfully download and install the SARDU utility on Windows 7, without downloading adware.
An overview on how to enroll an hourly employee into the employee database and how to give them access into the clock in terminal.

762 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

15 Experts available now in Live!

Get 1:1 Help Now