You want more?!

Awhile back, (awhile being a few years now) Anthony and I wrote a document processing system in PHP for the company. It takes in XML data and merges this with OpenOffice documents as templates to create final dynamic merged PDF documents for printing, email, and storage on disk. It has been running ever since, processing a few hundred documents a week.

This system actually replaced another one that did close to the same thing, but required Microsoft Word, licenses for Office, and multiple servers and Windows installations and .NET programming. It was horrible, slow, and unstable. Which lead us to create the new system.

A few days ago I was asked to add another template to the server, which happens a few times a month. But this time the document to be added was a PDF file already, very complex actually. Having multiple form fields and such. I tried to recreate / convert it to OpenOffice but it always comes out ugly. So instead of working around this, I went ahead and added some more code to the program to take in the XML data as usual, and for this one document (or more in the future) to merge FDF data into the PDF.

Searching around where to start, and found a good site: which gave some very useful information. What I really needed was the php function he offers here: Take a look, it’s kinda neat.

It is in production now, and working very well!

By |March 24th, 2010|Categories: General|Tags: , |0 Comments

Looking through scripts

Every now and then at work I have to dig through a few scripts to find some off the wall command that is run at a specific time, and to run it manually. Today I had to find a few commands so I opened a script that controls the shutdown of all databases, and found a nice block of comment code that was left from a friend, best damn UNIX guy I know. I’ll post an excerpt of it here, taking out the stuff that I should really not make public for obvious reasons.

#### DO NOT try to fix this! ###
# The following loop is absolutely painful, and I know you THINK you
# know a better way to do this, but trust me, it won't work. It will
# LOOK like it worked, and you won't know the difference until you have
# to restore from the backup you created and it fails.
# The ----- command used to shut down the databases completes
# successfully (return code 0) BEFORE the database is actually shut
# down (if you don't believe me, call -------- --------- Corporation
# and ask them 000-000-0000. Therefore we cannot start truncating
# the ----- just because ----- completed successfully. The ------
# command used in this loop returns an exit code of 0 if the database
# is shut down, and some positive value otherwise. In this loop we
# go through all of the databases, add up the exit codes for each one,
# and repeat until the sum is 0 (meaning all databases are shut down).
# It would be easier to grep 'ps -ef' output for the '-------' database
# server process, but so far we can't get ------- Tech Support to
# confirm that no other process could be modifying database files,
# so this is the only method that has the -------- stamp of
# approval.
# -- BEGIN brain dead loop --

Sorry, I just love finding odd bits of code from others during normal day operation.

By |March 23rd, 2010|Categories: Code|Tags: |0 Comments