Yes, I have read the PDF Reference 1.6 and regularly re-reading its chapter 8.4 called "Annotations" :). That is why I'm asking you in such details. Cannot say that 1236 pages of the reference gave me much enthusiasm, but... I've already made routine that reads the set of basic "properties" from annotation dictionary into special value-object, that is used for re-creation of rough copy of annotation later. These basic properties are of simple types : integers, floats, arrays of integers/floats, names, strings. Properties of the reference type, which aren't interesting for me for a while for recreation purposes, I represent (for simplicity sake) as references in their string form "{number} {generation} R". Properties of dictionary type are a little bit more complex, but when they consist of the simple types (or insignificant references), they are easy to be read too. Everything is stored just fine in my value-object. And then I encountered property that is of content stream type. I didn't know how to retrieve data from such property, therefore I've asked you for the help (a little bit hasty - before your reply I've found the proper means). Now I know how to extract data from content steams.
Now I'm solving an inverse problem : how to create PDF annotation using pre-populated value-object (container of annotation properties) and iText library. When I started to use iText library, I expected that library will provide necessary simple classes which allow to create blank template for arbitrary annotation object and then populate this template by required data in "field by field" way using appropriate setters. When annotations were of simple type, it worked. But then I've encountered the caret annotations. Such type of annotations wasn't present in the list of creation methods, and I started to find workarounds to solve this problem. Reading the mailing list I found out that I can solve this problem by considering my PdfAnnotation as PdfDictionary and to create caret annotation from, say, text annotation by changing property responsible for annotation type using PdfDictionary's put(PdfName.SUBTYPE, new PdfName("Caret")) method call. This way worked for all simple properties, untill I've enocunered streams. This type of data is a mixed type, and I was confused not knowing how to handle this type of data. Moreover, I was confused by PdfAnnotation's instance method setAppearance() - I thought that if class has such setter method for appearance, then some class should be able to create appearance using appearance-specific methods. But I couldn't find such methods and asked for help. You pointed out that I must go low level - and I did. After additional examining of PDF Reference it seemed to me that I've found the right way of setting the annotation appeearance, but before starting the implementation I asked you to check my logic. And now, knowing all history, could you say, am I on the right way in setting annotation appearance as dictionary of PdfStream objects ? I checked Paulo's suggestion to look into the FdfWriter's and PdfStamperImp's code, but unfortunately I couldn't manage to find the hint for solving my problem. Sorry for the long letter - I wanted to describe the situation as detailed as possible. > You are trying to save & restore annotations, in their > entirety, correct? As such, you need to first write a routine that > will serialize the annotation into a form that will maintain all the necessary > information for recovery/restoration later on. So start with that. > Once you have figure out what you need to store and how - > then you should have a MUCH better understanding of how to put it all > back together (restore). > If you haven't already, you REALLY need to read the PDF Reference concerning annotations... >Leonard ------------------------------------------------------- This SF.net email is sponsored by: Splunk Inc. Do you grep through log files for problems? Stop! Download the new AJAX search engine that makes searching your log files as easy as surfing the web. DOWNLOAD SPLUNK! http://sel.as-us.falkag.net/sel?cmd=lnk&kid=103432&bid=230486&dat=121642 _______________________________________________ iText-questions mailing list iText-questions@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/itext-questions