Newly created pdfs do not open on iPads

Hi,

I'm having an issue with PdfLib from TMS Pack for FireMonkey.

After creating a pdf (p.EndDocument(True);) it does not open on iPads. iPhones work fine, though.

Tested iOS Versions 12.1.2 to 12.1.4, Delphi 10.3, TMS Pack for FireMonkey 3.7.2.0.

A possible workaround by creating a pdf without automatically opening it and then using iCLs TTMSFMXNativeUIDocumentInteractionController.ShowPreview does not work either, the pdf will not open.
The preview will show up when I select the pdf from a list later, but not immediately after the pdf was created. This happens on iPhones too.

Best regards,
Thorsten

Hi,


Can you try the following workaround:

Create a PDF without automatically opening it and then use the TTMSFMXUtils.OpenFile method, with the location of the PDF, and a control reference from where the interaction controller should be presented from.
Hi Pieter,

your workaround did not help.

We tested with an iPad Pro MLQ62FD/A and an iPad Wi-Fi 32 GB MR7F2FD/A (A1893)

iPhones are still ok with the workaround.

Hi,


We have tested this here on an iPad and are not experiencing issues. The popup is shown i the center of the screen, and allows opening with acrobat, or books with the following code:



uses
  FMX.TMSPDFLib, IOUtils;


procedure TForm54.Button1Click(Sender: TObject);
var
  p: TTMSFMXPDFLib;
  fn: string;
begin
  fn := TPath.GetDocumentsPath + PathDelim + 'test.pdf';
  p := TTMSFMXPDFLib.Create;
  try
    p.BeginDocument(fn);
    p.NewPage;
    p.EndDocument(True);
  finally
    p.Free;
  end;
end;


are you able to test older iOS version to see if there is an issue regarding the iOS version instead of the component itself?

Hi,

this does not work either!

The oldest iOS version we were abe to test was 12.0.1.
We compiled with xcode 10.1 (10B61), and iPhoneOS 12.1 SDK

Which version was your iPad?

Ours was iOS 11.2. We'll investigate if we can test on iOS 12. It could potentially be an iOS version issue.

Hi, We have tested this here on iOS 12.1.4 and are not able to reproduce this. After running the PDFLib Demo, and clicking on the button, the PDF is generated and you can open it with iBooks, via the UIDocumentInteractionController that is prompted after calling the EndDocument with a true parameter.


As we are not able to reproduce this, it's actually unclear exactly what is going wrong. Did you test this with the demo? Did you try this in a new project?
Hi,

we've tested the demo in a new project today. It has the same issue.

I'd like to double check whether the problem is caused by our iPads or the development environment.
Can I invite you to test our demo with testflight? Can we test your app on our iPad?

The demo did not work on iOS out of the box, though.
I had to delpoy the files test2.txt, Sample.jpg and Sample2.jpg (remote path: StartUp\Documents) and change the save path of the pdf to TPath.GetDocumentsPath.
May the save path of the pdf be an issue?

Thanks you.

Hi,


It's a very strange issue, we have no issues here, and specially upgraded an iPad to test against iOS 12.1.4. Can you try saving the PDF to TPath.GetSharedDocumentsPath instead? Can you verify with FileExists on the path that it actually exists? Can you for instance, load a sample PDF in the project deployment window and try opening it with the TTMSFMXUtils.OpenFile method? Can you open other files, such as Images files or document files?

Hi,


TPath.GetSharedDocumentsPath is empty on iOS (see

http://docwiki.embarcadero.com/Libraries/Tokyo/en/System.IOUtils.TPath.GetSharedDocumentsPath),
so this will not work.


However, we tested a few other things:
1) TTMSFMXUtils.OpenFile does not work
2) TTMSFMXNativeUIDocumentInteractionController.ShowPreview works when triggered by a button click after the pdf was created
3) TTMSFMXNativeUIDocumentInteractionController.ShowPreview works not when called immediately after creating the pdf.
4) Adding a call to Application.ProcessMessages between pdf creation and TTMSFMXNativeUIDocumentInteractionController.ShowPreview does not work either

Strange indeed.

PS: I forgot to test TTMSFMXUtils.OpenFile with some other file types, will do that tomorrow.




After further testing...

5) TTMSFMXUtils.OpenFile does not work with an image
6) Using a Timer (250ms) after pfd creation to call TTMSFMXNativeUIDocumentInteractionController.ShowPreview does not work

So it seems like we need a user interaction before the Preview works and OpenFile never works.
I cross-checked on an iPhone without any issues.

Can I invite you to test our binary on your iPad with TestFlight?
Can we test the binary that worked on your iPad on one of our devices?

As this reminds me of thread behaviour, can you try the following code snippet:


TThread.Queue(TThread.CurrentThread,
procedure
begin
  TTMSFMXUtils.OpenFile(MyFile);
end
);
Using a Thread does not work.

How about TestFlight?

That can potentially be helpful yes, so perhaps you can sign me up, please send us an email to support@tmssoftware.com with a link to this thread, for further communication on this issue.