BeginPersistObjectData(
            SerializableObjectContext serializableObjectContext
            )
        {
            if (serializableObjectContext == null)
            {
                throw new ArgumentNullException(nameof(serializableObjectContext));
            }

            _xpsOMSerializationManager.RegisterDocumentStart();

            if (serializableObjectContext.IsComplexValue)
            {
                XpsSerializationPrintTicketRequiredEventArgs e =
                    new XpsSerializationPrintTicketRequiredEventArgs(PrintTicketLevel.FixedDocumentPrintTicket,
                                                                     0);

                _xpsOMSerializationManager.OnXPSSerializationPrintTicketRequired(e);

                //
                // Serialize the data for the PrintTicket
                //
                if (e.Modified)
                {
                    if (e.PrintTicket != null)
                    {
                        PrintTicketSerializer serializer = new PrintTicketSerializer(SerializationManager);
                        serializer.SerializeObject(e.PrintTicket);
                    }
                }
            }

            _xpsOMSerializationManager.StartNewDocument();
        }
        BeginPersistObjectData(
            SerializableObjectContext serializableObjectContext
            )
        {
            if (_xpsOMSerializationManager != null)
            {
                _xpsOMSerializationManager.RegisterDocumentStart();
                XpsSerializationPrintTicketRequiredEventArgs e =
                    new XpsSerializationPrintTicketRequiredEventArgs(PrintTicketLevel.FixedDocumentPrintTicket,
                                                                     0);

                _xpsOMSerializationManager.OnXPSSerializationPrintTicketRequired(e);

                //
                // Serialize the data for the PrintTicket
                //
                if (e.Modified)
                {
                    if (e.PrintTicket != null)
                    {
                        PrintTicketSerializer serializer = new PrintTicketSerializer(SerializationManager);
                        serializer.SerializeObject(e.PrintTicket);
                    }
                }

                _xpsOMSerializationManager.StartNewDocument();
            }

            DocumentPaginator paginator = (DocumentPaginator)serializableObjectContext.TargetObject;

            XmlLanguage language = null;

            DependencyObject dependencyObject = paginator.Source as DependencyObject;

            if (dependencyObject != null)
            {
                language = (XmlLanguage)dependencyObject.GetValue(FrameworkContentElement.LanguageProperty);
            }

            if (language == null)
            {
                //If the language property is null, assign the language to the default
                language = XmlLanguage.GetLanguage(XpsS0Markup.XmlLangValue);
            }

            SerializationManager.Language = language;

            return(paginator);
        }
