Some test text!
The platform-specific conversion API also supports HTML to PDF conversion, either with the +convertOfficeToPDF:paperSize:completion:
method for .html
files or the +convertHTMLStringToPDF:baseURL:paperSize:completion:
for raw HTML text.
The following code shows how to convert an HTML string to PDF:
pdftronprivate.PTConvert.ConvertHTMLStringToPDF(htmlString, baseURL, CGSize.Empty, (pathToPDF) => {
if (pathToPDF == null) {
// Failed to convert HTML to PDF.
return;
}
var dirs = NSSearchPath.GetDirectories(NSSearchPathDirectory.DocumentDirectory, NSSearchPathDomain.User, false);
var documentDirectory = dirs[0];
var urlToPdf = new NSUrl(pathToPDF);
var destinationURL = (new NSUrl(documentDirectory)).Append(urlToPdf.LastPathComponent, false);
NSError error = null;
var result = NSFileManager.DefaultManager.Copy(urlToPdf, destinationURL, out error);
if (!result) {
// Failed to copy PDF to persistent location.
}
// Do something with PDF output.
});
where baseURL
is the URL to use as the page's base URL for resolving relative links in the document.
Get the answers you need: Support
Get unlimited trial usage of PDFTron SDK to bring accurate, reliable, and fast document processing capabilities to any application or workflow.
Select a platform to get started with your free trial.
Web
Android
iOS
Windows
Linux
Unlimited usage. No email address required.