PDF Printing with Annotation Text

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
be done?

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
original annotation.

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.

Q: The route I'm trying accomplish is to scale down the page and place
the comments from the annotations next to the scaled down page
contents. I'm currently have an issue with this though. This is what
I'm doing:

1: I scale down the page to ~30% of the original size of the page.
2: Then I want to move the scaled down page contents over to the left
hand side of the page. To this I use the following code:

          Rect media_box = itr.Current().GetMediaBox();
                    media_box.y1 = media_box.y1 * .5;
                    media_box.y2 = media_box.y2 * .5;

The issue I'm having is that when I move the scaled down content, the
page size "automatically" changes. Prior to calling the above code my
page width is 720, however after calling this code the page width is
396. What can I do to move the scaled down page width without
changing the actual page size?

One thing to keep in mind is that the page content has annotations on
it and I want to make sure that those come along for the ride without
moving. I've tried this page for help:
However, that code doesn't seem to move the annotations to the correct
location in conjunction to where the page contents are.
A: You don’t necessarily need to edit the page (since it is more
work). You could instead specify a different page fix box in the call
to pdfdraw.DrawInRect(). PDFNet will render the page within the
provided rectangle and you are free to add annotation text content and
draw connecting lines.