/    Sign up×
Community /Pin to ProfileBookmark

Printing Forms

I’m seeking some help here. I’m not a coder, and taught myself CSS and HTML from a variety of sources on the Internet, so please know up front that I’m fully aware of my n00b status.

Having said that, I’m working on a project with a friend of mine who is a great programmer, and we’re doing a ticketing site for a small theater. The specific problem I’m having is when we try to have the tickets for a show print from the browser. The theater is using pre-perforated pages that contain 8 tickets, each with a stub.

His outstanding work produces individual ticket information including the patrons name, seat location, etc. and feeds it into HTML that I designed. The HTML output looks great!, but when we go to print, there is a lot of overlap, I’ve had issues with page breaks and printing and print-preview crashes Firefox. I don’t need to worry about browser compatibility for this one, as I’ve got the theater all on Firefox 1.5+.

The HTML for each generated ticket is:

[CODE]<div id=”whole”>
<div id=”ticket”>
Show Date &amp; Time<br />
<span id=”show”>Show Name</span><br />
Seat no.<br />
<span id=”customer”>Customer Name</span><br />
<span class=”small”>
Price – Order No.<br />
www.illusiontheater.org<br />
528 Hennepin, 8th Floor<br />
Minneapolis, MN 55403<br />
612-339-4944</span>
</div>

<div id=”stub”>
Show Date<br />
Time<br />
Show Name<br />
Seat No.<br />
Customer Name<br />
Price<br />
Order No.<br />
Payment Type<br />
</div>
</div>[/CODE]

The CSS for the print page is:

[CODE]@page {
size: landscape;
}

body {
margin: 0;
padding: 0;
font-size: 10pt;
font-family: Verdana, Arial, SunSans-Regular, Sans-Serif;
color: #000000;
background: none;
text-align: center;
vertical-align: middle;
}

#whole {
display: inline;
width: 50%;
border: solid 1pt #fff;
}

#ticket {
float: left;
width: 2.8in;
height: 1.720in;
margin: 0.2in 0.15in 0.1in 0.35in;
}

#stub {
float: left;
width: 1.5in;
height: 1.720in;
margin: 0.2in 0.25in 0.1in 0.15in;
font-size: 7pt;
page-break-before: avoid;
}

#show {
font-size: 11pt;
font-family: Broadway, Arial, SunSans-Regular, Sans-Serif;
font-weight: bold;
}

#customer {
font-size: 12pt;
font-family: Broadway, Arial, SunSans-Regular, Sans-Serif;
font-weight: bold;
}

.small {
font-size: 9pt;
}[/CODE]

I had what I thought was a very simple, elegant solution, but I just can’t make it print properly! Any suggestions? (Besides reading another ALA article or using a server-side PDF generator.)

to post a comment
CSS

5 Comments(s)

Copy linkTweet thisAlerts:
@David_HarrisonApr 07.2006 — Well, you can't specify widths for inline elements, so you have to remove that display:inline on #whole. To get them to stack up next to each other you'd need to float them all to the left, that'll work quite nicely, though you may have to take the width down to 49% because if you specify 50% there could be rounding errors which result in the blocks being ever so slightly larger than 50% and therefore not lining up next to each other.

Also, if you have lots and lots of these boxes, you should be using classes, not ID's, because ID's can only be used once.

One final point, not that it really matters for this application because this is only designed for printing out tickets, but have you thought about using more semantic markup? For example, using an unordered list, replacing each #whole with an <li>. If nothing else at least it's good practice for in the future.
Copy linkTweet thisAlerts:
@DiogenesauthorApr 07.2006 — Thanks!

I've changed all the ids to classes, and replaced the display: inline; with float: left; in .whole.

I played with the measurements a little bit, but your revelation that inline positioned elements can't have widths prompted me to forget about the percentage and just give the .whole ticket a measured width.

It works locally, somewhat. The problem is that the page always breaks before the last ticket. We only get 7 to a page. I'm happy that page-break-before: avoid; works in .stub, but this page break thing is annoying. (I'm not so much worried about dropping one of these cheap tickets off of each page, but I just hate not being able to make something work.)

I'll let you know if my partner's ASP.NET code produces the same results later today.

Thanks again for the help. It's the little things that the less experienced might never know without resources like this, and kind people like you.
Copy linkTweet thisAlerts:
@David_HarrisonApr 07.2006 — Thank-you for your kind words, flattery will get you everywhere.

And yes, I completely know where you're coming from, it's annoying not being able to stamp out a problem, even though it is only a small one.

Incidentally, the browser has default margins for the page and it could be that those are interfering.

[upl-file uuid=e32bfc56-e387-4d37-9275-e734fa6a6fe2 size=23kB]default margins.png[/upl-file]
Copy linkTweet thisAlerts:
@DiogenesauthorApr 07.2006 — We've got the new CSS/HTML uploaded and it works just as tested locally. (whew!)

And yes, the browser margins need to be carefully set or else the measurements on the page won't work. I had caught that one already ?

The big pain in the ass is having no idea what the native margins are for the printer, the printer drivers, etc. Still too many layers to go through for truly elegant print-from-web solutions. But we're working on it.
Copy linkTweet thisAlerts:
@David_HarrisonApr 07.2006 — Well all it takes is one test print on their printer to find out the margins, then a quick alteration in the CSS and it'll all be fine.

Good luck with it all.
×

Success!

Help @Diogenes spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 5.7,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @AriseFacilitySolutions09,
tipped: article
amount: 1000 SATS,

tipper: @Yussuf4331,
tipped: article
amount: 1000 SATS,

tipper: @darkwebsites540,
tipped: article
amount: 10 SATS,
)...