Generate PDF

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

This seems like a pretty good starting point:
http://lmgtfy.com/?q=Generate+PDF+C%23&l=1

1 Like

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?

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.

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.

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?)

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.

Yeah I noticed that, any idea how hefty we are talking? We are willing to pay for things like those, within reason.

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)

I have stumbled across this:[ http://www.devindia.biz/unity-pdf-generation-with-sharppdf-plugin/](http:// 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…

@MihaMarn
Link is not working, Can you share this project with me ?
If any other solution for PDF please share with me.
Thanks with me.

Can you help me in implementing ZetPDF SDK in Unity

Hi ,

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 :

iOS : Pdf Downloader & Generator For iOS | Integration | Unity Asset Store
Android : Pdf Generator for Android | Integration | Unity Asset Store