14 Replies Latest reply: Sep 4, 2008 6:57 AM by (Leonard_Rosenthol) RSS

    New trouble for today - /OCGs dictionary entry

    andrejusc Community Member
      Hi,

      In original document created with Adobe Illustrator and saved as PDF I could see this /OCProperties entry:

      /OCProperties<</D<</RBGroups[]/ON[22 0 R 26 0 R 44 0 R 49 0 R 53 0 R]/Order 21 0 R>>/OCGs[22 0 R 26 0 R 44 0 R 49 0 R 53 0 R]>>

      Now if I go via PDOCConfigGetOCGOrder/PDOCConfigSetOCGOrder then what I get in result is like this:

      /OCProperties<</RBGroups[]/ON[22 0 R 26 0 R 44 0 R 49 0 R 53 0 R]/Order 21 0 R>>

      i.e. no /D and neither /OCGs is there.

      Should I do that /D and /OCGs entries construction again only via low level Cos?

      The more I work with PDE layer - the more I think it's only for basic functionality and everything else I should do via Cos, unless I'm missing some special caveat about PDE calls.
        • 1. Re: New trouble for today - /OCGs dictionary entry
          Community Member
          That doesn't make any sense, since both D and OCGs are required keys

          What version of Adobe Acrobat & the SDK are you working with?

          Are you sure you aren't doing something after the fact? Are you really looking at the right keys/dictionaries?

          PDE is for content. Cos is for low level document structure. They do two different things.
          • 2. Re: New trouble for today - /OCGs dictionary entry
            andrejusc Community Member
            Adobe Acrobat is of version 7.0.8 Professional
            Adobe SDK is v7.0.5

            Will continue with Cos layer to see what I'm doing wrong...
            • 3. Re: New trouble for today - /OCGs dictionary entry
              Community Member
              Have you tried newer versions of Acrobat?
              • 4. Re: New trouble for today - /OCGs dictionary entry
                andrejusc Community Member
                I think I need one clarification in regards to CosObjCopy usage with copyIndirect set to true.

                Assume I have in source Cos tree:
                ObjA references ObjB
                ObjC also references ObjB

                ObjB has ID of 10

                Now if I do CosObjCopy over ObjA and over ObjC - I get ObjB listed twice in resulting Cos tree with two different IDs. Is it possible to have it only once as in the source? Or the only way to achieve that is to call CosObjCopy over ObjA and over ObjC with copyIndirect set to false and then add that reference to ObjB manually into ObjA and ObjC via additional calls?
                • 5. Re: New trouble for today - /OCGs dictionary entry
                  Community Member
                  If you copy two objects twice - and they each refer to the same object, then you will get two copies of the final object in the new document. You would need to do smart copying to handle maintaining the indirection.

                  What exactly are you copying over? Perhaps you should be using higher level APIs to accomplish what you want?
                  • 6. Re: New trouble for today - /OCGs dictionary entry
                    andrejusc Community Member
                    OK, let me answer your last two questions.

                    > Have you tried newer versions of Acrobat?

                    Acrobat 7.0.x is currently in use by my potential (still!) customer

                    > What exactly are you copying over?

                    I'm strugling with layers, which are referenced via /D/ON, /OCGs in /OCProperties and via /MC entries in /Properties in Resources.

                    If I do /Resources copy via Cos layer with copyIndirect set to true - then layers entries go already into new document, cause are referenced via /MC. Then later I want to copy (also via Cos) that /OCProperties content and here I have that trouble with smart copying, which I assume I need to implement somehow myself...

                    But I think it's quite common situation when several direct objects reference one other direct object, not just for my specific case. I.e. there should be a way from API (specify copyIndirectTwice=false) to avoid that twice indirection appearance in resulting doc.

                    Am I wrong here?
                    • 7. Re: New trouble for today - /OCGs dictionary entry
                      (Aandi_Inston) Community Member
                      >But I think it's quite common situation when several direct objects reference one other direct object,

                      That's not possible, but you can have several objects (direct and/or
                      indirect) referencing on other indirect object.

                      Aandi Inston
                      • 8. Re: New trouble for today - /OCGs dictionary entry
                        Patrick Leckey Community Member
                        > I.e. there should be a way from API (specify copyIndirectTwice=false) to avoid that twice indirection appearance in resulting doc.

                        Not at the Cos-layer, no. It is designed to offer the lowest-possible-level interaction with the PDF structure. You're missing the point of this API set. Higher-level APIs will handle smart copying, but if you use Cos you have to do it yourself.
                        • 9. Re: New trouble for today - /OCGs dictionary entry
                          (Aandi_Inston) Community Member
                          I have found it necessary to implement quite a number of Cos object
                          copiers, each with slightly different properties. Sometimes it's
                          necessary to keep a persistent cache of source:destination mappings
                          for indirect objects to avoid duplication over multiple copy actions.
                          You'll almost always need some kind of cache if you are not to fail
                          and go on forever if an object has recursive references to itself.

                          Aandi Inston
                          • 10. Re: New trouble for today - /OCGs dictionary entry
                            andrejusc Community Member
                            I see. That answers my question. Thanks... I thought it's inside API in some way and telling me (comment from PDL) that I'm missing the point just not right. PDE layer is not powerfull enough to do all required things with content. Or there are some undocumented features of it no one willing to tell.
                            • 11. Re: New trouble for today - /OCGs dictionary entry
                              (Aandi_Inston) Community Member
                              > PDE layer is not powerfull enough to do all required things with content.

                              Well, I don't use it in any of our commercial plug-ins...

                              Aandi Inston
                              • 12. Re: New trouble for today - /OCGs dictionary entry
                                Community Member
                                You need to be VERY careful when managing OCGs with the Cos APIs, as Acrobat keeps its own version of the "active set" and doesn't like it when someone screws with it behind its back. That's why the high level OCG APIs exist for pretty much any operation.

                                Back to the question at hand - what is the HIGH LEVEL thing you are trying to accomplish? Perhaps letting Acrobat copy ENTIRE PAGES across from document->document, andn then removing the stuff you don't want would be a better approach?
                                • 13. Re: New trouble for today - /OCGs dictionary entry
                                  andrejusc Community Member
                                  Leonard,

                                  Initially I was following this Adobe post:
                                  http://support.adobe.com/devsup/devsup.nsf/docs/51203.htm

                                  in which I've found a mix of PDE and Cos calls and then started to think that not everything is possible via PDE layer in regards to content.

                                  On the HIGH LEVEL - I need selectively copy all objects belonging to one particular document's layer (layers count is usually 5 or more) across documents and in resulting document move those copied objects as well.

                                  I'm not sure that copying ENTIRE PAGE and then removing the stuff I don't need is the best way in such case.
                                  • 14. Re: New trouble for today - /OCGs dictionary entry
                                    Community Member
                                    Actually, yes - copying the entire page and the deleting will be a MUCH better solution for what you are trying to achieve. It will end up faster, more efficient and a LOT eaiser since Acrobat already provides API calls for deleting content from specific layers - in fact, there may even be a sample in the SDK...