Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 13 Next capture
2021 2022 2023
1 capture
13 Jun 22 - 13 Jun 22
sparklines
Close Help
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
  • Asset Store
  • Get Unity

UNITY ACCOUNT

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account
  • Blog
  • Forums
  • Answers
  • Evangelists
  • User Groups
  • Beta Program
  • Advisory Panel

Navigation

  • Home
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
    • Blog
    • Forums
    • Answers
    • Evangelists
    • User Groups
    • Beta Program
    • Advisory Panel

Unity account

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account

Language

  • Chinese
  • Spanish
  • Japanese
  • Korean
  • Portuguese
  • Ask a question
  • Spaces
    • Default
    • Help Room
    • META
    • Moderators
    • Topics
    • Questions
    • Users
    • Badges
  • Home /
avatar image
0
Question by AliasVincent · Nov 22, 2013 at 10:19 PM · iospdfopenurl

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 !

Comment
Add comment · Show 3
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image Graham-Dunnett ♦♦ · Nov 22, 2013 at 10:19 PM 1
Share

$$anonymous$$aybe your url needs to start with file://?

avatar image AliasVincent · Nov 23, 2013 at 01:15 PM 0
Share

I already tried this, it works only on mac os...

avatar image sramos_eurecat · Apr 04, 2016 at 08:32 AM 0
Share

Hi, I'm struggling with the same issue on IOS. Could you find a solution?

2 Replies

· Add your reply
  • Sort: 
avatar image
0

Answer by AliasVincent · Apr 05, 2016 at 08:34 AM

Hello,

Check out this plugin : https://prime31.com/docs#iosEtc and look at the showWebPage function to open an external view of your pdf file.

Comment
Add comment · Show 1 · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image sramos_eurecat · Apr 05, 2016 at 09:01 AM 0
Share

Thanks, that's actually what I ended up doing. Unfortunately I couldn't find a way to open it without having to use external plugins and I guess you neither. But these prime31 plugins work like a charm. I could open not only PDF but also XLS, PPT, DOC, TXT, images, audio and video with the same method. Regards.

avatar image
0

Answer by martejpad · Oct 30, 2017 at 11:29 AM

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:

http://answers.unity3d.com/questions/1337996/ios-open-docx-file-from-applicationpersistentdata.html?childToView=1426652#answer-1426652


I hope it helps!

Comment
Add comment · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users

Your answer

Hint: You can notify a user about this post by typing @username

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Follow this Question

Answers Answers and Comments

20 People are following this question.

avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image

Related Questions

Open a pdf file from the Resources folder on iOS 1 Answer

iOS Application.OpenUrl("app-settings:") Camera Crash Issue 1 Answer

Unity IOS - Open a In-App Web Browser 2 Answers

iOS Loading Local PDF/HTML from StreamingAssets 0 Answers

Alternative to 'Application.OpenURL()' for newest Android API 1 Answer


Enterprise
Social Q&A

Social
Subscribe on YouTube social-youtube Follow on LinkedIn social-linkedin Follow on Twitter social-twitter Follow on Facebook social-facebook Follow on Instagram social-instagram

Footer

  • Purchase
    • Products
    • Subscription
    • Asset Store
    • Unity Gear
    • Resellers
  • Education
    • Students
    • Educators
    • Certification
    • Learn
    • Center of Excellence
  • Download
    • Unity
    • Beta Program
  • Unity Labs
    • Labs
    • Publications
  • Resources
    • Learn platform
    • Community
    • Documentation
    • Unity QA
    • FAQ
    • Services Status
    • Connect
  • About Unity
    • About Us
    • Blog
    • Events
    • Careers
    • Contact
    • Press
    • Partners
    • Affiliates
    • Security
Copyright © 2020 Unity Technologies
  • Legal
  • Privacy Policy
  • Cookies
  • Do Not Sell My Personal Information
  • Cookies Settings
"Unity", Unity logos, and other Unity trademarks are trademarks or registered trademarks of Unity Technologies or its affiliates in the U.S. and elsewhere (more info here). Other names or brands are trademarks of their respective owners.
  • Anonymous
  • Sign in
  • Create
  • Ask a question
  • Spaces
  • Default
  • Help Room
  • META
  • Moderators
  • Explore
  • Topics
  • Questions
  • Users
  • Badges