PDF output?

Cogman

Lifer
Sep 19, 2000
10,286
145
106
So, I want to be able to output pretty reports that are printable without screwing up page-breaks ect. PDFs seem to be the most widely supported printer/friendly output format, the problem is, how do you create a PDF from code?

I'm cheap, and would prefer a free solution. The most promising that I've looked at have been XeTeX and pdftex. However, I can't find any sort of documentation for interfacing with them programatically (I would prefer linking to them rather then executing external programs.)

Any help, or alternate solutions would be welcomed. I would prefer not having to read over the XeTeX source just to learn how to use it :).

BTW, I particularly like the Tex->PDF route, because Tex is pretty easy to modify from a programming standpoint, so it is easy to insert needed variables/duplicate sections ect.

If worst comes to worst, I'm reading the adobe supplement iso standard for PDFs :).
 
Last edited:

Crusty

Lifer
Sep 30, 2001
12,684
2
81
I think the easiest solution would still be to emit the markup you need and then just run it through whatever tool you need to generate the PDF. You could setup a web service that accepts the raw markup data and returns a PDF file so you only have to deal with setting up what Tex parser you use once and so clients don't have to know WTF Tex is. That said... I guess it depends on your use case :p
 

Cogman

Lifer
Sep 19, 2000
10,286
145
106
When I say reports, I don't mean like system logs. I'm talking about dynamically generated content. Like and Invoke for a company, or a list of employees time spent working.

I don't really want the server saving this stuff, so it will essentially just barf a PDF out to the user when they click "generate report". Let the user save the reports they think are critical.

I do want them (the admins) to be able to customize their available reports. using a sort of markup language might be a better solution, however, then you have to get the tools that can read said markup language.
 

Shilohen

Member
Jul 29, 2009
194
0
0
Last edited:

Cogman

Lifer
Sep 19, 2000
10,286
145
106
Well, I've found what I'm looking for. It only supports PDF creation, so I'll still have to manage how in between templates are read/handled, but that's really not too bad (at least, I hope it won't be :))

The projects name is PoDoFo and while it isn't too old, it seems to have the functionality that I want. (and isn't under the AGPL, that license is terrible.)
 
Last edited:

Cogman

Lifer
Sep 19, 2000
10,286
145
106
If Java does not disgust you, there's JasperReports (http://jasperforge.org/projects/jasperreports) and iText (http://itextpdf.com/). For the latter, if you want to separate the CSS from the HTML you can use Flying Saucer as well (http://today.java.net/article/2007/06/21/generating-pdfs-fun-and-profit-flying-saucer-and-itext). To compose the HTML, it's possible to use FreeMarker as a templating engine (http://freemarker.sourceforge.net/). All of them are open source freeware.
Java doesn't disgust me. The problem is, the project is nearly complete and written in c++... So, making the switch to java right now would be excessive.
 

Shilohen

Member
Jul 29, 2009
194
0
0
Deploy the report service as a WS* or RESTful service written in Java and call it from your C++ application then? :p

Seriously, while the above would be possible, since the C++ application probably already has all the necessary data at hand, I wouldn't see a reason to change either, unless PoDoFo ends up being a huge pain in the a**.
 

CycloWizard

Lifer
Sep 10, 2001
12,348
1
81
I'm not sure I understand exactly what you're trying to do, but pdftex should work if you want to automatically generate some output. There are plenty of pdftex compilers which should be able to do it, though I have only used it to typeset papers which I've written manually using MikTeX and TeXnicCenter.
 

Cogman

Lifer
Sep 19, 2000
10,286
145
106
I'm not sure I understand exactly what you're trying to do, but pdftex should work if you want to automatically generate some output. There are plenty of pdftex compilers which should be able to do it, though I have only used it to typeset papers which I've written manually using MikTeX and TeXnicCenter.
:) I'm trying to serve dynamically created PDFs which never touch the servers hard-drive.

Word of warning. PoDoFo uses a RETARDED build system, and has a nice inbuilt bug in it that prevents it from easily compiling on windows without some code tweaking.

Why developers think they HAVE to stray from the standard configure, make, make install build sequence for some imagined better cross platform compatibility is beyond me. make and config is good enough for x264 which probably hits the most platforms of any software I've seen, its good enough for any software developer.[/rant]

Its too bad PoDoFo's API and Syntax is the best I've seen for free pdf file creation, I would have given up on building it hours ago if it wasn't for that.
 
Sep 29, 2004
18,656
68
91
Assuming this is a project that is costing money. And not some $2000 project. But an actual large contract, wouldn't it be worthwhile contacting Adobe and inquiring about their products? I'm sure they have an API for C/C++ somewhere that is for sale to developers.
 

Cogman

Lifer
Sep 19, 2000
10,286
145
106
Assuming this is a project that is costing money. And not some $2000 project. But an actual large contract, wouldn't it be worthwhile contacting Adobe and inquiring about their products? I'm sure they have an API for C/C++ somewhere that is for sale to developers.
it is some less then $2000 project. Otherwise I would agree with you.

The current route I'm taking is a combination of libxml and podofo.
 

MGMorden

Diamond Member
Jul 4, 2000
3,348
0
76
I've used sharpPDF with good results in some projects. Works with with .NET.

In PHP code I've also used TCPDF. It works fine (and in formatting was actually far more flexible than sharpPDF), but is very, very slow. For generating a page or two it's fine, but I was trying to output a 90k+ page document (well, it was set to break the document into 2000 page files, but the entire batch was over 90k pages). TCPDF at the rate it was going was going to take almost 16 hours to complete the job. Equivalent code, done in C# using sharpPDF generated the files in under 10 minutes.