{"record":{"id":"78e6ef57b9cb4961","repo":"dotnet/wpf","slug":"sr-format-sr-formatrestrictionsexceeded-fserr","errorCode":null,"errorMessage":"SR.Format(SR.FormatRestrictionsExceeded, fserr)","messagePattern":"SR\\.Format\\(SR\\.FormatRestrictionsExceeded, fserr\\)","errorType":"exception","errorClass":"PtsException","httpStatus":null,"severity":"error","filePath":"src/Microsoft.DotNet.Wpf/src/PresentationFramework/MS/Internal/PtsHost/Pts.cs","lineNumber":70,"sourceCode":"                case fserrOutOfMemory:\n                    throw new OutOfMemoryException();\n\n                case fserrCallbackException:\n                    Debug.Assert(ptsContext != null, \"Null argument 'ptsContext' - required for return value validation.\");\n                    if (ptsContext != null)\n                    {\n                        SecondaryException se = new SecondaryException(ptsContext.CallbackException);\n                        ptsContext.CallbackException = null;\n                        throw se;\n                    }\n                    else\n                    {\n                        throw new Exception(SR.Format(SR.PTSError, fserr));\n                    }\n\n                case tserrPageTooLong:\n                case tserrSystemRestrictionsExceeded:\n                    throw new PtsException(SR.Format(SR.FormatRestrictionsExceeded, fserr));\n\n                default:\n                    throw new PtsException(SR.Format(SR.PTSError, fserr));\n            }\n        }\n        internal static void ValidateAndTrace(int fserr, PtsContext ptsContext)\n        {\n            if (fserr != fserrNone) \n            { \n                ErrorTrace(fserr, ptsContext); \n            }\n        }\n        private static void ErrorTrace(int fserr, PtsContext ptsContext)\n        {\n            switch (fserr)\n            {\n                case fserrOutOfMemory:\n                    throw new OutOfMemoryException();","sourceCodeStart":52,"sourceCodeEnd":88,"githubUrl":"https://github.com/dotnet/wpf/blob/81131a70a4c573cd62748a5c36908fc4d662daa9/src/Microsoft.DotNet.Wpf/src/PresentationFramework/MS/Internal/PtsHost/Pts.cs#L52-L88","documentation":"Pts.Error maps error codes returned by the native PTS (Page/Tex­ture Services) layout engine to .NET exceptions. When the code is tserrSystemRestrictionsExceeded (reported via FormatRestrictionsExceeded), the native formatter exceeded its system/format restrictions — the requested layout (column count, page size, constraints, formatting complexity) is beyond what PTS accepts — and a PtsException is thrown naming the code.","triggerScenarios":"Validating/formatting a document with a ComplexColumnProperties/flow document layout whose parameters (page width/height, column rules, para properties) violate native PTS restrictions, reached via PtsContext.Validate callbacks during page layout of a FlowDocumentPage/DocumentPage.","commonSituations":"Extremely large or zero/negative page dimensions, aggressive multi-column settings, or custom page views supplying out-of-range layout constraints; typically surfaces after programmatic document/page-size changes rather than normal XAML use.","solutions":["Check the page/column/paragraph properties your code supplies to the flow document layout (PageSize, ColumnWidth, padding) and bring them within sane positive bounds.","Verify the fserr code in the message against PTS error constants to identify which restriction (e.g. page too long vs. system restrictions) was exceeded.","Reset the document viewer/page metrics to defaults to confirm the failure is caused by custom layout parameters.","If it occurs with default settings, treat it as an internal layout invariant failure and gather the document structure for a WPF bug report, wrapping layout in a try/catch on PtsException."],"exampleFix":"// before\nviewer.Document.DocumentPaginator.PageSize = new Size(0, 0); // violates PTS restrictions\n// after\nviewer.Document.DocumentPaginator.PageSize = new Size(816, 1056); // valid page size","handlingStrategy":"try-catch","validationCode":"bool pageSizeIsValid = paginator.PageSize.Width > 0 && paginator.PageSize.Height > 0 && !double.IsInfinity(paginator.PageSize.Width) && !double.IsInfinity(paginator.PageSize.Height);","typeGuard":"static bool IsValidPageSize(Size s) => !s.IsEmpty && s.Width > 0 && s.Height > 0 && double.IsFinite(s.Width) && double.IsFinite(s.Height);","tryCatchPattern":"try { viewer.UpdateLayout(); }\ncatch (PtsException ex) when (ex.Message.Contains(\"restrictions\")) { ResetLayoutToDefaults(viewer); }","preventionTips":["Validate page size, column widths, and paddings are finite positive values before assigning them to viewers/paginators","After custom layout changes, force a full re-layout rather than reusing cached pages","Log the fserr code from PtsException messages to identify which PTS restriction fired","Test documents with extreme content sizes against your custom page/paragraph properties"],"tags":["wpf","pts","layout","native-interop"],"backgroundTag":"layout-restrictions-exceeded","analyzedSha":"81131a70a4c573cd62748a5c36908fc4d662daa9","analyzedAt":"2026-09-14T10:12:48.479Z","contentChangedAt":"2026-09-14T10:12:48.479Z","schemaVersion":2},"datasetVersion":"2026-09-21T21:30:21.729Z"}