locked
How to convert Byte array into PDF using C#.Net

    Question

  • Hi,
    I need to convert the byte array into PDF using  C#.net

    can any one help in this regards..

    i have browsed the similar thread in this forum..
    there teh accepted answer was VSTO add in ..
    i am knew to this add in's
    i know nothing abt these...

    can any one help me in this regards..


    Thanks in advance,
    Raja
    R@J@
    Friday, May 15, 2009 7:19 AM

Answers

  • For your requirment, i think you have to go for some thirdpary components. Directly form dotNet is not possible.
    -- Thanks Ajith R [Remember to Mark as Answer if it is Helpful.]
    • Proposed as answer by Harry Zhu Wednesday, May 20, 2009 7:48 AM
    • Marked as answer by Harry Zhu Thursday, May 21, 2009 2:58 AM
    Friday, May 15, 2009 12:21 PM

  • a user can upload any type of data like .txt, .doc, .rtf, .jpg, .gif, .xls, .pdf through upload control..
    which will converts the uploaded file into Byte array...

    now we need to convert that uploaded file into PDF and save it into the files..


    Then you need to look around for a component or library that will let you generate PDF files from all those sources. Writing one yourself would not be an easy task. Google something like ".NET PDF generator" and you will find some options.
    Mattias, C# MVP
    • Proposed as answer by Harry Zhu Wednesday, May 20, 2009 7:48 AM
    • Marked as answer by Harry Zhu Thursday, May 21, 2009 2:58 AM
    Friday, May 15, 2009 10:59 AM

All replies

  • Hi,
      Did you mean you have the data of a pdf file as byte array?
    -- Thanks Ajith R [Remember to Mark as Answer if it is Helpful.]
    Friday, May 15, 2009 7:51 AM
  • What's the format of the data in the byte array? If it's just an in-memory copy of a PDF file, all you need to do is to save it to a file on disk. If not, what kind of conversion is needed?
    Mattias, C# MVP
    Friday, May 15, 2009 7:55 AM
  • Like the above, my suggestion is similar.

    If it is a byte array, you can write it to disk so it becomes saved as *pdf file.

    or

    either, you can write the bytes to the response output stream and user will be prompt to download and save the file.

    Response.Clear();
    Response.ContentType = "application/pdf";
    Response.AppendHeader("Content-Disposition", "inline;filename=data.pdf");
    Response.BufferOutput = true;
    byte[] pdf;
    Response.AddHeader("Content-Length", response.Length.ToString());
    Response.BinaryWrite(pdf);
    Response.End();
    Friday, May 15, 2009 9:12 AM
  • What's the format of the data in the byte array? If it's just an in-memory copy of a PDF file, all you need to do is to save it to a file on disk. If not, what kind of conversion is needed?
    Mattias, C# MVP

    Thanks for all ur replies..
    here is my requirement..


    a user can upload any type of data like .txt, .doc, .rtf, .jpg, .gif, .xls, .pdf through upload control..
    which will converts the uploaded file into Byte array...

    now we need to convert that uploaded file into PDF and save it into the files..

    the byte array is not specific to PDF it self...

    that is what we need to do..

    R@J@
    Friday, May 15, 2009 9:45 AM
  • Like the above, my suggestion is similar.

    If it is a byte array, you can write it to disk so it becomes saved as *pdf file.

    or

    either, you can write the bytes to the response output stream and user will be prompt to download and save the file.

    Response.Clear();
    Response.ContentType = "application/pdf";
    Response.AppendHeader("Content-Disposition", "inline;filename=data.pdf");
    Response.BufferOutput = true;
    byte[] pdf;
    Response.AddHeader("Content-Length", response.Length.ToString());
    Response.BinaryWrite(pdf);
    Response.End();

    Thanks for all ur replies..
    here is my requirement..


    a user can upload any type of data like .txt, .doc, .rtf, .jpg, .gif, .xls, .pdf through upload control..
    which will converts the uploaded file into Byte array...

    now we need to convert that uploaded file into PDF and save it into the files..

    the byte array is not specific to PDF it self...

    that is what we need to do..

    R@J@
    Friday, May 15, 2009 9:45 AM

  • a user can upload any type of data like .txt, .doc, .rtf, .jpg, .gif, .xls, .pdf through upload control..
    which will converts the uploaded file into Byte array...

    now we need to convert that uploaded file into PDF and save it into the files..


    Then you need to look around for a component or library that will let you generate PDF files from all those sources. Writing one yourself would not be an easy task. Google something like ".NET PDF generator" and you will find some options.
    Mattias, C# MVP
    • Proposed as answer by Harry Zhu Wednesday, May 20, 2009 7:48 AM
    • Marked as answer by Harry Zhu Thursday, May 21, 2009 2:58 AM
    Friday, May 15, 2009 10:59 AM
  • For your requirment, i think you have to go for some thirdpary components. Directly form dotNet is not possible.
    -- Thanks Ajith R [Remember to Mark as Answer if it is Helpful.]
    • Proposed as answer by Harry Zhu Wednesday, May 20, 2009 7:48 AM
    • Marked as answer by Harry Zhu Thursday, May 21, 2009 2:58 AM
    Friday, May 15, 2009 12:21 PM
  • Hi Ch Raja,

    I can recommend you third-party components to convert : *.txt, *.rtf, *.gif, *.jpg, *.xls to PDF format in ASP.Net.

    1) PDF Vision .Net: *.jpg, *.gif to PDF

    2) PDF Metamorphosis .Net: *.rtf, *.txt to PDF

    3) Excel to PDF .Net: *.xls to PDF

    All these components can be found at one site: http://www.sautinsoft.com

    Max

     

    Thursday, July 01, 2010 12:51 PM
  • For html, SVG, JPG, PNG to pdf conversion the hiqpdf html to pdf converter is a reliable and accurate solution
    Thursday, September 13, 2012 7:23 AM