Thank you for the example! I will check test it when the 323 build is out.
Sasha - Tracker Dev Team wrote:I've asked "How can I extract the ID from the IPXC_ContentItem", which was ignored because my provided (first) PDF sample doesn't have any OCProperties (which is completely unrelated to that question).
If you mean the position in the IPXC_Content then it's simply the position in the IPXC_ContentItems array of the IPXC_Content. Note that XForms content items have their own content that can other XForms and so on.
Bit of a vague question from my end, let me try to clarify:
I will use the extracted COS code from the PDF the
sample.pdf PDF I attached previously as an example:
First, the page (object 22):
Code: Select all
<<
/Type/Page
/Parent 18 0 R
/Resources <<
/ProcSet[/PDF/Text]
/Font <<
/F2 15 0 R
/TT8 3 0 R
/TT6 16 0 R
/TT4 2 0 R
/TT2 29 0 R
/Xi1 26 0 R
/F0 <<
/Type/Font
/Subtype/Type1
/BaseFont/Helvetica
>>
>>
/ExtGState <<
/GS1 10 0 R
/gs0 <<
/Type/ExtGState
/ca 0.2
>>
>>
/ColorSpace <</Cs5 5 0 R>>
/Properties<</Xi0 23 0 R>>
>>
/MediaBox[0 0 595 842]
/Rotate 0
/CropBox[0 0 595 842]
/Metadata 13 0 R
/Contents[1 0 R 27 0 R 24 0 R 4 0 R 20 0 R 25 0 R 9 0 R 7 0 R]
>>
Inside the page dictionary I have
Page.Resources.Properties.Xi0, which is a reference to object 23:
Code: Select all
<</Name(TesteringStamps)/Type/OCG>>
Examining the
Page.Contents array I find references to multiple objects, one of which is object 4, a stream:
Code: Select all
<</Length 84>>
stream
Q
q
/OC /Xi0 BDC
0 0 0 rg
BT
1 0 0 1 139.55 806.62 Tm
/Xi1 12 Tf
(Test)Tj
ET
EMC
Q
endstream
Traversing the
IPXV_Document.CoreDoc.CosDocument I can get the object 4 stream as a string or I can get the contents of it as 1 or more
IPXC_ContentItems using
IPXC_Page.GetContent().
If I wanted to, I could link some (maybe only optional/marked content, I am not sure) of these
IPXC_ContentItems to their corresponding
CosDocument dictionary item by parsing the stream string, for example:
- /OC /Xi0 => Page.Resources.Properties.Xi0
- /Xi1 12 Tf => Page.Resources.Font.Xi1
I'm not exactly sure what
/Xi0 and
/Xi1 are, but my question was whether or not it's possible to obtain those from their corresponding
IPXC_ContentItems? Alternatively, is there another way to link items in the
CosDocument to the corresponding
IPXC_ContentItems?
(If possible, either solution would allow me identify optional content in the Structures layer and remove/hide it in the Core layer regardless of OCGs being defined in the OCProperties dictionary.)
Sasha - Tracker Dev Team wrote:I've asked if changes in the structures layer can be reflected in the rendering of the PDF. I still don't know if that's possible, but you've mentioned events and exclusive locks on the structure layer as requirements, but no working examples. I myself have hinted at saving and re-opening the document.
The locks themselves allow you to either correctly read or write the document's structure (that is not done on the normal occasions). There are 3 levels in the SDK - Structure level -> Core level -> Editor Level. To see the updates that were done in the Structure level in the Editor level, first the Core Level should be notified of that (if needed) and then the Editor level events or methods should be called to refresh the UI.
I tried removing objects in the Structure layer without luck, but I probably just went about it the wrong way (using the sample document from above again):
Code: Select all
IPXV_Document doc = _pdfControl.Doc;
doc.CoreDoc.CosDocument.LockDocument();
// Get contents of first page from structures layer
IPXS_PDFVariant contents = doc.CoreDoc.Pages[0].PDFObject.Dict_Get("Contents");
// Remove some content
contents.RemoveItems(3, 1);
doc.CoreDoc.CosDocument.UnlockDocument();
// Trigger event to notify Core layer about structure change event - probably not the correct way, given the event is fired on the Editor layer document, hmm...
IEvent evt = doc.EventServer.CreateNewEvent(pxvInst.Str2ID("e.document.sourceChanged"));
doc.EventServer.FireEvent(evt, doc);
// Trigger event to notify Editor layer about Core doc change event
doc.ActiveView.PagesView.InvalidatePages(null);
A few questions for this sample code:
- Is it even possible to change the content of the PDF in this way (i.e., by removing 1 or more of the referenced streams of Page.Contents)?
- If not, is it possible to modify the content on the Structures layer in another way?
- Is it possible to update other objects (for example, document metadata) in the structures layer directly (as in, not using one of your provided methods, such as SetOCState()) and have it update in the Editor layer?
- Am I using the correct events?
Assuming that it
is possible to directly modify the arrays/dictionaries of the
CosDocument and have it update the Editor layer, the simplest answer to the above questions would probably be an example of how.