Search Unity

PDF reader

Discussion in 'Scripting' started by Steva, Dec 26, 2010.

Thread Status:
Not open for further replies.
  1. Steva

    Steva

    Joined:
    Sep 9, 2010
    Posts:
    60
    is it possible? In Unity i mean... the company i'm working for could really use it, and we are willing to pay someone to program a pdf reader for us...
     
  2. zumwalt

    zumwalt

    Joined:
    Apr 18, 2007
    Posts:
    2,287
    Not sure you have a purpose to read a PDF in Unity... Just google up PDF API's, if you find one that is a managed library, it will probably work, but what you want will be some way to convert the PDF to a PNG or JPEG so maybe look up PDF to JPEG or PNG converters, see if anyone has written one.
     
  3. Eric5h5

    Eric5h5

    Volunteer Moderator Moderator

    Joined:
    Jul 19, 2006
    Posts:
    32,401
    Pretty much everything is possible, but it would be highly non-trivial.

    --Eric
     
  4. Steva

    Steva

    Joined:
    Sep 9, 2010
    Posts:
    60
    Hmm actually what we need is a pdf reader with text search functionality, so no conversion to images for the moment... Right now we're thinking to integrate the unity app inside a native app (it's ugly but it could work), and since we need to pay someone to do that it would be better to have everything integrated in Unity...
    It's not a game btw...
    Anyone interested? :D
     
    MarcoLuzuriaga likes this.
  5. Sicarius Studios

    Sicarius Studios

    Joined:
    Sep 28, 2010
    Posts:
    8
    Sounds Interesting but unfortunately i do not have the expertise for this job but getting the pdf file would be easy but loading it inside unity is the problem. Can you give us any more details, like is it going to be loading multiple pdf files, but you could embedded a flash swf and that could handle the pdf files. Good Luck
     
  6. zumwalt

    zumwalt

    Joined:
    Apr 18, 2007
    Posts:
    2,287
    Displaying the information is one thing, to have the search features that are in the PDF is something totally different. Unity in a native app is simple enough to just publish as a web browser app and use the web interface in C# for instance. But to further try to show the PDF in Unity with search abilities in native PDF format, that link from Sicarius won't get you very far. One source to begin this research would be to look at DjVuLibre, http://djvu.sourceforge.net
    There is another open source technique from Samurajdata at http://view.samurajdata.se
    Finally there is a java renderer for PDF's that is open source to get to see how they did it: http://www.icepdf.org

    Any of those sets of code should get you started along the path you are looking, but search features? Trickier
     
  7. Steva

    Steva

    Joined:
    Sep 9, 2010
    Posts:
    60
    Ops i forgot to mention that by native i mean iOs, as we're developing for iPad... (please don't kill me xD) so flash is not an option :/ but yes, it needs to be able to load multiple pdfs (around 100) and navigate through them, like a catalog.

    Thank you i'll look into those; we may choose to discard the search functionality and go for a "chapters" navigation, but it all depends on the client's requests...
    I have very little experience with Objective-C and iOs functionalities, but is PDF reading a built-in feature or at least easier to achieve? If yes then we could enable the reader from inside Unity...
     
  8. zumwalt

    zumwalt

    Joined:
    Apr 18, 2007
    Posts:
    2,287
    You put in a new level of difficulty when you mentioned iPad/iPhone app, now, there are already PDF readers available for download with cataloging features, how they did this I have no idea. If you are looking to make a virtual cataloger for iPad/iPhone like the eBook readers, your best bet would be to do something Object-C Native, avoid Unity's overhead since you are trying to make a 3d version of the reader system. I am not saying it is impossible, but would probably require iPhone Pro version (which assuming you have it already), and a very strong familiarity of Object-C, personally, I think you are going overboard by using Unity and creating a PDF reader / cataloger. That is just IMHO though, it is a very challenging project, probably doable, not sure how, but anything is possible like Eric says.
     
  9. JonnyHilly

    JonnyHilly

    Joined:
    Sep 4, 2009
    Posts:
    749
    dragging up old thread... anyone every get any progress on this on iOS ? I'm looking into the same issue... view and interact with pdf contents, not just display it
     
  10. juan-jo

    juan-jo

    Joined:
    May 15, 2010
    Posts:
    162
    Me too.
     
  11. franky303

    franky303

    Joined:
    Aug 27, 2012
    Posts:
    10
    I'm looking for a simple solution to display a PDF using the iOS native PDF viewer. On Windows i can open a fullscreen PDF reader to display the PDF, on iPad i'd like to use the default PDF viewer. Is there any alternative to uWebKit for doing this? When i use Application.OpenURL it opens Safari ...
     
  12. unitrade

    unitrade

    Joined:
    Aug 27, 2012
    Posts:
    20
    in here i didn't find any pdf viewers. but just google it. you can find plenty of PDF viewers.
     
  13. stimarco

    stimarco

    Joined:
    Oct 17, 2007
    Posts:
    721
    The OS X "Cocoa", and iOS "Cocoa Touch", APIs both have built-in PDF support as standard. (The OS X GUI is actually built on PDF technology, so the PDF features are effectively 'free'.)

    The trick is finding a way to nail a Cocoa-built PDF viewer component onto your Unity project. Assuming you have suitable Unity Pro licenses, you can modify the default Xcode template(s) to add the PDF component. The only problem here is that you effectively have to jump back and forth between the Unity part to the PDF viewer part, which requires a good understanding of iOS, Cocoa Touch, and Objective-C programming.

    It's not exactly trivial, but it is possible.

    An alternative would be to build a proper C++ plugin that exposes iOS' PDF rendering features directly to Unity scripts. Much depends on your budget, UI design, and technical requirements.
     
  14. fffMalzbier

    fffMalzbier

    Joined:
    Jun 14, 2011
    Posts:
    3,276
  15. Abigail111

    Abigail111

    Joined:
    Aug 20, 2013
    Posts:
    2
  16. Dream_Code_TM

    Dream_Code_TM

    Joined:
    Jul 19, 2013
    Posts:
    38
  17. Lumen-Digital

    Lumen-Digital

    Joined:
    Aug 3, 2012
    Posts:
    16
  18. fffMalzbier

    fffMalzbier

    Joined:
    Jun 14, 2011
    Posts:
    3,276
    On the unity side of things there is not much to do.
    Code (CSharp):
    1.     [DllImport ("__Internal")]
    2.     private static extern void  NativeFunctionName(int textureId);
    3.  
    4.         public Texture2D myTex;
    5.  
    6.         // Use this for initialization
    7.         void Start () {
    8.        
    9.  
    10.             int myTexId = myTex.GetNativeTextureID();
    11.      
    12.             NativeFunctionName(myTexId);
    13.         }
    The rest is the difficult part of rendering the PDF into the opengl texture with the provided id.
    You do not not need to return anything , because you just overwrite the texture in the native code.
     
  19. fenden

    fenden

    Joined:
    Dec 22, 2014
    Posts:
    8
    Thank you a lot, the code works perfect for me.
     
  20. mark-pollard

    mark-pollard

    Joined:
    Apr 2, 2013
    Posts:
    14
    HI
    Does this plugin allow me to create a pdf document on an android device and have access to it after?

    I need to be able to create a pdf document from some records and then add it to a email as a attachment.

    Thanks
     
  21. siddharth3322

    siddharth3322

    Joined:
    Nov 29, 2013
    Posts:
    1,049

    Basically I can't able to understand your point, can you please provide me more details about reading pdf file ??
     
  22. fffMalzbier

    fffMalzbier

    Joined:
    Jun 14, 2011
    Posts:
    3,276
    The code i posted is just for calling a native plugin with the native texture id so that the Native code can write into the texture and the texture will be updated in Realtime inside of unity.
    Are you interested in learning how to render PDF to a texture or why are you asking?
    If not i would recommend to use one if the many plugins in the assetstore.
    My favorite on is this one: https://assetstore.unity.com/packages/tools/gui/pdf-renderer-32815

    I do not have the old code for rendering the PDF to the native texture id arround anymore, but the code is now 6 years old so i would not expect it to work with the current unity / ios version (yes it was ios only since ios has a native pdf rendering capability)
     
    Last edited: Apr 9, 2018
    siddharth3322 likes this.
  23. siddharth3322

    siddharth3322

    Joined:
    Nov 29, 2013
    Posts:
    1,049
    Thank you @fffMalzbier for your reply. I require to display PDF content within application kind of game so that I am researching.
    Plugin that you mentioned that is really good but its price is too high, outside of my purchase capacity and current project requirements :)

    If I want to open PDF using Application.OpenURL then how can I do this?
    Where in project I require to place actual PDF file?
     
  24. fffMalzbier

    fffMalzbier

    Joined:
    Jun 14, 2011
    Posts:
    3,276
    A
    if you want to have assets available to the OS / other apps , put them in the streaming asset folder, thy will be copied over into your build.
    https://docs.unity3d.com/Manual/StreamingAssets.html

    You can use Application.streamingAssetsPath + Filename on ios and windows, on android there are some problems witht his, what is your target platform?
    (keep in mind that this will not draw the PDF instad of unity but will open the default application that is associated with the pdf file format.
     
    siddharth3322 likes this.
  25. siddharth3322

    siddharth3322

    Joined:
    Nov 29, 2013
    Posts:
    1,049
  26. CrossGamers5555

    CrossGamers5555

    Joined:
    Dec 23, 2017
    Posts:
    5
    any other way to read pdf?
     
  27. siddharth3322

    siddharth3322

    Joined:
    Nov 29, 2013
    Posts:
    1,049
  28. CrossGamers5555

    CrossGamers5555

    Joined:
    Dec 23, 2017
    Posts:
    5
    siddharth3322 likes this.
  29. AshleyBates

    AshleyBates

    Joined:
    Feb 24, 2017
    Posts:
    34
  30. MelvMay

    MelvMay

    Unity Technologies

    Joined:
    May 24, 2013
    Posts:
    11,459
    No need to necro a 13 year old thread, you can use the report button. That domain was valid but disappeared a long time ago. I'll delete the post and yours.

    EDIT: I can see you reported the link as well, thanks but that's all you needed to do.

    Thanks.
     
Thread Status:
Not open for further replies.