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?
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?
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.
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.
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?
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.
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.
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.
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.
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)
It might be late but can help other devs searching for similar functionality for iOS and Android. I have used following plugins to generate pdfs and they works excellent. Developer is very helpful too. Links :