CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Page 2 of 2 FirstFirst 12
Results 16 to 23 of 23
  1. #16
    Join Date
    Jun 2003
    Location
    South Africa
    Posts
    11

    Sorry I lost my self there.

    Sorry I lost my self there.
    What I wanted to say is.
    When you convert the page write it to binary
    And on the page with no HTML Page load event you say Response.BinaryWrite()
    Then it will display the PDF File in the browser.
    Kind Regards
    Neil de Weerdt

  2. #17
    Join Date
    May 2002
    Location
    Hyderabad
    Posts
    76
    Still I couldn't get you?
    can you provide sample example for what you are saying?
    Ashish Sheth

  3. #18
    Join Date
    Jun 2003
    Location
    South Africa
    Posts
    11

    What i did with Crystal (See if you can change it to adapt to yours)

    Attached you will find a Example Zip File.


    protected ReportDocument rptDocument;

    private void Page_Load(object sender, System.EventArgs e)
    {
    rptDocument = new ReportDocument();
    Response.ClearContent();
    Response.ClearHeaders();
    Response.ContentType = "application/pdf";
    Response.BinaryWrite(ReportConvert(CreateDataSource()));

    }

    private DataSet CreateDataSource()
    {
    DataSet ds = new DataSet();
    SqlCommand cmd = new SqlCommand("select top 10 * from dbo.syscolumns");
    SqlConnection connection = new SqlConnection(@"");
    cmd.Connection = connection;
    SqlDataAdapter sqlAdapter = new SqlDataAdapter(cmd);
    sqlAdapter.Fill(ds);
    return ds;
    }

    public byte[] ReportConvert(DataSet ds)
    {
    try
    {
    this.rptDocument.Load(Server.MapPath(@"Report.rpt"));
    this.rptDocument.SetDataSource(ds);
    return this.ExportToPDF();
    }
    catch(Exception ex)
    {
    throw (ex);
    }
    }

    protected byte[] ExportToPDF()
    {
    ExportOptions exportOptions;
    System.IO.Stream st;
    exportOptions = this.rptDocument.ExportOptions;
    exportOptions.FormatOptions = new PdfRtfWordFormatOptions();
    exportOptions.ExportFormatType = ExportFormatType.PortableDocFormat;
    ExportRequestContext expRequest = new ExportRequestContext();
    expRequest.ExportInfo = exportOptions;
    st = this.rptDocument.FormatEngine.ExportToStream(expRequest);
    byte[] returnValue = new Byte[int.Parse(st.Length.ToString())];
    st.Read(returnValue, 0, int.Parse(st.Length.ToString()));
    return returnValue;
    }
    Attached Files Attached Files
    Kind Regards
    Neil de Weerdt

  4. #19
    Join Date
    Jun 2003
    Location
    South Africa
    Posts
    11

    ABCPDF Have a Look at this site

    Kind Regards
    Neil de Weerdt

  5. #20
    Join Date
    May 2002
    Location
    Hyderabad
    Posts
    76
    Hi Neildw,
    Can it be done without the use of crystal reports?
    Or, suppose we don't want to send it to client, but we want to save it on the server?
    Ashish Sheth

  6. #21
    Join Date
    Jun 2003
    Location
    South Africa
    Posts
    11
    Yes I think you can..
    Haven’t tried it but I think you can.
    The reason why I didn’t try it. Cause the company I do development for are very fussy on security so we are not allowed to save stuff to the server. Only in a DB'
    have a look at that site.
    im busy downloading it as we speak..
    to have a look
    Kind Regards
    Neil de Weerdt

  7. #22
    Join Date
    Jul 2003
    Posts
    1
    I'm in the same issue using asp/asp.net.

    Would you please suggest an ActiveX control that can convert a HTML file to PDF like this:

    oPDF.Convert("d:\test\src.html","d:\test\dest.pdf")

    I have tried to use Acrobat Distiller printer but always face with user permission problem.
    Things went smootly when I use the Distiller printer in VB, but not with ASP, although I tried use the same code directly in ASP page or move the print feature to COM.
    If I set Internet user as Administrator, I could do it smoothly but I don't dare do the same thing on live server.

    ------------------------------------------
    Save me if you can

  8. #23
    Join Date
    Apr 2005
    Posts
    1

    Re: How to convert HTML to PDF format

    Hi
    Try HtmlDoc , it is free. and run it as a process in C# and commmand line arguments are needed
    you can download it from
    http://mamboforge.net/frs/?group_id=227&release_id=625
    and htmldoc home page is
    http://www.htmldoc.org/index.php

    If you need any more help getback to me
    with regards
    Krishnan

Page 2 of 2 FirstFirst 12

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured