Has anyone gotten Unity to produce out a pdf file?

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?

Its an enterprise app. It is sort of like a 3D order form, client wanted the ability to email a pdf from the app representing their order.

Sounds interesting… did you get it done?

Hi eem,

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 :wink: This is what you have to do:

  1. Download iText as C# from this site: http://itextpdf.com/download.php
  2. Put the two files: itextsharp.dll and itextsharp.xtra.dll in your Plugin-Folder
  3. This site has a lot of examples: http://www.ujihara.jp/iTextdotNET/en/examples.html

But you have to use a different “using”:
For example:
using iTextSharp.text; instead of “using com.lowagie.text;”
using iTextSharp.text.pdf;

I hope this helps you.

I need any example sir. I couldnt do it.