I don't know how many of you have been trying to create pdf report online with open source pdf .net control. I have been through many of these.  Either it is erroneous or costs too much of design time to create a report..
The following is my attempt recently to create pdf on fly with a open source product, PDF creator, http://sourceforge.net/projects/pdfcreator/
<%@ Page Language="C#" debug="true"%>
<%@ import Namespace="System" %>
<%@ import Namespace="System.IO" %>
<%@ import Namespace="System.Diagnostics" %>

<script runat="server">

    
void Page_Load(object sender, EventArgs e)
    
{
        
// Get a file name relative to the current Web app.
        
//ProcessStartInfo i = new ProcessStartInfo("myexe.exe", "-arg1 -arg1 -others");
       try {

            
string file = Server.MapPath(@"bin\PDFCreator.exe");
        
// Response.Write(file);
        
// return;
            System.Diagnostics.ProcessStartInfo info = new ProcessStartInfo(file, "/NOSTART /PF\"C:/test.html\"");
            
// Redirect output so we can read it.
            info.RedirectStandardOutput = true;
            
// To redirect, we must not use shell execute.
            info.UseShellExecute = false;

            
// Create and execute the process.
            Process p = Process.Start(info);
            p.Start();

            
// Send whatever was returned through the output to the client.
            Response.Clear();
            Response.ContentType 
= "application/pdf";
            Response.Write(p.StandardOutput.ReadToEnd());
       }

       
catch (Exception ex)
       
{
            Response.Write(ex.ToString());
       }

     }


</script>
<html>
<head>
</head>
<body>
    
<form runat="server">
        
<!-- Insert content here -->
    
</form>
</body>
</html>


Warning!! This program is not working yet.
But I have the gut feeling that it is possible to create a pretty stable and good webcontrol  from this

(To be continued ...)


posted on 2005-06-03 05:37  netspring  阅读(1163)  评论(0)    收藏  举报