473,669 Members | 2,386 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Save aspx output to a file on the server

In my web application there is an interactive report. Then there need
to be a printable version a pdf. So I found this java tool csstoxslfo
and the java fop tool from apache that will take my xhtml and css and
convert it to pdf.

Problem 1)
I designed the aspx page to produce the xhtml as output. So how do I
save that rendered page to a file on the server? I think it involves
overriding the Render method. I wrote some code which appears below
that I don't know if it will work. Anybody done this before and have
code examples?

Problem 2)
Assuming I can render to a file, I now have to invoke java. I tested
from the command line and this works fine. So now I have to do it from
the asp.net page, wait for it to finish, and then render the resulting
pdf file to the user. I assume all this code will be in the render
override?
Anybody called java before like this?
I'm thinking using a process object and something like the following
for the command. I've been researching and just doing java -jar as the
command doesn't work? Again anybody done this before and have code
examples?
start command /c java -jar thejar.jar options

Will Rickards
Protected Overrides Sub Render(ByVal writer As
System.Web.UI.H tmlTextWriter)

' create stream to store output
Dim objRendered As System.web.UI.H tmlTextWriter
Dim objFileWriter As System.IO.Strea mWriter

' get file writer
objFileWriter = System.IO.File. CreateText(Serv er.MapPath(".") &
"\\PDF\\" & CStr(m_intRepor tNumber) & ".xhtml")

objRendered = New System.Web.UI.H tmlTextWriter(o bjFileWriter)

MyBase.Render(o bjRendered)

objFileWriter.F lush()
objFileWriter.C lose()
objRendered.Flu sh()
objRendered.Clo se()

writer.Write("D one")

End Sub

Nov 19 '05 #1
2 2149
Hi Will,

I think this will help with Problem #1.

Ken
Microsoft MVP [ASP.NET]

' Render() sends server control content to a provided HtmlTextWriter
object
' We overrides the Render method
' Output is the HtmlTextWriter object.
Protected Overrides Sub Render _
(ByVal Output As HtmlTextWriter)
' Create a StringBuilder to hold the HTML
Dim sb As New StringBuilder
' Create an HtmlTextWriter
Dim tw As New HtmlTextWriter( New System.IO.Strin gWriter(sb))
MyBase.Render(t w)
' The following will fail if the ASPNET or impersonated account
' doesn't have write privileges in the root
Dim txtw As System.IO.Strea mWriter = _
System.IO.File. CreateText("c:\ htmltxt.txt")
' Write the page contents to the file just created
txtw.Write(sb.T oString())
txtw.Flush()
txtw.Close()
' Write the text to the HTML page
Output.Write(sb .ToString())
End Sub
"Will Rickards" <wi**********@g mail.com> wrote in message
news:11******** *************@o 13g2000cwo.goog legroups.com...
In my web application there is an interactive report. Then there need
to be a printable version a pdf. So I found this java tool csstoxslfo
and the java fop tool from apache that will take my xhtml and css and
convert it to pdf.

Problem 1)
I designed the aspx page to produce the xhtml as output. So how do I
save that rendered page to a file on the server? I think it involves
overriding the Render method. I wrote some code which appears below
that I don't know if it will work. Anybody done this before and have
code examples?

Problem 2)
Assuming I can render to a file, I now have to invoke java. I tested
from the command line and this works fine. So now I have to do it from
the asp.net page, wait for it to finish, and then render the resulting
pdf file to the user. I assume all this code will be in the render
override?
Anybody called java before like this?
I'm thinking using a process object and something like the following
for the command. I've been researching and just doing java -jar as the
command doesn't work? Again anybody done this before and have code
examples?
start command /c java -jar thejar.jar options

Will Rickards
Protected Overrides Sub Render(ByVal writer As
System.Web.UI.H tmlTextWriter)

' create stream to store output
Dim objRendered As System.web.UI.H tmlTextWriter
Dim objFileWriter As System.IO.Strea mWriter

