How to load pdf file with ios ?

Hi,

I need to open pdf files with ios for an industrial application. Currently I build pdf file from StreamingAssets folder which is then reading as bytes and writen in the documents folder of the app with FileStream library.

Pdf file looks ok on the Documents folder (I can see it in the Xcode app details panel) but i can’t open it with the Application.OpenURL function, nothing happen whereas it works fine on my mac !

Here is the code :

private void WriteAndLoadFile()
{
	string filePath = Path.Combine(Application.streamingAssetsPath, "file.pdf");
		
	fileBytes = File.ReadAllBytes(filePath);

	cachedFile = Path.Combine(Application.persistentDataPath, "file.pdf");
	Debug.Log(cachedFile);

	FileStream cache = new System.IO.FileStream(cachedFile, System.IO.FileMode.Create);
	cache.Write(fileBytes, 0, fileBytes.Length);

	cache.Close();

	Application.OpenURL(cachedFile);
}

What i am doing wrong ??

Thanks !

Hello,

Check out this plugin : prime31 - Unity plugin and asset documentation and look at the showWebPage function to open an external view of your pdf file.

Hello!

I tried to do the same thing as @AliasVincent but came across the same problems. I ended up writing a native iOS plugin for Unity to preview a PDF file on iOS without leaving the app, I shared the code here:

iOS open docx file from Application.persistentData - Unity Answers


I hope it helps!