Get access to over 100 FireMonkey cross platform samples for Android, IOS, OSX, Windows, and Linux!

AppmethodCode SnippetDelphiDemoFiremonkeyIOSLibrary

Create, View, And Open PDFs In Other Apps With Delphi XE8 Firemonkey On IOS

| Delphi 11 10 XE8 XE7 XE Seattle Berlin Tokyo Rio Firemonkey Delphi Android Delphi IOS

Delphi XE8 Firemonkey Create Open In App View PDF IOS | Delphi 11 10 XE8 XE7 XE Seattle Berlin Tokyo Rio Firemonkey Delphi Android Delphi IOSIf you are looking to create or view PDFs on IOS in Delphi XE8 Firemonkey the DPF IOS libraries really make it easy. This example (based on the DPF IOS demo) shows how to create a PDF on the fly, view the PDF, and open the PDF in third party apps on IOS like PDF Expert and Google Chrome. Creating the PDF is handled by a function called CreatePDFfromView(). The PDF viewer is handled by the TDPFQLPreviewController component. And finally opening the PDF in a third party app is handled by the UIDocumentInteractionController component. The UIDocumentInteractionController component is part of the FMX RTL which means you can use it in normal FMX apps as well. DPF IOS is used for the PDF viewer which means you can not mix other FMX controls on the same form with the PDF viewer. For a normal FMX app you can just use TWebBrowser to view PDFs under IOS which makes DPF IOS not a requirement. Obviously this example is only for IOS and not for Android, OSX, or Windows. You should be able to use the example with Appmethod as well. Full source code is provided. Here is a code snippet from the example:

uses
{$IFDEF IOS}
,iOSapi.Foundation, FMX.Platform.Ios, iOSapi.UIKit, Macapi.Helpers
{$ENDIF}
//
public
FController : UIDocumentInteractionController;
//
procedure TFPDFExport.FormCreate(Sender: TObject);
begin
FController := TUIDocumentInteractionController.Wrap(
TUIDocumentInteractionController.Alloc.init);
end;
//
procedure TFPDFExport.OpenIn(path: string);
{$IFDEF IOS}
var
URL: NSURL;
DPFBarItem: UIBarButtonItem;
success : Boolean;
{$ENDIF}
begin
{$IFDEF IOS}
URL := TNSUrl.Wrap(TNSUrl.OCClass.fileURLWithPath(StrToNSStr(path)));
FController.setURL(URL);
FController.setUTI(StrToNSStr('com.adobe.pdf'));
DPFBarItem := self.DPFToolbar1.BarItems[1].DPFBarItem;
success := FController.presentOptionsMenuFromBarButtonItem(
DPFBarItem , True);
{$ENDIF}
end;

Download the PDF creator/viewer/open in app demo source code for Delphi XE8 Firemonkey on IOS.

Have Delphi Firemonkey questions? Ask and get answers on StackOverflow.

Related posts
DelphiDemoFiremonkeyLinuxOSXShowcaseWindows

AutoBlogAI: FireMonkey Client To Leverage LLMs And Generative AI For Blogging

DelphiFiremonkeyShowcaseUtilityWindows

Unleashing Creativity With Song Writer AI: A Deep Dive

DelphiFiremonkeyShowcaseWindows

How To Build Stable Diffusion Text To Image Prompts

AndroidC++BuilderDelphiFiremonkeyIOSOSXWindows

FireMonkey 10.4.2 Features Updated iOS 14, Android 11, And macOS 11 Support Plus Hundreds Of Fixes

Sign up for our Newsletter and
stay informed

1 Comment

Leave a Reply