开发者

WPF and XPS: Empty Document Viewer

开发者 https://www.devze.com 2022-12-26 08:12 出处:网络
byte[] mediaBytes = Convert.FromBase64String(\"<<strings>>\"); XpsDocument doc; ms = new MemoryStream(mediaBytes, 0, mediaBytes.Length);
        byte[] mediaBytes = Convert.FromBase64String("<<strings>>");

        XpsDocument doc;

        ms = new MemoryStream(mediaBytes, 0, mediaBytes.Length);

        Uri DocumentUri = new Uri("pack://document.xps");

        using (Package package = Package.Open(ms, FileMode.Create))
        {
            PackageStore.AddPackage(DocumentUri, package);
            doc = new XpsDocument(package, CompressionOption.Maximum, DocumentUri.AbsoluteUri);
            FixedDocumentSequence fds = doc.GetFixedDocumentSequence();
            documentViewer.Document = fds as IDocumentPaginatorSo开发者_StackOverflow中文版urce;
            PackageStore.RemovePackage(DocumentUri);
            doc.Close();
        }

Can anyone please help me. Its result is an empty document. The mediaBytes is a PDF document.


In your statement: Package package = Package.Open(ms, FileMode.Create) You are setting ms as the package destination stream, not a source stream.

0

精彩评论

暂无评论...
验证码 换一张
取 消