Help! I need to convert RTF to PDF using C#


Article from our customer

Hello everyone! Please tell me how to convert RTF string to PDF stream?!

Finally, our company has decided to move to modern technology of document processing. We have a variety documents in RTF format storing in the database. At the request of the visitor to choose from a database RTF document stored as RTF string and display the document to the user. We have chosen the PDF format. The principle of operation was simple and easy. At the request of the customer from the base gets out rtf and convert to a PDF stream, a physical file is not created and does not take place on the server’s hard disk! After the converting a PDF download on the client browser or by using the PDF Viewer!

We picked out a few libraries, but stopped on the component “PDF Metamorphosis. NET” that can run under any platform … Below I show the code:


            SautinSoft.PdfMetamorphosis p = new SautinSoft.PdfMetamorphosis();
byte[] pdfBytes = p.RtfToPdfConvertFileToByte(Path.Combine(Server.MapPath(""), @"Document.rtf"));

//show PDF
if (pdfBytes != null)
{
    Response.Buffer = true;
    Response.Clear();
    Response.ContentType = "application/PDF";
    Response.BinaryWrite(pdfBytes);
    Response.Flush();
    Response.End();
}
                    

If you need a new code example or have a question: email us at support@sautinsoft.com or ask at Online Chat (right-bottom corner of this page) or use the Form below:



Questions and suggestions from you are always welcome!

We are developing .Net components since 2002. We know PDF, DOCX, RTF, HTML, XLSX and Images formats. If you need any assistance with creating, modifying or converting documents in various formats, we can help you. We will write any code example for you absolutely free.