I am trying to get Unity to spit out a PDF file. Not quite working. I am using the PDFJet library, and I have altered the library to use the ICSharpCode.SharpZipLib library because it originalliy the PDFJet library relied on system.io.compression, which seems to have issues under OSX. But I can’t get it to work, the SharpZipLib is not giving back the proper byte array of the compressed data.
Just wondering, has anyone found a way to get Unity to produce a pdf?
If anyone searches for this, thought I would fill you in on what I did.
For iOS I wrote a function in objective c, using the native PDF libraries to iOS and then marshalled a chunk of data from C# to that objective c function to output the pdf.
On Windows I first tried using the pdfJet library compiled to a dll as a plugin in unity, so then unity could output pdf files directly. However pdfJet relies on a zip function in Mono that unity did something funky to and will give a ‘some something posix’ error. I attempted to edit the pdfjet library to use a different zip library that would work in unity. But I could not get this to work. I got the code running and compiling, but it wasn’t producing PDF’s that worked. Maybe someone could get it to work? I don’t know. I gave up.
So then I tried pdfclown library as a plugin to unity which unity just could not use as a plugin at all. I tried altering the library in ways to make it work. But it just wouldn’t work.
So I basically just made an entirely seperate .exe compiled from Visual Studio .NET that used the pdfclown library to generate a pdf. Unity will output a txt file ‘pdfOutput.txt’ that contains all the information that is necessary to generate a pdf, text, text positions, images, image positions etc. It will then launch the seperate .exe via Process.Start(), which will automatically look for a pdfOutput.txt file, and if it finds it, then it will generate a pdf off of it.
Out of curiousity… why did you need/want to produce a pdf from insdie Unity? I mean what kind of game? Or is it supposed to be some kind of app for a phone?
i want to do the same thing as you. My Programs reads data from a database save them to a pdf. I found your comment, and so i googled it myself. And boom 10 Minutes later it worked. I was lucky This is what you have to do: