{"record":{"id":"a2ac905929816875","repo":"dotnet/wpf","slug":"sr-onlyflowandfixedsupported","errorCode":null,"errorMessage":"SR.OnlyFlowAndFixedSupported","messagePattern":"SR\\.OnlyFlowAndFixedSupported","errorType":"exception","errorClass":"ArgumentException","httpStatus":null,"severity":"error","filePath":"src/Microsoft.DotNet.Wpf/src/PresentationFramework/System/Windows/Annotations/AnnotationDocumentPaginator.cs","lineNumber":71,"sourceCode":"        /// </summary>\n        /// <param name=\"originalPaginator\">document to add annotations to</param>\n        /// <param name=\"annotationStore\">store to retrieve annotations from</param>\n        public AnnotationDocumentPaginator(DocumentPaginator originalPaginator, AnnotationStore annotationStore) : this(originalPaginator, annotationStore, FlowDirection.LeftToRight)\n        {\n        }\n\n        /// <summary>\n        ///     Create an instance of AnnotationDocumentPaginator for a given document and annotation store.\n        /// </summary>\n        /// <param name=\"originalPaginator\">document to add annotations to</param>\n        /// <param name=\"annotationStore\">store to retrieve annotations from</param>\n        /// <param name=\"flowDirection\"></param>\n        public AnnotationDocumentPaginator(DocumentPaginator originalPaginator, AnnotationStore annotationStore, FlowDirection flowDirection)\n        {\n            _isFixedContent = originalPaginator is FixedDocumentPaginator || originalPaginator is FixedDocumentSequencePaginator;\n\n            if (!_isFixedContent && !(originalPaginator is FlowDocumentPaginator))\n                throw new ArgumentException(SR.OnlyFlowAndFixedSupported);\n\n            _originalPaginator = originalPaginator;\n            _annotationStore = annotationStore;\n            _locatorManager = new LocatorManager(_annotationStore);\n            _flowDirection = flowDirection;\n\n            // Register for events\n            _originalPaginator.GetPageCompleted += new GetPageCompletedEventHandler(HandleGetPageCompleted);\n            _originalPaginator.ComputePageCountCompleted += new AsyncCompletedEventHandler(HandleComputePageCountCompleted);\n            _originalPaginator.PagesChanged += new PagesChangedEventHandler(HandlePagesChanged);\n        }\n\n        #endregion Public Constructors\n\n        //------------------------------------------------------\n        //\n        //  Public Properties\n        //","sourceCodeStart":53,"sourceCodeEnd":89,"githubUrl":"https://github.com/dotnet/wpf/blob/81131a70a4c573cd62748a5c36908fc4d662daa9/src/Microsoft.DotNet.Wpf/src/PresentationFramework/System/Windows/Annotations/AnnotationDocumentPaginator.cs#L53-L89","documentation":"AnnotationDocumentPaginator only supports wrapping a DocumentPaginator for fixed content (FixedDocumentPaginator / FixedDocumentSequencePaginator) or flow content (FlowDocumentPaginator). The constructor throws ArgumentException for any other paginator implementation.","triggerScenarios":"new AnnotationDocumentPaginator(paginator, store, flowDirection) where paginator is a custom DocumentPaginator subclass or any paginator not derived from the three supported types.","commonSituations":"Developers implementing custom pagination (e.g. for custom printing layouts) and trying to annotate it, or passing a paginator wrapper around another paginator.","solutions":["Pass a paginator from a FlowDocument, FixedDocument, or FixedDocumentSequence instead of a custom paginator.","If custom content must be annotated, render it as a FixedDocument and use its paginator.","If you cannot change the content type, implement annotation support manually via AnnotationStore and AnnotationService rather than this paginator.","Wrap the original content in a FlowDocumentPageViewer/DocumentViewer to obtain a supported paginator."],"exampleFix":"// before\nvar paginator = new MyCustomPaginator(doc);\nvar ap = new AnnotationDocumentPaginator(paginator, store, FlowDirection.LeftToRight);\n// after\nvar paginator = ((FlowDocumentPageViewer)viewer).Document.DocumentPaginator; // FlowDocumentPaginator\nvar ap = new AnnotationDocumentPaginator(paginator, store, FlowDirection.LeftToRight);","handlingStrategy":"type-guard","validationCode":"bool IsSupportedPaginator(DocumentPaginator p) => p is FlowDocumentPaginator or FixedDocumentPaginator or FixedDocumentSequencePaginator;","typeGuard":"bool IsSupportedPaginator(DocumentPaginator p) => p is FlowDocumentPaginator or FixedDocumentPaginator or FixedDocumentSequencePaginator;","tryCatchPattern":"try { var ap = new AnnotationDocumentPaginator(paginator, store, flowDir); } catch (ArgumentException ex) { log.Error(\"Unsupported paginator type for annotations: \" + ex.Message); }","preventionTips":["Only pass paginators from FlowDocument/FixedDocument/FixedDocumentSequence.","Convert custom content to FixedDocument before enabling annotation printing.","Feature-detect with a type check before constructing the paginator."],"tags":["wpf","annotations","printing","arguments"],"backgroundTag":"incompatible-source-type","analyzedSha":"81131a70a4c573cd62748a5c36908fc4d662daa9","analyzedAt":"2026-09-14T10:12:48.479Z","contentChangedAt":"2026-09-14T10:12:48.479Z","schemaVersion":2},"datasetVersion":"2026-09-22T01:17:13.364Z"}