Cross platform system.openURL for embedded files

I have a PDF within my assets directory.  I’m attempting to trigger its display using:

 system.openURL('file:///' .. system.pathForFile('assets/schedule.pdf'))

based on another answer I found here on the forums.  The PDF loads properly from within the simulator.  When I try on my android device, I get the error “schedule.pdf is of invalid format”.  After some experimenting (using incorrect filenames) I believe that error means it can’t find the file.  What is the correct, cross-platform way to trigger the loading of an embedded PDF?

Thanks :slight_smile:

It says, schedule.pdf is of invalid format

and not

assets/schedule.pdf is of invalid format?

That seems like you’re not running the version with the path you described.  Did you accidentally not install the build?

Question, why not just:

system.openURL( system.pathForFile('assets/schedule.pdf') )

This works for me universally.

Try this sample:

Whatever you do, the local OS will needs a handler or this won’t work.  i.e. If there is no local app capable of loading a PDF and associated with the extension, this won’t work.

Thank you.  Using your demo app helped me solve the issue as I knew you’d tried it universally.  For future developers, I installed Adobe Acrobat Reader and changed the default PDF association to use it.  For some reason Google Drive will open the PDF if I have it downloaded to the device but will not open the same PDF if my Corona app requests it.  Adobe handles both cases.

I guess my confusion was that I knew there was something capable of opening PDFs (as I could see it being opened when requested from outside the app) and I knew there was nothing specifically wrong with that particular PDF (again, coz it opened).

Is this worth investigating further?

Regardless, thanks for the help roaminggamer, much appreciated.

It says, schedule.pdf is of invalid format

and not

assets/schedule.pdf is of invalid format?

That seems like you’re not running the version with the path you described.  Did you accidentally not install the build?

Question, why not just:

system.openURL( system.pathForFile('assets/schedule.pdf') )

This works for me universally.

Try this sample:

Whatever you do, the local OS will needs a handler or this won’t work.  i.e. If there is no local app capable of loading a PDF and associated with the extension, this won’t work.

Thank you.  Using your demo app helped me solve the issue as I knew you’d tried it universally.  For future developers, I installed Adobe Acrobat Reader and changed the default PDF association to use it.  For some reason Google Drive will open the PDF if I have it downloaded to the device but will not open the same PDF if my Corona app requests it.  Adobe handles both cases.

I guess my confusion was that I knew there was something capable of opening PDFs (as I could see it being opened when requested from outside the app) and I knew there was nothing specifically wrong with that particular PDF (again, coz it opened).

Is this worth investigating further?

Regardless, thanks for the help roaminggamer, much appreciated.