Beispiel #3
0
        SimulatePrintTicketRaisingEvent(
            XpsSerializationPrintTicketRequiredEventArgs e
            )
        {
            (_serializationManager as IXpsSerializationManager)?.OnXPSSerializationPrintTicketRequired(e);

            //
            // Serialize the data for the PrintTicket
            //
            if (e.Modified)
            {
                if (e.PrintTicket != null)
                {
                    PrintTicketSerializer serializer = new PrintTicketSerializer(_serializationManager);
                    serializer.SerializeObject(e.PrintTicket);
                }
            }
        }
        PersistObjectData(
            SerializableObjectContext serializableObjectContext
            )
        {
            if (SerializationManager is IXpsSerializationManager)
            {
                (SerializationManager as IXpsSerializationManager).RegisterPageStart();
            }

            //
            // A DocumentPage is persisted as a FixedPage
            //
            DocumentPage dp = (DocumentPage)serializableObjectContext.TargetObject;

            ReachTreeWalker treeWalker = new ReachTreeWalker(this);

            treeWalker.SerializeLinksInDocumentPage(dp);

            XmlWriter.WriteStartElement(XpsS0Markup.FixedPage);

            String xmlnsForType = SerializationManager.GetXmlNSForType(typeof(FixedPage));

            if (xmlnsForType != null)
            {
                XmlWriter.WriteAttributeString(XpsS0Markup.Xmlns, xmlnsForType);
                XmlWriter.WriteAttributeString(XpsS0Markup.XmlnsX, XpsS0Markup.XmlnsXSchema);

                if (SerializationManager.Language != null)
                {
                    XmlWriter.WriteAttributeString(XpsS0Markup.XmlLang, SerializationManager.Language.ToString());
                }
                else
                {
                    XmlWriter.WriteAttributeString(XpsS0Markup.XmlLang, XpsS0Markup.XmlLangValue);
                }
            }

            XpsSerializationPrintTicketRequiredEventArgs e =
                new XpsSerializationPrintTicketRequiredEventArgs(PrintTicketLevel.FixedPagePrintTicket,
                                                                 0);

            ((IXpsSerializationManager)SerializationManager).OnXPSSerializationPrintTicketRequired(e);

            PrintTicket printTicket = null;

            if (e.Modified)
            {
                printTicket = e.PrintTicket;
            }

            Size size = Toolbox.ValidateDocumentSize(dp.Size, printTicket);

            ((IXpsSerializationManager)SerializationManager).FixedPageSize = size;

            //
            //write length and width elements
            //
            WriteAttribute(XmlWriter, XpsS0Markup.PageWidth, size.Width);
            WriteAttribute(XmlWriter, XpsS0Markup.PageHeight, size.Height);

            //
            // Serialize the data for the PrintTicket
            //
            if (printTicket != null)
            {
                PrintTicketSerializer serializer = new PrintTicketSerializer(SerializationManager);
                serializer.SerializeObject(printTicket);
            }

            SerializeChild(dp.Visual, serializableObjectContext);

            ((XpsSerializationManager)SerializationManager).PackagingPolicy.PreCommitCurrentPage();

            //copy hyperlinks into stream
            treeWalker.CommitHyperlinks();

            XmlWriter.WriteEndElement();
            XmlWriter = null;
            //
            // Free the image table in use for this page
            //
            ((XpsSerializationManager)SerializationManager).ResourcePolicy.CurrentPageImageTable = null;
            //
            // Free the colorContext table in use for this page
            //
            ((XpsSerializationManager)SerializationManager).ResourcePolicy.CurrentPageColorContextTable = null;

            ((IXpsSerializationManager)SerializationManager).VisualSerializationService.ReleaseVisualTreeFlattener();

            if (SerializationManager is IXpsSerializationManager)
            {
                (SerializationManager as IXpsSerializationManager).RegisterPageEnd();
            }
            //
            // Signal to any registered callers that the Page has been serialized
            //
            XpsSerializationProgressChangedEventArgs progressEvent =
                new XpsSerializationProgressChangedEventArgs(XpsWritingProgressChangeLevel.FixedPageWritingProgress,
                                                             0,
                                                             0,
                                                             null);

            ((IXpsSerializationManager)SerializationManager).OnXPSSerializationProgressChanged(progressEvent);
        }
        PersistObjectData(
            SerializableObjectContext serializableObjectContext
            )
        {
            if (serializableObjectContext == null)
            {
                throw new ArgumentNullException("serializableObjectContext");
            }

            FixedPage fixedPage = serializableObjectContext.TargetObject as FixedPage;

            if (SerializationManager is IXpsSerializationManager)
            {
                (SerializationManager as IXpsSerializationManager).RegisterPageStart();
            }

            ReachTreeWalker treeWalker = new ReachTreeWalker(this);

            treeWalker.SerializeLinksInFixedPage((FixedPage)serializableObjectContext.TargetObject);

            String xmlnsForType = SerializationManager.GetXmlNSForType(serializableObjectContext.TargetObject.GetType());

            if (xmlnsForType == null)
            {
                XmlWriter.WriteStartElement(serializableObjectContext.Name);
            }
            else
            {
                XmlWriter.WriteStartElement(serializableObjectContext.Name);

                XmlWriter.WriteAttributeString(XpsS0Markup.Xmlns, xmlnsForType);
                XmlWriter.WriteAttributeString(XpsS0Markup.XmlnsX, XpsS0Markup.XmlnsXSchema);

                XmlLanguage language = fixedPage.Language;
                if (language == null)
                {
                    //If the language property is null, assign the language to the default
                    language = XmlLanguage.GetLanguage(XpsS0Markup.XmlLangValue);
                }

                SerializationManager.Language = language;

                XmlWriter.WriteAttributeString(XpsS0Markup.XmlLang, language.ToString());
            }
            {
                Size fixedPageSize = new Size(fixedPage.Width, fixedPage.Height);
                ((IXpsSerializationManager)SerializationManager).FixedPageSize = fixedPageSize;

                //
                // Before we serialize any properties on the FixedPage, we need to
                // serialize the FixedPage as a Visual
                //
                Visual fixedPageAsVisual = serializableObjectContext.TargetObject as Visual;

                bool needEndVisual = false;

                if (fixedPageAsVisual != null)
                {
                    needEndVisual = SerializePageAsVisual(fixedPageAsVisual);
                }

                if (serializableObjectContext.IsComplexValue)
                {
                    ReachSerializerContext context = new ReachFixedPageSerializerContext(this,
                                                                                         serializableObjectContext,
                                                                                         SerializerAction.endSerializeReachFixedPage,
                                                                                         needEndVisual,
                                                                                         treeWalker);

                    ((IXpsSerializationManagerAsync)SerializationManager).OperationStack.Push(context);

                    PrintTicket printTicket = ((IXpsSerializationManager)SerializationManager).FixedPagePrintTicket;

                    if (printTicket != null)
                    {
                        PrintTicketSerializer serializer = new PrintTicketSerializer(SerializationManager);
                        serializer.SerializeObject(printTicket);
                        ((IXpsSerializationManager)SerializationManager).FixedPagePrintTicket = null;
                    }


                    SerializeObjectCore(serializableObjectContext);
                }
                else
                {
                    throw new XpsSerializationException(SR.Get(SRID.ReachSerialization_WrongPropertyTypeForFixedPage));
                }
            }
        }
        PersistObjectData(
            SerializableObjectContext serializableObjectContext
            )
        {
            String xmlnsForType = SerializationManager.GetXmlNSForType(typeof(FixedDocumentSequence));

            if (SerializationManager is XpsSerializationManager)
            {
                (SerializationManager as XpsSerializationManager).RegisterDocumentSequenceStart();
            }

            if (xmlnsForType == null)
            {
                XmlWriter.WriteStartElement(serializableObjectContext.Name);
            }
            else
            {
                XmlWriter.WriteStartElement(serializableObjectContext.Name,
                                            xmlnsForType);
            }

            {
                if (serializableObjectContext.IsComplexValue)
                {
                    //
                    // Pick the data for the PrintTicket if it existed
                    //
                    XpsSerializationPrintTicketRequiredEventArgs e =
                        new XpsSerializationPrintTicketRequiredEventArgs(PrintTicketLevel.FixedDocumentSequencePrintTicket,
                                                                         0);

                    ((IXpsSerializationManager)SerializationManager).OnXPSSerializationPrintTicketRequired(e);

                    //
                    // Serialize the data for the PrintTicket
                    //
                    if (e.Modified)
                    {
                        if (e.PrintTicket != null)
                        {
                            PrintTicketSerializer serializer = new PrintTicketSerializer(SerializationManager);
                            serializer.SerializeObject(e.PrintTicket);
                        }
                    }

                    SerializeObjectCore(serializableObjectContext);
                }
                else
                {
                }
            }

            XmlWriter.WriteEndElement();
            XmlWriter = null;

            //
            // Signal to any registered callers that the Sequence has been serialized
            //
            XpsSerializationProgressChangedEventArgs progressEvent =
                new XpsSerializationProgressChangedEventArgs(XpsWritingProgressChangeLevel.FixedDocumentSequenceWritingProgress,
                                                             0,
                                                             0,
                                                             null);

            if (SerializationManager is XpsSerializationManager)
            {
                (SerializationManager as XpsSerializationManager).RegisterDocumentSequenceEnd();
            }
            ((IXpsSerializationManager)SerializationManager).OnXPSSerializationProgressChanged(progressEvent);
        }
        PersistObjectData(
            SerializableObjectContext serializableObjectContext
            )
        {
            Toolbox.EmitEvent(EventTrace.Event.WClientDRXSerializationBegin);

            if (serializableObjectContext == null)
            {
                throw new ArgumentNullException("serializableObjectContext");
            }

            if (SerializationManager is IXpsSerializationManager)
            {
                (SerializationManager as IXpsSerializationManager).RegisterPageStart();
            }

            FixedPage fixedPage = serializableObjectContext.TargetObject as FixedPage;

            ReachTreeWalker treeWalker = new ReachTreeWalker(this);

            treeWalker.SerializeLinksInFixedPage((FixedPage)serializableObjectContext.TargetObject);

            String xmlnsForType = SerializationManager.GetXmlNSForType(serializableObjectContext.TargetObject.GetType());

            if (xmlnsForType == null)
            {
                XmlWriter.WriteStartElement(serializableObjectContext.Name);
            }
            else
            {
                XmlWriter.WriteStartElement(serializableObjectContext.Name);

                XmlWriter.WriteAttributeString(XpsS0Markup.Xmlns, xmlnsForType);
                XmlWriter.WriteAttributeString(XpsS0Markup.XmlnsX, XpsS0Markup.XmlnsXSchema);

                XmlLanguage language = fixedPage.Language;
                if (language == null)
                {
                    //If the language property is null, assign the language to the default
                    language = XmlLanguage.GetLanguage(XpsS0Markup.XmlLangValue);
                }

                SerializationManager.Language = language;

                XmlWriter.WriteAttributeString(XpsS0Markup.XmlLang, language.ToString());
            }
            {
                Size fixedPageSize = new Size(fixedPage.Width, fixedPage.Height);
                ((IXpsSerializationManager)SerializationManager).FixedPageSize = fixedPageSize;

                //
                // Before we serialize any properties on the FixedPage, we need to
                // serialize the FixedPage as a Visual
                //
                Visual fixedPageAsVisual = serializableObjectContext.TargetObject as Visual;

                bool needEndVisual = false;

                if (fixedPageAsVisual != null)
                {
                    needEndVisual = SerializePageAsVisual(fixedPageAsVisual);
                }

                if (serializableObjectContext.IsComplexValue)
                {
                    PrintTicket printTicket = ((IXpsSerializationManager)SerializationManager).FixedPagePrintTicket;

                    if (printTicket != null)
                    {
                        PrintTicketSerializer serializer = new PrintTicketSerializer(SerializationManager);
                        serializer.SerializeObject(printTicket);
                        ((IXpsSerializationManager)SerializationManager).FixedPagePrintTicket = null;
                    }

                    SerializeObjectCore(serializableObjectContext);
                }
                else
                {
                    throw new XpsSerializationException(SR.Get(SRID.ReachSerialization_WrongPropertyTypeForFixedPage));
                }

                if (needEndVisual)
                {
                    XmlWriter pageWriter = ((XpsSerializationManager)SerializationManager).
                                           PackagingPolicy.AcquireXmlWriterForPage();

                    XmlWriter resWriter = ((XpsSerializationManager)SerializationManager).
                                          PackagingPolicy.AcquireXmlWriterForResourceDictionary();


                    VisualTreeFlattener flattener = ((IXpsSerializationManager)SerializationManager).
                                                    VisualSerializationService.AcquireVisualTreeFlattener(resWriter,
                                                                                                          pageWriter,
                                                                                                          fixedPageSize);

                    flattener.EndVisual();
                }
            }

            ((XpsSerializationManager)SerializationManager).PackagingPolicy.PreCommitCurrentPage();

            //
            // Copy hyperlinks into stream
            //
            treeWalker.CommitHyperlinks();

            XmlWriter.WriteEndElement();
            //
            //Release used resources
            //
            XmlWriter = null;
            //
            // Free the image table in use for this page
            //
            ((XpsSerializationManager)SerializationManager).ResourcePolicy.CurrentPageImageTable = null;
            //
            // Free the colorContext table in use for this page
            //
            ((XpsSerializationManager)SerializationManager).ResourcePolicy.CurrentPageColorContextTable = null;
            //
            // Free the resourceDictionary table in use for this page
            //
            ((XpsSerializationManager)SerializationManager).ResourcePolicy.CurrentPageResourceDictionaryTable = null;

            ((IXpsSerializationManager)SerializationManager).VisualSerializationService.ReleaseVisualTreeFlattener();

            if (SerializationManager is IXpsSerializationManager)
            {
                (SerializationManager as IXpsSerializationManager).RegisterPageEnd();
            }

            //
            // Signal to any registered callers that the Page has been serialized
            //
            XpsSerializationProgressChangedEventArgs progressEvent =
                new XpsSerializationProgressChangedEventArgs(XpsWritingProgressChangeLevel.FixedPageWritingProgress,
                                                             0,
                                                             0,
                                                             null);

            ((IXpsSerializationManager)SerializationManager).OnXPSSerializationProgressChanged(progressEvent);

            Toolbox.EmitEvent(EventTrace.Event.WClientDRXSerializationEnd);
        }
