Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. Dismiss Notice

Generate PDF

Discussion in 'Scripting' started by Staples, Oct 25, 2011.

  1. Staples

    Staples

    Joined:
    Jan 14, 2009
    Posts:
    224
    I have a situation where I need to generate a PDF that can be saved from unity, and then opened on the desktop (and perhaps iPad).

    Anyone have any suggestions for this? We have Pro so we might be able to use a native code library if there is one suitable, in fact that might be the only way to go about this?

    Thanks
     
  2. Ntero

    Ntero

    Joined:
    Apr 29, 2010
    Posts:
    1,436
    MNNoxMortem likes this.
  3. Staples

    Staples

    Joined:
    Jan 14, 2009
    Posts:
    224
    As already mentioned, I already know I can use an external library, so I was wondering if there are any other options.... I'm also not sure if these can be used on an iPad version?
     
  4. andorov

    andorov

    Joined:
    Feb 10, 2011
    Posts:
    1,061
    http://itextpdf.com/

    Open source and entirely written in C#, so you should be able to use it "out of the box" or atleast learn a lot from it.

    EDIT: Alternatively, you can post data to a webserver and have the webserver generate the report.
     
  5. Ntero

    Ntero

    Joined:
    Apr 29, 2010
    Posts:
    1,436
    Ok then, yeah Unity does not have any built in PDF creation tools. So you basically have 2 options: Use an existing, external library, or make your own. I'd suggest these C# ones at the search over a native one if you don't have any experience with an existing plugin, as these will be easier to integrate and test from within Unity.

    PDF is a file specification, so as long as the generator supports a specific element of the specification (images, shapes, fonts, etc...) then it should support it across all platforms you can see normal PDFs on.
     
  6. Staples

    Staples

    Joined:
    Jan 14, 2009
    Posts:
    224
    Yeah I've done this before, but this needs to be available for standalone in "offline" mode as well unfortunately =(

    So something like that itextpdf should work on standalone PC Mac builds, and even iPad builds? (just not webplayer since you can't include externals?)
     
  7. andorov

    andorov

    Joined:
    Feb 10, 2011
    Posts:
    1,061
    IIRC, iTextSharp can write a pdf onto a System.IO.MemoryStream (which can even be used in web player builds).. now, whether you can save the resulting binary data (byte[]) onto the system, I don't know. One images you can, however.
     
  8. Staples

    Staples

    Joined:
    Jan 14, 2009
    Posts:
    224
    Okay thanks, from what I read iPad seemed to support external libraries, but I wasn't 100% sure, and I don't know a lot about the file system, if it lets you prompt to save a PDF, things like that.

    Hmm I was under the impression that Web player couldn't use external libraries at all? They aren't included in the build?
     
  9. Ntero

    Ntero

    Joined:
    Apr 29, 2010
    Posts:
    1,436
    Yeah iOS supports the full suite of File writing, so long as you use the proper folders Apple provides. There is no prompt, you have to create those yourself, (or not if you don't want to ask the user).

    Also, C/ObjC/C++ plugins don't work in the Web Player, but C# libraries should work. I've not tested it, but it's a .NET dll just like any other, and I can't see why it wouldn't. You can already include the other .NET dlls so this is just one more.
     
  10. andorov

    andorov

    Joined:
    Feb 10, 2011
    Posts:
    1,061
    C# libraries work across the board. AFAIK, you just have to be careful as to what you reference in them. I think the web player supports .NET 3.5 but the iOS/Android devices only do 2.0 + some random stuff.
     
  11. Staples

    Staples

    Joined:
    Jan 14, 2009
    Posts:
    224
    Oh okay, so it's just a matter of using one that doesn't use anything external that's non .NET, or restricted. Interesting!

    Mind you I'm not sure how useful that would be on the webplayer since you probably can't prompt to save the PDF unless you route it through the webpage via the server.
     
  12. Jaimi

    Jaimi

    Joined:
    Jan 10, 2009
    Posts:
    6,171
    Be mindful of the new iText license. The previous version allowed distribution with closed source applications. The current one does not, and has some hefty fees.
     
  13. Staples

    Staples

    Joined:
    Jan 14, 2009
    Posts:
    224
    Yeah I noticed that, any idea how hefty we are talking? We are willing to pay for things like those, within reason.
     
  14. MihaMarn

    MihaMarn

    Joined:
    Nov 6, 2017
    Posts:
    15
    At a risk of necroing this thread: I am also looking into creating pdf documents in my app but non of the libs I have tryed dont work on android. Any sugestions? I have tryed migrados and pdfSharp (the oficial versions)
     
  15. MihaMarn

    MihaMarn

    Joined:
    Nov 6, 2017
    Posts:
    15
    I have stumbled across this: http://www.devindia.biz/unity-pdf-generation-with-sharppdf-plugin/
    It is not a plugin, it is a whole project. The guy in schwitzerland gave me a permission to use it comercially. He was relly nice about it.
    It is not the most easy to use and needs some more work in tearms of paragraphing , but I find it usefull. Maybe if I have time someday I will upgrade it an opensource it on github.....
     
  16. appmechanic

    appmechanic

    Joined:
    Sep 10, 2016
    Posts:
    14
    @unity_E6C76QCz9SVV2w
    Link is not working, Can you share this project with me ?
    If any other solution for PDF please share with me.
    Thanks with me.
     
  17. jinendramehta

    jinendramehta

    Joined:
    Oct 4, 2018
    Posts:
    2
    Can you help me in implementing ZetPDF SDK in Unity
     
  18. Mayank516

    Mayank516

    Joined:
    Nov 17, 2014
    Posts:
    7