Click here to Skip to main content
15,895,709 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
Hi
I am looking to show a XPS file in browser same as PDF using asp.net, c#4.0.
After going through some article I came to know that even though both are fixed file format(PDF and XPS) we can not render XPS file same as we follow for PDF files.
please suggest me the best possible way. I don't have knowledge of HTML5 so if it is possible using HTML5 then plz let me know.

I tried bellow code to open xps(same as for PDF):
C#
protected void Page_Load(object sender, EventArgs e)
    {
        string pdfPath = Server.MapPath("~/xpstest.xps");
        WebClient client = new WebClient();
        Byte[] buffer = client.DownloadData(pdfPath);
        Response.ContentType = "application/vnd.ms-xpsdocument";
        Response.AddHeader("content-length", buffer.Length.ToString());
        Response.BinaryWrite(buffer);
    }

It helps me to open xps in IE browser but I am getting a popup to save the file in other browsers.

Regards,
Prashant
Posted

1 solution

To best of my knowledge, not all browsers support the format, so, unfortunately, you cannot do it.

To some extent, in principle, you can map some XPS data to "plain" HTML (I don't know why did you thing that HTML5 can help, specifically) and "export" XPS to HTML. In principle, this is possible just because XPS specification is open; this is the ECMA-388 standard:
http://en.wikipedia.org/wiki/Open_XML_Paper_Specification[^],
http://www.ecma-international.org/publications/standards/Ecma-388.htm[^].

As you can get full description of the format, you can do it, but this is just some particular mapping, not one-to-one correspondence. The approaches of these formats are very different. HTML is a flow document, XPS is very rigid, contains the alignment of graphics attached to the pieces of paper. However, as most XPS documents are actually originated from flow documents (such as Word, LibreOffice and a lot more), such "export" would be successful in very many cases.

Unfortunately, from the first attempt, I could not find any open-source ready-to-use solutions, but you can try to find something: http://bit.ly/WHI3lW[^].

—SA
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900