Simple Conversion
Converting a File or URL
Saving the PDF Output to a File
The following example demonstrates a simple file conversion from HTML (a specified URL) to PDF. An RTF to PDF conversion line is also illustrated. A similar process would be done for converting any of the over 50 file type to PDF.
Converter.Convert("http://www.google.com", pdfFilePath);
OR
Converter.Convert(rtfFilePath, pdfFilePath);
Converter.Convert("http://www.google.com", pdfFilePath)
OR
Converter.Convert(rtfFilePath.rtf, pdfFilePath)
Streaming the PDF Output Directly to the Browser
The following example demonstrates a simple file conversion to PDF while outputting that PDF directly to the user's browser. Specifically this takes an RTF file and converts it to PDF and outputs it to the browser. A similar process would be done for converting any of the over 50 file type to PDF and outputting them to the browser.
Converter.ConvertToWeb("http://www.google.com");
OR
Converter.ConvertToWeb(@"C:\Temp\DocumentA.rtf");
Converter.ConvertToWeb("http://www.google.com")
OR
Converter.ConvertToWeb("C:\Temp\DocumentA.rtf")
HTML String Converting
The following example demonstrates converting a specific HTML string to PDF (as opposed to using an actual HTML file or URL as demonstrated in the examples above). Use of the ConvertHtmlStringToWeb method would yield the same resultant PDF but would stream the output directly to the browser. Please refer to the Converting Current Web Page to PDF section for an example on how to specify for the current web page be converted to PDF.
string sampleHtml = "<html><body><p>This is a very simple HTML string including a Table below.</p>" +
"<h4>Two rows and three columns:</h4><table border=\"1\"><tr><td>100</td><td>200</td>" +
"<td>300</td></tr><tr><td>400</td><td>500</td><td>600</td></tr></table></body></html>";
Converter.ConvertHtmlString(sampleHtml, pdfFilePath);
Dim sampleHtml As String = "<html><body><p>This is a very simple HTML string including a Table below.</p>" + \_
"<h4>Two rows and three columns:</h4><table border=""1""><tr><td>100</td><td>200</td>" + \_
"<td>300</td></tr><tr><td>400</td><td>500</td><td>600</td></tr></table></body></html>"
Converter.ConvertHtmlString(sampleHtml, pdfFilePath)
Specific Converter Classes
We also have ExcelConverter, HtmlConverter, ImageConverter, PowerPointConverter, RtfConverter, TextConverter and WordConverter for converting specific file types with respective options classes.