' get file writer
objFileWriter = System.IO.File. CreateText(Serv er.MapPath(".") &
"\\PDF\\" & CStr(m_intRepor tNumber) & ".xhtml")

objRendered = New System.Web.UI.H tmlTextWriter(o bjFileWriter)

MyBase.Render(o bjRendered)

objFileWriter.F lush()
objFileWriter.C lose()
objRendered.Flu sh()
objRendered.Clo se()

writer.Write("D one")

End Sub

Nov 19 '05 #2
Thanks, that worked. Unfotunately, once I got the output the java tool
didn't like it as input so I have to track down those bugs.

Nov 19 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

4
1661
by: Mr Gordonz | last post by:
Hi All, I want to be able to save a file from the client's PC on the server. The tricky part is the aspx page is never actually seen by the user. Basically, I have a VB application running on the client PC, it calls an aspx page and passes some data as query srtings, including the full path to the relevant file(s) on the client PC. For example, the VB app might call the page thus: ...
9
3016
by: Ivan Demkovitch | last post by:
Hi! I would like to know if I can save File on Server using server-side code? For example, I like to create thumbnail images and populate specific directory. Do I need specific permissions to do this? (I use public host) Thanks!
4
4011
by: Nikhil Tayal | last post by:
Is there a way to write a file on the client machine from an aspx page? I've a custom query page and need to store the search criteria specified in an XML file on the user machine from my web page (aspx). I form the XML at run time from the search fileds specfied by the user and now my aspx page should save it on client machine so that the user can open the same query on next visit of the page. And help is appreciated. Nikhil
4
3709
by: Glenn M | last post by:
I have a shared XML file on a server . i also have one xslt file that performs a simple transform on in to view the data. now i want to have another page that lets users modify the shared xml file via some editable controls such as text boxes , option boxes etc. how can i implment this , should i use another xslt file with <INPUT> controls . if so how can i save the result back using the asp.net
8
2685
by: DanB | last post by:
This is probably soooo simple but I can't seem to get it. I have a text file that I want users to download via a web page. I want the file to be saved to a default folder (or one that they choose) on the users / client file system. I have toyed with a Self-Extracting zip file but the contents of my zip file changes each time it is downloaded so that invalidates the exe file. Also the text file is so small it is a waste to zip it.
0
1072
by: WaterBug | last post by:
Is it possible?... We have an aspx page that serves as a form for data entry. When the user presses 'print' our desire is to populate an Excel worksheet with the data and serve the output in a browser or Excel. We want to do this without doing a save on the server and a redirect to the xls file in the browser. We have an xls file (template with formatting) that we want to open, populate with data from a data adapter server side then...
1
1632
by: =?Utf-8?B?U00=?= | last post by:
Hi, We have developed an application that transforms xsl into excel file and present xsl file to the user with data. We use open xml features of excel 2003. Our user is now asking for a chart to be part of transformed xl file. We tried to save the chart properties in the xsl and it is not saving the xsl with chart properties ( chart we are trying is simple pie chart) Appreciate if any one has a solution or idea for this to happen.
3
7145
by: =?Utf-8?B?YzY3NjIyOA==?= | last post by:
Hi all, I have a question for you. I have a .csv file which has many lines of data. Each line has many data fields which are delimited by ",". Now I need to extract part of data from this file but save it as an excel file. The data in this excel file will be imported into an Access database. The
3
4348
by: evenlater | last post by:
I have an Access application on a terminal server. Sometimes my users need to export reports to pdf, rtf or xls files and save them to their own client device hard drives. They can do that right now the way I have this set up, but it's confusing and slow. When they browse for a place to save the reports, they see all of the drives on the terminal server as well as their own client drives. So they're likely to want to choose "My...
0
8465
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
1
8588
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
7407
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
6210
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
4206
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
4386
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2797
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
2032
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
2
1788
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.