|
C# RTF to PDF Converter Library
How to convert RTF (rich text) to PDF using C#.net code in ASP.NET Webform, MVC application
C#.NET Users Are Allowed to Create PDF from RTF with XDoc.PDF SDK for C#.NET
- Free C# RTF to PDF converter SDK for converting PDF from RTF in Visual Studio .NET
- An advanced .NET library which able to batch convert multiple RTF files to adobe PDF files in C#.NET
- Support .NET WinForms, ASP.NET MVC in IIS, ASP.NET Ajax, Azure cloud service, DNN (DotNetNuke), SharePoint
- Free .NET evaluation components for creating PDF from RTF in .NET WinForms
- Able to create PDF file from rtf online in ASP.NET web application
-
c# pdf to image,
convert tiff to pdf c#,
convert csv to pdf c# .net,
convert pdf to tiff using c#.net,
convert images to pdf c#,
c# convert pdf to html,
c# docx to pdf free.
- Allow to create PDF file from RTF file with high quality in C#.NET framework
- C#.NET source codes for creating PDF from RTF in .NET console application
C# convert single RTF file to PDF
#region rtf file to pdf (file to file)
internal static void rtfToPdf()
{
String inputPath = @"C:\demo.rtf";
String outputPath = @"C:\output.pdf";
//convert .docx to .pdf
RTFDocument doc = new RTFDocument(inputPath);
doc.ConvertToDocument(DocumentType.PDF, outputPath);
}
#endregion
#region rtf to pdf (stream to stream)
internal static void rtfStreamToPdf()
{
String inputPath = @"";
byte[] arr = File.ReadAllBytes(inputPath);
Stream inputStream = new MemoryStream(arr);
RTFDocument doc = new RTFDocument(inputStream);
Stream outputStream = new MemoryStream();
doc.ConvertToDocument(DocumentType.PDF, outputStream);
}
#endregion
C# convert two or multiple RTF files to PDF (batch convert)
#region rtf to pdf (batch files and single tread)
internal static void rtfFilesToPdf()
{
String inputDirectory = @"C:\input\";
String outputDirectory = @"C:\output\";
String[] files = Directory.GetFiles(inputDirectory, "*.rtf");
foreach (String filePath in files)
{
int startIdx = filePath.LastIndexOf("\\");
int endIdx = filePath.LastIndexOf(".");
String docName = filePath.Substring(startIdx + 1, endIdx - startIdx - 1);
RTFDocument doc = new RTFDocument(filePath);
doc.ConvertToDocument(DocumentType.PDF, outputDirectory + docName + ".pdf");
}
}
#endregion
#region rtf to pdf (batch file and multiple threads)
internal static void rtffiles2pdf()
{
String inputDirectory = @"C:\input\";
String outputDirectory = @"C:\output\";
String[] files = Directory.GetFiles(inputDirectory, "*.rtf");
List<ConversionArgs> args = new List<ConversionArgs>();
foreach (String filePath in files)
{
int startIdx = filePath.LastIndexOf("\\");
int endIdx = filePath.LastIndexOf(".");
String docName = filePath.Substring(startIdx + 1, endIdx - startIdx - 1);
ConversionArgs arg = new ConversionArgs(filePath, outputDirectory + docName + ".pdf");
args.Add(arg);
}
List<Thread> threads = new List<Thread>();
foreach (ConversionArgs arg in args)
{
Thread thread = new Thread(rtfToPdfThread);
thread.Start(arg);
}
foreach (Thread thread in threads)
{
thread.Join();
}
}
private static void rtfToPdfThread(object args)
{
ConversionArgs toPdfArgs = (ConversionArgs)args;
RTFDocument srcDoc = new RTFDocument(toPdfArgs.SrcPath);
if (srcDoc != null)
{
srcDoc.ConvertToDocument(DocumentType.PDF, toPdfArgs.DstPath);
srcDoc.Dispose();
}
}
#endregion
C# combine multiple RTF files into PDF
#region combine and convert rtf to single pdf
internal static void combineAndConvertRtfToPdf()
{
String[] files = new String[] { @"C:\demo1.rtf", @"C:\demo2.rtf", @"C:\demo3.rtf" };
String outputFilePath = @"C:\output.pdf";
List<MemoryStream> streams = new List<MemoryStream>();
foreach (String file in files)
{
MemoryStream outputStream = new MemoryStream();
RTFDocument doc = new RTFDocument(file);
doc.ConvertToDocument(DocumentType.PDF, outputStream);
streams.Add(outputStream);
}
PDFDocument.CombineDocument(streams.ToArray(), outputFilePath);
}
#endregion
C# insert RTF file into pdf document, and create a new PDF file
#region insert rtf to pdf
internal static void insertOdtToPdf()
{
String filePath = @"C:\demo.rtf";
RTFDocument doc = new RTFDocument(filePath);
MemoryStream stream = new MemoryStream();
doc.ConvertToDocument(DocumentType.PDF, stream);
PDFDocument pdf = new PDFDocument(stream);
int pageCount = pdf.GetPageCount();
List<BasePage> pages = new List<BasePage>();
for (int i = 0; i < pageCount; i++)
{
pages.Add(pdf.GetPage(i));
}
String outputPdf = @"C:\output.pdf";
PDFDocument desDoc = new PDFDocument(outputPdf);
int insertLocation = 2;
desDoc.InsertPages(pages.ToArray(), insertLocation);
desDoc.Save(@"C:\desDocumcnet.pdf");
}
#endregion
|