private void button1_Click(object sender, System.EventArgs e) { SautinSoft.PdfMetamorphosis p = new SautinSoft.PdfMetamorphosis(); if (p != null) { string pdfPath = @"..\..\test.pdf"; //1. Get RTF content string rtfString = this.richTextBox1.Rtf; //2. Converting RTF to PDF byte[] pdf = p.RtfToPdfConvertStringToByte(rtfString); if (pdf != null) { //3. Save to PDF file File.WriteAllBytes(pdfPath, pdf); System.Diagnostics.Process.Start(new System.Diagnostics.ProcessStartInfo(pdfPath) { UseShellExecute = true }); } } }
private void buttonConvert_Click(object sender, EventArgs e) { SautinSoft.PdfMetamorphosis p = new SautinSoft.PdfMetamorphosis(); // After purchasing the license, please insert your serial number here to activate the component //p.Serial = "XXXXXXXXXXX"; // Specify some page options p.PageSettings.Orientation = SautinSoft.PdfMetamorphosis.PageSetting.Orientations.Landscape; // Set page header in HTML format p.PageSettings.Header.FromString("<b>Sample header in HTML format</b>", SautinSoft.PdfMetamorphosis.HeadersFooters.InputFormat.Html); // Set page footer in RTF format p.PageSettings.Footer.FromString(@"{\rtf1\b Bold footer}", SautinSoft.PdfMetamorphosis.HeadersFooters.InputFormat.Rtf); // Set page numbers p.PageSettings.Numbering.Text = "Page {page} of {numpages}"; if (p != null) { string rtfPath = @"..\..\example.rtf"; string pdfPath = @"..\..\test.pdf"; //1. Get RTF content from file string rtfString = File.ReadAllText(rtfPath); //2. Convert RTF to PDF bytes byte[] pdfBytes = p.RtfToPdfConvertStringToByte(rtfString); if (pdfBytes != null) { //3. Save pdfBytes to PDF file File.WriteAllBytes(pdfPath, pdfBytes); System.Diagnostics.Process.Start(new System.Diagnostics.ProcessStartInfo(pdfPath) { UseShellExecute = true }); } else { System.Console.WriteLine("An error occurred during converting RTF to PDF!"); Console.ReadLine(); } } }