Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6822319
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T21:38:57+00:00 2026-05-26T21:38:57+00:00

i am trying to make help for my application. I have xps documents which

  • 0

i am trying to make help for my application. I have xps documents which i am loading to documentviewer. These files are embedded in resource file.

I am able to access these as bytearray.
For example
Properties.Resources.help_sudoku_methods_2
returns byte[]

However, documentviewer cant read it and requires fixeddocumentsequence.
So i create memory stream from bytearray, then xpsdocument and then fixeddocumentsequence like this:

 private void loadDocument(byte[] sourceXPS)
        {
            MemoryStream ms = new MemoryStream(sourceXPS);
            const string memoryName = "memorystream://ms.xps";
            Uri memoryUri = new Uri(memoryName);
            try
            {
                PackageStore.RemovePackage(memoryUri);
            }
            catch (Exception)
            { }

            Package package = Package.Open(ms);


            PackageStore.AddPackage(memoryUri, package);

            XpsDocument xps = new XpsDocument(package, CompressionOption.SuperFast, memoryName);

            FixedDocumentSequence fixedDocumentSequence = xps.GetFixedDocumentSequence();
            doc.Document = fixedDocumentSequence;


        }

This is very unclean aproach and also doesnt work if there are images in files – instead of images in new documents displays images from first loaded doc.

Is there any cleaner way to load XPS from embedded resources to documentviewer? or do i need somethink like copy file from resources to application directory and load from here and not memorystream? Thank you.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-26T21:38:58+00:00Added an answer on May 26, 2026 at 9:38 pm

    why dont you write file to system temp folder and then read from there.

        Stream ReadStream = System.Reflection.Assembly.GetExecutingAssembly().GetManifestResourceStream("file1.xps");
            string tempFile = Path.GetTempPath()+"file1.xps"; 
            FileStream WriteStream = new FileStream(tempFile, FileMode.Create, FileAccess.Write);
            ReadStream.CopyTo(WriteStream);
            WriteStream.Close();
            ReadStream.Close();
    
            // Read tempFile INTO memory here and then
    
            File.Delete(tempFile);
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am trying to make help pages for my application. I have written the
I have a WPF Application where I am trying to make a close button
I am trying to make an application using AppleScript which can remind to check
I have spent the whole day trying to make my application use threads but
Hello everyone i need some help. I'm trying to make an application for mac
I am trying to make a small ASP.NET application where I have a GridView
I have a sample application, in which I am trying to load a text
I am trying to make the help support for my mac application. I made
I am trying to make a small application for a project in which clients
Trying to make a MySQL-based application support MS SQL, I ran into the following

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.