Convert documents to PDF in Xamarin
Apryse has a powerful conversion system which allows you to convert many file formats to PDF. The PTConvert class handles the conversion process and supports the following file types:
Office files:
.docx,.pptx,.xlsx,.doc(with the office conversion Add-On module)Images:
.bmp,.jpg,.tif,.png,.gifImage collections (zip archives with any type of image listed above)
Markdown files:
.md(with the office conversion Add-On module)
Open a non-PDF file
The simplest way to convert and view any file format that Apryse supports is to use the PTDocumentController (or PTTabbedDocumentViewController) method openDocumentWithURL:. This method supports local files, files opened from remote cloud services and "raw" http URLs.
Convert a non-PDF file
Another way is to convert a file with the Convert class's StreamingPDFConversion(String, ConversionOptions) method. The following code shows how to convert a non-PDF file using Apryse's internal conversion:
var documentConversion = Convert.StreamingPDFConversion("my_file_path", null);
documentConversion.Convert();
var pdfDoc = documentConversion.GetDoc();The result of the conversion will be contained in the provided PTPDFDoc, which can then be displayed.
Convert other non-PDF files
In addition to the file types supported by Apryse's internal conversion, it is also possible to convert many other file types with an iOS-specific API. The PTConvert class's +convertOfficeToPDF:paperSize:completion: method can convert any file type supported by WKWebView to PDF. Some of the supported file types include:
iWork files:
.pages,.key,.numbersBinary office files:
.doc,.ppt,.xlsRich Text Format files:
.rtf
The following code shows how to convert a file with the iOS-specific API:
Convert HTML to PDF
Please see this guide about Web/HTML to PDF.
Last updated
Was this helpful?