Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How can I use a non-embedded font when constructing PDF from scratch?

Status
Not open for further replies.

silverspecv

Programmer
Oct 31, 2003
125
US
I am trying to put a small program on our web-based intranet that can be used to print checks. I have a util that will allow me to more of less "construct" a pdf from scratch. It comes out as straight text with a .pdf extension. The problem is that I need to use a MICR font for the check number, but I can't get it to work. It seems that there is a predefined set of standard fonts that are the only ones available. If I use anything other than that, I get the error "The font '____' contains a bad /BBox."

Is there a way around this such as embedding the font or some trick to make it read the font from Windows, or can I set a good /BBOX (whatever that is)?
 
I've been digging and digging, but I can't find any concrete information that pertains to my situation. I'm using Macromedia ColdFusion to read in form data from a web browser and then, after submitting, call a utility called <cf_pdf> which creates the file. It works by setting up the header and then putting in the appropriate tags and such for adding fonts and finally the datastream.

Here's an example that works:

<cf_pdf action="init" file="c:\test.pdf" fonts="Arial|Arial,Bold|Arial,Italic">
<cf_pdf action="startpage">
<cf_pdf action="addtext" x="25" y="758" fontsize="10" fontnum="1" text="Arial text">
<cf_pdf action="addtext" x="25" y="745" fontsize="10" fontnum="2" text="Arial Bold text">
<cf_pdf action="addtext" x="25" y="732" fontsize="10" fontnum="3" text="Arial Italic text">
<cf_pdf action="endpage">
<cf_pdf action="finish">


and that creats the file c:\test.pdf which contains:

%PDF-1.0
1 0 obj
<</Producer (The Producer) /CreationDate (D:20040921155326) >>
endobj
2 0 obj
<</Type /Font
/Name /F1
/Subtype /Type1
/BaseFont /Arial
/Encoding /PDFDocEncoding
>>
endobj
3 0 obj
<</Type /Font
/Name /F2
/Subtype /Type1
/BaseFont /Arial,Bold
/Encoding /PDFDocEncoding
>>
endobj
4 0 obj
<</Type /Font
/Name /F3
/Subtype /Type1
/BaseFont /Arial,Italic
/Encoding /PDFDocEncoding
>>
endobj
5 0 obj
<</Type /Outlines
/Count 0
>>
endobj
6 0 obj
<<
/ProcSet [/PDF /Text]
/Font
<<
/F1 2 0 R
/F2 3 0 R
/F3 4 0 R
>>
>>
endobj
7 0 obj
<</Length 8 0 R >>
stream
BT 0 0 0 RG 0 0 0 rg 1 w /F1 10 Tf 0 Tc 100 Tz 0 Tr 25 758 Td (Arial text) Tj ET
BT 0 0 0 RG 0 0 0 rg 1 w /F2 10 Tf 0 Tc 100 Tz 0 Tr 25 745 Td (Arial Bold text) Tj ET
BT 0 0 0 RG 0 0 0 rg 1 w /F3 10 Tf 0 Tc 100 Tz 0 Tr 25 732 Td (Arial Italic text) Tj ET
endstream
endobj
8 0 obj
0000000258
endobj
9 0 obj
<</Type /Page
/Parent 10 0 R
/Resources 6 0 R
/Contents [7 0 R]
>>
endobj
10 0 obj
<</Type /Pages
/Count 1
/Kids [ 9 0 R ]
>>
endobj
11 0 obj
<</Type /Catalog
/Pages 10 0 R
/Outlines 5 0 R
>>
endobj
xref
0 12
0000000000 65535 f
0000000010 00000 n
0000000091 00000 n
0000000200 00000 n
0000000314 00000 n
0000000430 00000 n
0000000480 00000 n
0000000576 00000 n
0000000890 00000 n
0000000919 00000 n
0000001008 00000 n
0000001073 00000 n
trailer
<<
/Size 12
/Root 11 0 R
/Info 1 0 R
>>
startxref
0000001145
%%EOF


And if you copy and paste that into a text file with a .pdf extension it will open right up. It works great if I don't try to use the weird font, at which point I get the error: "The font 'Checkbook' contains a bad /BBox" and the text that should be in MICR font shows up as Arial.
 
Ok. You have a bad font. Fonts are complicated structures, and your particular font doesn't have all of the required interal entries. "BBox" stand for Bounding Box, and is an array of numbers that describe the smallest box that would contain all of the characters in the font.

A PostScript Type 1 font should, on a PC system, be contained in a file with a "pfb" or "pfa" extension. It will be accompanied by a "pfm" file, but that isn't strictly part of the font.

So, you aren't doing anything wrong. Your code works, and the PDF looks great. It's a bad/corrupt font. Speak to whoever supplied the font, or find a different font supplier.



Thomas D. Greer

Providing PostScript & PDF
Training, Development & Consulting
 
Thanks. I am really quite please with the pdf creation ability, but this font thing is a real snag. The file is called advmicr.ttf and came with a check-writing program that no longer runs. The accountant's computer is totally trashed with viruses and spyware to where I don't even risk putting it on the network, and the disk was purchased in 2000 and is scratched all to hell. Since I can't get the software installed, I decided to try to develop a replacement and put it on the intranet. I pulled the font file from the check program's installation directory. I found several other MICR fonts too, but none of them work for me. Even some of the ones already in the windows\fonts directory don't work. There seem to be 3 unique icon types in the fonts directory. Arial, Times, Courier, etc all look the same, all all the ones that look different do not work. But then there are some that DO look the same as Arial and the gang, but they don't work, so I dunno.. a real head-scratcher. I suppose there is more to this than I originally thought.

Regarding replacing the font, why is the MICR font so hard to come by? People want hundreds of dollars for a single floppy disk with of software???
 
Font files with a .ttf extention are TrueType fonts. TrueType fonts are not PostScript Type 1 fonts. That is apparently what your utility needs. Note the "/Subtype /Type 1" key-value pairs in the PDF: PostScript Fonts good; TrueType fonts bad.

Any good font will cost you money. It takes money to make a good font, and that's what makes the world go 'round.

Just go to or somewhere similiar, and pay the $100.00 bucks. You are presumbably charging for your work, too... so that cost will quickly be passed on to your customers, who can complain, "why is good commercial check printing so hard to come by? People want hundreds of dollars for paper with ink on it???"

Good luck.




Thomas D. Greer

Providing PostScript & PDF
Training, Development & Consulting
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top