Dec. 18th, 2012

alexpgp: (Computing)
I'm slowly coming to the realization that if I want to do something with a PDF file in Acrobat X that I hadn't done before, I may as well go ahead and Google whatever it is I want to do first, to see if it's even possible, or at least to get an idea of how hard it will be.

For example, my new-found invoicing program, BambooInvoice, outputs PDFs in the A4 format popular in Europe instead of the "Letter" format (8½ x 11) used in the U.S. So I opened Acrobat X and searched, in vain, for a way to save the document in Letter format. Apparently, instead of providing such a capability, the application automagically restructures the file in the event you decide to print it, so that any footer—which would be cut off the bottom of an A4 document printed on Letter paper—appears where it should be.

But that's not what I wanted.

So I pushed my luck and searched the BambooInvoice source code for references to 'pdf' and found—as before—the appropriate function (create_pdf) in its very own file! And that file contained about a dozen lines, one of which specified the paper to be "a4" (which I changed to "letter")! Hot diggety! Now my invoices—two of which have been sent to clients on a test basis—are generated using the 8½ x 11 format.

Paraphrasing Auric Goldfinger from Ian Fleming's novel Goldfinger, my first painless experience modifying BambooInvoice source code can be attributed to happenstance. This second one, to coincidence.

If it happens a third time, I'll have to conclude the software is just well-organized! (Because my coding-fu ain't the sharpest tool in the bag!)

Cheers...

UPDATE of 2:13 pm: It turns out that modifying rates to allow fractions of a penny has the incompletely thought-out consequence of displaying all currency amounts to three digits past the decimal point, which looks kinda goofy when charging for certain kinds of work (e.g., $40.000 per hour).

So I revisited the pdf output file and learned how to use the PHP preg_replace function to strip off that third digit past the decimal if it's a zero, like so:
preg_replace('/\.(\d\d)0/', '.\1', $item->amount)
Not quite a third time, but close. :^)

Profile

alexpgp: (Default)
alexpgp

January 2018

S M T W T F S
  1 2 3456
7 8910111213
14 15 16 17181920
21222324252627
28293031   

Most Popular Tags

Style Credit

Expand Cut Tags

No cut tags
Page generated Aug. 12th, 2025 06:42 pm
Powered by Dreamwidth Studios