hi,
i was generation XPS report with wpf and displaying with document viewer.the report is showing fine in document viewer
but when i save this report and try to open in IE(InternetExplorer)/third partuy XPS viewer it is showing a error.here iam attaching my
Code and Error:
Code:
FixedDocument fixedDocument= new FixedDocument ();
FixedPage fixedpage = new FixedPage {Height = 840,Width = 800};
PageContent pageContent = new PageContent();
((System.Windows.Markup.IAddChild)pageContent).AddChild(fixedpage);
fixedDocument.Pages.Add(pageContent);
DrawingVisual visual = new DrawingVisual();
drawingContext = visual.RenderOpen();
drawingContext.DrawText(new FormattedText(text,CultureInfo.GetCultureInfo("en-us"),
FlowDirection.LeftToRight,font,
font.Size,brush),new Point(rect.X,rect.Y));
drawingContext.Close();
UIElement ui = new DrawingVisualPresenter(visual);
fixedpage.Children.Add(ui);
XpsDocument xpsDocument = new XpsDocument("XPSReport.xps",FileAccess.ReadWrite);
XpsDocumentWriter writer = XpsDocument.CreateXpsDocumentWriter(xpsDocument);
writer.Write(fixedDocument);
DocumentViewer.Document = xpsDocument .GetFixedDocumentSequence();
internal class DrawingVisualPresenter: FrameworkElement {
private DrawingVisual visual;
internal DrawingVisualPresenter(DrawingVisual visual) {
this.visual = visual;
}
protected override int VisualChildrenCount {
get { return 1; }
}
protected override Visual GetVisualChild(int index) {
if (index != 0)
throw new ArgumentOutOfRangeException("index");
return visual;
}
}
Error::
Startup URI: D:\Projects\Cardio\Source\UCTests\bin\Debug\XpsReport.xps
Application Identity:
System.ArgumentException: The document does not contain a valid FixedDocumentSequence.
at MS.Internal.Documents.DigitalSignatureProvider..ctor(Package package)
at MS.Internal.Documents.Application.PackageController.MS.Internal.Documents.Application.IDocumentController.Open(Document document)
at MS.Internal.Documents.Application.DocumentManager.DispatchOpen(IDocumentController controller, Document document)
at MS.Internal.Documents.Application.DocumentManager.<>c__DisplayClass6.<orderbyleastdependent>b__5(IDocumentController controller, Document subject)
at MS.Internal.Documents.Application.ChainOfResponsiblity`2.Dispatch(Action action, S subject)
at MS.Internal.Documents.Application.DocumentManager.<>c__DisplayClass6.<orderbyleastdependent>b__4(Document member)
at MS.Internal.Documents.Application.ChainOfDependencies`1.OrderByLeastDependent(T member, Action action)
at MS.Internal.Documents.Application.DocumentManager.OrderByLeastDependent(DispatchDelegate action, Document document)
at MS.Internal.Documents.Application.DocumentManager.Open(Document document)
at MS.Internal.AppModel.ApplicationProxyInternal.InitContainer()
at MS.Internal.AppModel.ApplicationProxyInternal.Run(InitData initData)</orderbyleastdependent></orderbyleastdependent>