Beispiel #8
0
        BeginSerializeDocumentPage(
            SerializableObjectContext serializableObjectContext
            )
        {
            PrintTicket printTicket = null;

            _xpsOMSerializationManager.RegisterPageStart();

            XpsSerializationPrintTicketRequiredEventArgs e =
                new XpsSerializationPrintTicketRequiredEventArgs(PrintTicketLevel.FixedPagePrintTicket,
                                                                 0);

            _xpsOMSerializationManager.OnXPSSerializationPrintTicketRequired(e);

            if (e.Modified)
            {
                printTicket = e.PrintTicket;
            }

            //
            // Serialize the data for the PrintTicket
            //
            if (printTicket != null)
            {
                PrintTicketSerializer serializer = new PrintTicketSerializer(SerializationManager);
                serializer.SerializeObject(printTicket);
            }

            //
            // A DocumentPage is persisted as a FixedPage
            //
            DocumentPage dp = (DocumentPage)serializableObjectContext.TargetObject;

            ReachTreeWalker treeWalker = new ReachTreeWalker(this);

            treeWalker.SerializeLinksInDocumentPage(dp);

            XmlWriter.WriteStartElement(XpsS0Markup.FixedPage);

            String xmlnsForType = SerializationManager.GetXmlNSForType(typeof(FixedPage));

            if (xmlnsForType != null)
            {
                XmlWriter.WriteAttributeString(XpsS0Markup.Xmlns, xmlnsForType);
                XmlWriter.WriteAttributeString(XpsS0Markup.XmlnsX, XpsS0Markup.XmlnsXSchema);

                if (SerializationManager.Language != null)
                {
                    XmlWriter.WriteAttributeString(XpsS0Markup.XmlLang, SerializationManager.Language.ToString());
                }
                else
                {
                    XmlWriter.WriteAttributeString(XpsS0Markup.XmlLang, XpsS0Markup.XmlLangValue);
                }
            }



            Size size = Toolbox.ValidateDocumentSize(dp.Size, printTicket);

            _xpsOMSerializationManager.FixedPageSize = size;

            //
            //write length and width elements
            //
            WriteAttribute(XmlWriter, XpsS0Markup.PageWidth, size.Width);
            WriteAttribute(XmlWriter, XpsS0Markup.PageHeight, size.Height);

            return(treeWalker);
        }
