Ecrion Software Inc. Homepage
Forum Home Forum Home > XF Rendering Server > XSL-FO
  New Posts New Posts RSS Feed: how to open PDF at runtime using XSLFO input
  FAQ FAQ  Forum Search   Register Register  Login Login

how to open PDF at runtime using XSLFO input

 Post Reply Post Reply
Author
Message / View First Unread Post
kuul13 View Drop Down
Newbie
Newbie


Joined: 06 May 2011
Posts: 1
Post Options Post Options   Quote kuul13 Quote  Post ReplyReply Direct Link To This Post Topic: how to open PDF at runtime using XSLFO input
    Posted: 06 May 2011 at 3:02pm
I have the following code that creates the PDF file on the machine. But, I require, I user click on the View PDF link, the PDF file should be generated at runtime and open.

string inputString = "PGZvOnJvb3QgeG1sbnM6Zm89Imh0dHA6Ly93==";
//parameters for the rendering operation.
RenderingParameters param = new RenderingParameters();
//set input format
param.InputFormat = Engine.InputFormat.XSLFO;
//set output format
param.OutputFormat = Engine.OutputFormat.PDF;

Engine engine = new Engine();
System.Text.UTF8Encoding encoding = new System.Text.UTF8Encoding();
byte[] stringBytes = Convert.FromBase64String(inputString);
//create input and output streams
Stream inputStream = new MemoryStream(stringBytes);

//create input and output streams
using (FileStream outputStream = new FileStream("C:\\HelloWorld1.pdf", FileMode.Create))
{
    engine.Render(inputStream, outputStream, param);
}

How can I write code to open the PDF on the fly without writing on the disk?
Back to Top
gabig View Drop Down
Admin Group
Admin Group


Joined: 06 Aug 2008
Posts: 144
Post Options Post Options   Quote gabig Quote  Post ReplyReply Direct Link To This Post Posted: 10 May 2011 at 10:37am
Hi kuul13,

You can't open PDFs directly from memory because Adobe Reader doesn't support it. Even if you write the PDF stream into the response, it causes the file to be downloaded into the Temporary Internet Files folder and then opened from there.

You have 2 options: either write it into the response stream with Response.Write() if you're in ASP.NET and it will open in the browser, or write it to the temporary folder and use System.Diagnostics.Process.Start(pathToFile) to open it in its native application.

Regards,
Gabi Ghita
Back to Top
 Post Reply Post Reply

Forum Jump Forum Permissions View Drop Down

Bulletin Board Software by Web Wiz Forums® version 9.69
Copyright ©2001-2010 Web Wiz

This page was generated in 0.109 seconds.