Adding a seamless Word, Excel, and PowerPoint viewer to iOS apps is made simple with the PDFTron PDF SDK. Office files are converted directly to PDF in the client , and then displayed with a PDF viewer. No server, Microsoft Office license, or other third party software needed.

Although this blog will explain how to add an Office viewer to iOS apps (Swift and Objective-C ), this is also possible on all major platforms through a single unified API, including Android and Xamarin .

If you are interested in trying this out for yourself you can download our free trial .

Step 1 - Convert From Office to PDF

First we'll convert the .doc, .docx, .pptx or .xlsx file to PDF directly in the client:

func ConvertOfficeFile(_ inPath: String, outPath: String, options: PTConversionOptions) {
    let pdfDoc = PTPDFDoc() pdfDoc, in_filename: inPath, options: options)
    pdfDoc?.save(toFile: outPath, flags: e_ptremove_unused.rawValue)

Step 2 - Display the Documents

You can now display the converted file saved in outPath like this:

// Create a PTDocumentViewController
let documentController = PTDocumentViewController()

// The PTDocumentViewController must be in a navigation controller before a document can be opened
let navigationController = UINavigationController(rootViewController: documentController)

// Open an existing local file URL.
let fileURL: URL! = Bundle.main.url(forResource: "sample", withExtension: "pdf")

documentController.openDocument(with: fileURL)

// Show navigation (and document) controller.
self.present(navigationController, animated: true, completion: nil)

Here's what it looks like:


You can read more about displaying a PDF in our documentation.

Converting Other File Formats

PDFTron’s iOS PDF library can also convert a variety of other file formats to PDF for viewing, such as images (.jpeg, .jpg, .gif, .png, .bmp etc.), markdown (.md) or comic book archive (.cbz). Here's how:

func ConvertNonPDFFile(_ inPath: String, outPath: String, options: PTConversionOptions) {
    let documentConversion = PTConvert.streamingPDFConversion(inPath, options: options)
    let pdfDoc = documentConversion?.getDoc()
    pdfDoc?.save(toFile: outPath, flags: e_ptremove_unused.rawValue)

These converted files can now be viewed in the same way as the PDF.

Adding More Functionality

For a richer document experience, the PDFTron SDK makes it easy to add more functionality to the viewer:


Adding an Office document viewer to your iOS app is simple with the PDFTron SDK. To give it a try, download a free trial and check out our iOS Office viewer documentation .

For further guidance, please get in touch . The developers who helped build our SDK from the ground up would be happy to walk you through your options.