Q: I have been tasked with trying to automate the printing of PDF’s
complete with the text from the annotations on each page. Now, I’ve
tried to set each annotation to be printable and I can get the
annotation to show up, but I haven’t found a way to expand all of the
annotations so you can see the text prior to printing them. Can that
The other way I was trying to do this was to attempt to duplicate the
way Adobe Professional prints these. Basically Adobe Professional
will shrink the contents of the page to about 50% of its original size
and take the text from the annotations and place it over to the right
of the page. It basically just extracts the annotation text and
places it on the white space on the page and draws a line to the
Long story short, are there any options that I have to get PDF’s
printed with all of their annotation text on the page? I’ve tried
messing around with the newest version of PDFNet and the print sample
code it came with. However, it didn’t do what I was looking for
although I might not have set it up properly.
A: At the moment there is no built-in option related to automatic
comment printing, however using the existing API-s you can print
comments in many ways. For example, to open all pop-up you can iterate
through all annotations as set the ‘Open’ entry on all 'Popup'
annotations to true (annot.GetSDFObj().PutBool("Open", true)).
You can also print all pages then output all comments, or you could
scale down the pages and output comments similar to Acrobat Pro.
Since you are using rather old version of PDFNet (v4) I assume that
you are using pdfdraw.DrawInRect() to print the pages. You could pass
in a smaller rectangle in this method (to indicate scaled down
location of the page) and then output annotation text to the right.
You could use PDFNet annotation API (http://www.pdftron.com/pdfnet/
samplecode.html#Annotation , http://www.pdftron.com/pdfnet/html/inherits.html)
to iterate through all annotations on a given page and extract their
text content (e.g. annot.GetContents().ConvertToNativeWString()) then
output the text on the print DP using standard GDI calls. Using PDFNet
4.0.9 you should be able to access annotation using the low-level API
but it may require a bit more coding than using the current version.