Printing filled form annotations using iOS AirPrint


We are evaluating PDFTron iOS library in order to integrate it in one
of our products and it seems to meet many of our needs,
but we are experiencing some issues.

We need to Print a PDF with text forms edited by the user and,
starting from PDFViewCtrl
app example, we have implemented a little addiction to interact with
AirPrint's API.

ISSUE 1 : Your library supports Text Fields, so we perform a
conversion from PDF to NSData with the following commands:

                       SaveOptions aBuff = e_linearized;
                       NSData* aData = [docToOpen SaveToBuf:aBuff];
                       [self printData:aData]; //
custom method

DEFECT : We are able to print the PDF and the content of txt
fields. But instead of the inserted character, we see some strange
This looks much more an encoding or font issue, have you ever noticed
anything like this?
It is possible to overcome the issue?

ISSUE 2 : Trying to workaround the issue 1, we have tested a
FieldIteration approach: our assumption was that if we can iterate and
informations about the state of fields contained in the pdf, we could
have been able to print text contents as overlayered to the PDF.
That's our test code:

               FieldIterator* aFI=[docToOpen GetFieldIterator];
               while ([aFI HasNext]) {
                       [aFI Next]; Field* field = [aFI Current];
                       FieldType f_type = field.GetType;
                       NSLog(@"iterating next Field...");
                       if (f_type == e_text) {
                               NSLog(@"TXT field");
                               // do something...
                       }else {
                               NSLog(@"it's another type of field");
                               // do something else...

DEFECT : The application crashes with a exc-bad-access error.

Before trying other workarounds we would like to ask you if we are
correctly handling the print for the PDF with your library or if you
could kindly
provide us an example about how to print a PDF document containing
form field edited by the end-user.


If you are sending the PDF data to AirPrint then Apple’s PDF renderer
will be used to print the document, and unfortunately it has some
deficiencies, especially in the area of annotations (of which forms
are a type). If you save the edited document to disk instead of
printing it and then open it in iBooks, do the form fields display
correctly? My guess is that they do not. One thing worth trying is
saving a temporary copy of the PDF you wish to print and then
flattening the annotations before printing it, which eliminates the
annotations and saves the content directly as part of the pdf. The
call to flatten annotations is would be something similar to
“[myPDFDoc FlattenAnnotations:YES];”. If this doesn’t work, the other
option would be to use the PDFDraw class to rasterize each page, and
print each page using the bitmap data. This would guarantee correct
printing at the expense of larger print jobs.

Note that we intend to make a change in the near future so that all
form fonts are automatically embedded into the PDF. This will remove
the reliance on the PDF viewer's font substitution mechanism. The
feature should be available in either the next release or the one