Beispiel #9
0
        PersistObjectData(
            SerializableObjectContext serializableObjectContext
            )
        {
            String xmlnsForType = SerializationManager.GetXmlNSForType(typeof(FixedDocument));
            String nameForType  = XpsS0Markup.FixedDocument;

            if (SerializationManager is XpsSerializationManager)
            {
                (SerializationManager as XpsSerializationManager).RegisterDocumentStart();
            }

            if (xmlnsForType == null)
            {
                XmlWriter.WriteStartElement(nameForType);
            }
            else
            {
                XmlWriter.WriteStartElement(nameForType,
                                            xmlnsForType);
            }

            {
                XpsSerializationPrintTicketRequiredEventArgs e =
                    new XpsSerializationPrintTicketRequiredEventArgs(PrintTicketLevel.FixedDocumentPrintTicket,
                                                                     0);

                ((IXpsSerializationManager)SerializationManager).OnXPSSerializationPrintTicketRequired(e);

                //
                // Serialize the data for the PrintTicket
                //
                if (e.Modified)
                {
                    if (e.PrintTicket != null)
                    {
                        PrintTicketSerializer serializer = new PrintTicketSerializer(SerializationManager);
                        serializer.SerializeObject(e.PrintTicket);
                    }
                }

                DocumentPaginator paginator = (DocumentPaginator)serializableObjectContext.TargetObject;

                XmlLanguage language = null;

                DependencyObject dependencyObject = paginator.Source as DependencyObject;
                if (dependencyObject != null)
                {
                    language = (XmlLanguage)dependencyObject.GetValue(FrameworkContentElement.LanguageProperty);
                }

                if (language == null)
                {
                    //If the language property is null, assign the language to the default
                    language = XmlLanguage.GetLanguage(XpsS0Markup.XmlLangValue);
                }

                SerializationManager.Language = language;

                for (int i = 0; !paginator.IsPageCountValid || (i < paginator.PageCount); i++)
                {
                    DocumentPage page = Toolbox.GetPage(paginator, i);

                    ReachSerializer serializer = SerializationManager.GetSerializer(page);

                    if (serializer != null)
                    {
                        serializer.SerializeObject(page);
                    }
                }
            }

            XmlWriter.WriteEndElement();
            XmlWriter = null;
            //
            // Clear off the table from the resource policy
            //
            ((XpsSerializationManager)SerializationManager).ResourcePolicy.ImageCrcTable = null;

            ((XpsSerializationManager)SerializationManager).ResourcePolicy.ImageUriHashTable = null;
            //
            // Clear off the table from the resource policy
            //
            ((XpsSerializationManager)SerializationManager).ResourcePolicy.ColorContextTable = null;
            //
            // Signal to any registered callers that the Document has been serialized
            //
            XpsSerializationProgressChangedEventArgs progressEvent =
                new XpsSerializationProgressChangedEventArgs(XpsWritingProgressChangeLevel.FixedDocumentWritingProgress,
                                                             0,
                                                             0,
                                                             null);

            if (SerializationManager is XpsSerializationManager)
            {
                (SerializationManager as XpsSerializationManager).RegisterDocumentEnd();
            }
            ((IXpsSerializationManager)SerializationManager).OnXPSSerializationProgressChanged(progressEvent);
        }
