Fairly simple:
I have an XPSDocument that I am pulling off of disk. I would like to get the FixedDocuments out of this XpsDocument, but I’ve hit a bit of a cropper since I can only get a FixedDocumentSequence, and I can’t work out how to pull the XpsDocuments from this sequence.
So far I’ve tried something like:
FixedDocument doc = (FixedDocument)myFixedDocSequence.References.First();
That cast doesn’t work, but it illustrates what I’m trying to achieve.
myFixedDocSequence.References.First();should return aDocumentReference. From that instead of casting have you tried using theDocumentReference.GetDocumentmethod, which returns aFixedDocument? The code would look like this:Read the documentation linked to above for more information on the
GetDocumentparameter options. Also unless you’re sureReferences.First()won’t be null, consider usingFirstOrDefault()and checking for null before using the returned object.