Frequently Asked Component Specific Questions
Options |
|
Display all FAQ items |
Displaying items 1 to 1 of 1, page 1 of 1
<< previous next >>

TMS iCLPrinting a PDF File
To print a pdf file from iOS, you can use the following code to access the UIPrintInteractionController (it requires MacApi.ObjectiveC, iOSApi.UIKit and iOSApi.Foundation units)
type
TUIPrintInteractionControllerCompletionHandler = procedure(printInteractionController: Pointer;
completed: Pointer; error: Pointer) of object;
UIPrintInteractionControllerClass = interface(NSObjectClass)
['{D3566B82-3014-40C6-B7E3-DFC22AF39319}']
{class} function canPrintData(data: NSData): Boolean; cdecl;
{class} function canPrintURL(url: NSURL): Boolean; cdecl;
{class} function isPrintingAvailable: Boolean; cdecl;
{class} function printableUTIs: NSSet; cdecl;
{class} function sharedPrintController: Pointer; cdecl;
end;
UIPrintInteractionController = interface(NSObject)
['{0FEF6AA7-132B-41C8-BB12-045C43027D4B}']
function delegate: Pointer; cdecl;
procedure dismissAnimated(animated: Boolean); cdecl;
function printFormatter: UIPrintFormatter; cdecl;
function printInfo: UIPrintInfo; cdecl;
function printPageRenderer: UIPrintPageRenderer; cdecl;
function printPaper: UIPrintPaper; cdecl;
function printingItem: Pointer; cdecl;
function printingItems: NSArray; cdecl;
procedure setDelegate(delegate: Pointer); cdecl;
procedure setPrintFormatter(printFormatter: UIPrintFormatter); cdecl;
procedure setPrintInfo(printInfo: UIPrintInfo); cdecl;
procedure setPrintPageRenderer(printPageRenderer: UIPrintPageRenderer); cdecl;
procedure setPrintingItem(printingItem: Pointer); cdecl;
procedure setPrintingItems(printingItems: NSArray); cdecl;
procedure setShowsPageRange(showsPageRange: Boolean); cdecl;
procedure presentAnimated(animated: Boolean; completionHandler:
TUIPrintInteractionControllerCompletionHandler); cdecl;
function showsPageRange: Boolean; cdecl;
end;
TUIPrintInteractionController = class(TOCGenericImport<UIPrintInteractionControllerClass,
UIPrintInteractionController>) end;
var pi: UIPrintInfo; pic: UIPrintInteractionController; fileURL: Pointer; begin pi := TUIPrintInfo.Wrap(TUIPrintInfo.OCClass.printInfo); pi.setOutputType(UIPrintInfoOutputGeneral); pi.setJobName(TMSFMXNativeUIWebView1.WebView.request.URL.absoluteString); pi.setOrientation(UIPrintInfoOrientationPortrait); pi.setDuplex(UIPrintInfoDuplexLongEdge); pic := TUIPrintInteractionController.Wrap(TUIPrintInteractionController.OCClass.sharedPrintController); pic.setPrintInfo(pi); pic.setShowsPageRange(True); fileURL := TNSURL.OCClass.fileURLWithPath(NSSTR(ExtractFilePath(ParamStr(0))+'sample.pdf')); pic.setPrintingItem(fileURL); pic.presentAnimated(True, PrintCompleted); end;