Beispiel #10
0
        PersistObjectData(
            SerializableObjectContext serializableObjectContext
            )
        {
            if (serializableObjectContext == null)
            {
                throw new ArgumentNullException("serializableObjectContext");
            }

            String xmlnsForType = SerializationManager.GetXmlNSForType(typeof(FixedDocument));

            if (SerializationManager is XpsSerializationManager)
            {
                (SerializationManager as XpsSerializationManager).RegisterDocumentStart();
            }

            if (xmlnsForType == null)
            {
                XmlWriter.WriteStartElement(serializableObjectContext.Name);
            }
            else
            {
                XmlWriter.WriteStartElement(serializableObjectContext.Name,
                                            xmlnsForType);
            }

            {
                if (serializableObjectContext.IsComplexValue)
                {
                    XpsSerializationPrintTicketRequiredEventArgs e =
                        new XpsSerializationPrintTicketRequiredEventArgs(PrintTicketLevel.FixedDocumentPrintTicket,
                                                                         0);

                    ((IXpsSerializationManager)SerializationManager).OnXPSSerializationPrintTicketRequired(e);

                    //
                    // Serialize the data for the PrintTicket
                    //
                    if (e.Modified)
                    {
                        if (e.PrintTicket != null)
                        {
                            PrintTicketSerializer serializer = new PrintTicketSerializer(SerializationManager);
                            serializer.SerializeObject(e.PrintTicket);
                        }
                    }

                    SerializeObjectCore(serializableObjectContext);
                }
                else
                {
                    throw new XpsSerializationException(SR.Get(SRID.ReachSerialization_WrongPropertyTypeForFixedDocument));
                }
            }

            //
            // Clear off the table from the packaging policy
            //
            ((XpsSerializationManager)SerializationManager).ResourcePolicy.ImageCrcTable = null;

            ((XpsSerializationManager)SerializationManager).ResourcePolicy.ImageUriHashTable = null;

            XmlWriter.WriteEndElement();
            XmlWriter = null;

            //
            // Signal to any registered callers that the Document has been serialized
            //
            XpsSerializationProgressChangedEventArgs progressEvent =
                new XpsSerializationProgressChangedEventArgs(XpsWritingProgressChangeLevel.FixedDocumentWritingProgress,
                                                             0,
                                                             0,
                                                             null);

            ((IXpsSerializationManager)SerializationManager).OnXPSSerializationProgressChanged(progressEvent);

            if (SerializationManager is XpsSerializationManager)
            {
                (SerializationManager as XpsSerializationManager).RegisterDocumentEnd();
            }
        }
        BeginPersistObjectData(SerializableObjectContext serializableObjectContext, out ReachTreeWalker treeWalker)
        {
            if (serializableObjectContext == null)
            {
                throw new ArgumentNullException("serializableObjectContext");
            }

            _xpsOMSerializationManager.RegisterPageStart();


            if (serializableObjectContext.IsComplexValue)
            {
                PrintTicket printTicket = _xpsOMSerializationManager.FixedPagePrintTicket;

                if (printTicket != null)
                {
                    PrintTicketSerializer serializer = new PrintTicketSerializer(SerializationManager);
                    serializer.SerializeObject(printTicket);
                    _xpsOMSerializationManager.FixedPagePrintTicket = null;
                }
            }

            FixedPage fixedPage = serializableObjectContext.TargetObject as FixedPage;

            treeWalker = new ReachTreeWalker(this);
            treeWalker.SerializeLinksInFixedPage((FixedPage)serializableObjectContext.TargetObject);

            String xmlnsForType = SerializationManager.GetXmlNSForType(serializableObjectContext.TargetObject.GetType());

            if (xmlnsForType == null)
            {
                XmlWriter.WriteStartElement(serializableObjectContext.Name);
            }
            else
            {
                XmlWriter.WriteStartElement(serializableObjectContext.Name);

                XmlWriter.WriteAttributeString(XpsS0Markup.Xmlns, xmlnsForType);
                XmlWriter.WriteAttributeString(XpsS0Markup.XmlnsX, XpsS0Markup.XmlnsXSchema);

                XmlLanguage language = fixedPage.Language;
                if (language == null)
                {
                    //If the language property is null, assign the language to the default
                    language = XmlLanguage.GetLanguage(XpsS0Markup.XmlLangValue);
                }

                SerializationManager.Language = language;

                XmlWriter.WriteAttributeString(XpsS0Markup.XmlLang, language.ToString());
            }

            Size fixedPageSize = new Size(fixedPage.Width, fixedPage.Height);

            _xpsOMSerializationManager.FixedPageSize = fixedPageSize;

            //
            // Before we serialize any properties on the FixedPage, we need to
            // serialize the FixedPage as a Visual
            //
            Visual fixedPageAsVisual = serializableObjectContext.TargetObject as Visual;

            bool needEndVisual = false;

            if (fixedPageAsVisual != null)
            {
                needEndVisual = SerializePageAsVisual(fixedPageAsVisual);
            }

            return(needEndVisual);
        }