I have an invoice that contains over 100 lines of product that I am trying to print. This single invoice should take over 3 pages, but when printed, the content flows off the footer and the next page is the following invoice.
I am using divs instead of tables, and I can't understand why the long invoices will not print on multiple pages.
Any ideas?
Here's my stylesheet:
h1,h2,h3 { margin: 0 0 0.5em 0; padding: 0;}
body { font-family: sans-serif; font-size: 0.8em; }
label, legend { font-weight: bold; }
pre { font-family: sans-serif; }
shipping_address {
width: 45%;
}
billing_address {
width: 45%;
}
order_info {
padding: 0 10px;
}
shipping_logo {
width: 115px;
}
content {
margin: 0px auto 0px auto;
width: 100%;
padding-bottom:15px;
}
div.container {
display: table;
width: 100%;
}
div.header {
display: table-row;
text-align: center;
}
div.row {
display: table-row;
}
.even {
background: #CCCCCC none repeat scroll 0 0;
}
div.cell {
display: table-cell;
padding: 0 10px;
}
You might want to specify specific stylesheets for printing. For example,
#media all
{
.page-break { display:none; }
}
#media print
{
.page-break { display:block; page-break-before:always; }
}
You can then apply the page-break class where you want to page to break. This article has a few neat tricks to format a page for printing.
We're going to need much more information than what you have suggested to really tackle this problem.
However, a pretty blind stab at something that would cause a similar behavior is if you had something set such that the height is 100%, whether it's a table, a div, or something. This is sometimes done to try and keep a footer at the bottom of the browser window and if you do that, this can cause this behavior when printing.
Related
I have this div named "container" that is supposed to be displayed when the max-width gets to 47em. This can be triggered through zooming in. It's initial display is none but in the media query i change it to display block. The problem is that even after zooming in enough to get the max-width to become 47em, it's still not displaying anything. Why is this and how can i go about fixing the problem?
Code: http://codepen.io/anon/pen/RWBJXv
html,
body {
height: 100%;
margin: 0px;
font-family: verdana, arial, helvetica, sans-serif;
}
#media (max-width: 47em) {
#container {
display: block;
}
}
div#container {
display:none;
}
div#nav {
position: relative;
width: 100%;
background: white;
box-shadow: 1px 1px 15px #888888;
}
div#logo {
border-right-style: solid;
border-width: 1px;
border-color: rgba(0, 0, 0, 0.15);
font-family: 'Myriad Pro Regular';
font-weight: normal;
color: #1E3264;
font-size: 2em;
}
<body>
<div id="container">
<div id="nav">
<div id="logo">TEST</div>
</div>
</div>
Your code has several problems:
First of all, div#container is a css selector with a higher specificity than #container, which you are using inside your media query, so the general rule takes precedence.
Second, make sure you always put your media-queried rules after your general rules.
http://codepen.io/anon/pen/zvLLPa
Seems to be an order & specificity issue.
Try changing this
#media (max-width: 47em) {
#container {
display: block;
}
}
div#container {
display:none;
}
to this:
#container {
display:none;
}
#media (max-width: 47em) {
#container {
display: block;
}
}
Codepen Demo
If you swap around your media query with your general css, and add an important tag this sorts out your issue example:
#container {
display:none;
}
#media (max-width: 47em) {
#container {
display: block;
}
}
Check out this codepen: http://codepen.io/sshhdaniella/pen/EVppwR
We have been working on a new calendar interface which includes a printable "classic" calendar view. There was much working going into the #media print stylesheet, and while everything is looking great in Safari, the event times are overlapping the event name in Chrome. Cannot figure out why.
#media print {
body{
-webkit-print-color-adjust:exact;
}
img,
.calendar-nav button,
.calendar-date-picker,
.event .btn-group {
display: none;
}
.calendar-nav {
text-align: center;
padding-top:20px;
}
.calendar-nav .date-title {
font-size: 50px;
font-weight: normal;
}
a:link:after,
a:visited:after {
content: "";
}
#calendarTable div.event {
padding: 0;
margin-left:0;
text-indent: 0;
}
.events.active {
width: 100%
}
}
EDIT: I fixed the overlap issue by adding .event-location {float: none; margin-top: 0px;} into the print media query.
Also, in Firefox there is a huge margin to the left of the content:
It is pretty hard debugging these print style sheet to figure out what is going on. Even Chrome developer tools will show the correct print preview, but doing a real print shows it incorrect.
Any ideas on what to do to fix these issues? Is using an #media print inside of our main style sheet an issue?
http://www.puc.edu/calendar?state=full
Looks like adding a few styles to overwrite the Bootstrap defaults was all I needed:
.event-location {
float: none !important;
margin-top: 0px !important;
}
.event-time {
float: none !important;
}
body .container {
width:100% !important;
margin:0 !important;
}
I've generated some labels using HTML and CSS which I intend to print onto to pre-printed label paper. The labels should have a fixed width of 45mm * 35mm, which I've set in CSS, but when printed they come out at different sizes.
I've also tried converting the HTML to a PDF using HTML to PDF, but this hasn't helped. What am I doing wrong?
My Html:
<html>
<head>
<style>
#media screen , print {
body {
margin: 0;
border: 0.264583333mm solid green;
}
.table_style {
width: 100%;
}
.table_style td {
text-align: left;
padding: 0 0 3.175mm 5.291666667mm;
}
.space {
height: 2.645833333mm;
}
.div_print {
width: 63mm;
height: 37.735416667mm;
margin-top: 3.735416667mm;
border-width: 1px;
border-style: solid;
border-color: red;
}
.part_dec_print {
font: 3mm arial;
text-align: left;
padding-left: 1.5875mm;
height: 8.5mm;
}
.p_tag {
height: 100%;
vertical-align: middle;
padding-top: 1.5875mm;
}
.qty_span {
padding-top: 1.5875mm;
}
.part_print {
font: 6.5mm arial;
height: 6.5mm;
text-align: left;
padding-left: 1.5875mm;
}
.bar_print {
padding-left: 3.96875mm
}
.qty_print {
font: 6.5mm arial;
text-align: center;
height: 6.5mm;
}
.date_print {
font: 2mm arial;
text-align: right;
padding-right: 4.645833333mm;
margin-top: 4.995833333mm;
height: 2mm;
}
}
</style>
</head>
<body cz-shortcut-listen="true">
<div class="div_print">
<div class="part_dec_print">
<div class="p_tag">REAR FABRIC SCVR</div>
</div>
<div class="part_print">PZQ22-12100</div>
<div class="bar_print">
<img alt="testing" src="http://anybarcode_image_here201x29.png">
</div>
<div class="qty_print">1</div>
<div class="date_print">23A4</div>
</div>
If the problem is differences between browsers (as I think it is now from your comments), then the issue is that your widths include fractional measurements, e.g. 4.645833333mm.
Each browser round decimals slightly differently as discussed here - there's no guaranteed away around it other than to not include fractional widths.
What about creating a PDF in PHP (with something like dompdf) and then styling the PDF so it has the correct widths and heights for your label cells. The PDF and styled formatting should always be the same size no matter the browser.
From device preferences, you have to set page size according to your label and it will work. I just did it for TSC TA210 device!
page size css never work in this case! it will print lots of empty label for you.
when i give the page to print...
the text on the right hand side of the page gets cut off....
i gave text align left in print css but still not working...
providing my code below....
http://jsfiddle.net/jjnKP/
#media print {
body {
margin:0;
padding:0;
line-height: 1.4em;
word-spacing:1px;
letter-spacing:0.2px;
font: 17px Arial, Helvetica,"Lucida Grande", serif;
color: #000;
}
.mainDiv, .navbar,
.copyright {
display: none;
}
#templateTwoPadding {
padding: 0 0;
}
#tableHeadingLastDF {
text-align: left;
width: 134px;
border:1px solid white;
}
#makeLeftDF {
text-align: left;
}
.jumbotron .lead {
font-size: 12px;
}
}
I had the same thing happen to me on a project...everything kept getting cut off on the right side. :(
I ended up "fixing" it by simply setting a width and being happy with it. I don't think this post is the exact one I got my information from but looks good just the same.
I had same problem with SVG graphs, below css is worked for me.
#media print {
body {transform: scale(.6);}
}
I'm trying to match the dimensions, margins, text sizes, line height, etc of a web page to those of a word processor (in this case, OpenOffice) so that when you go to print the web page or make a PDF of it, it will look exactly like the document.
So far I've set the height and width to 11in/8.5in, every side margin to 0.79in, and the font is the same size as the document. (That is, if documents use pt.)
So how come it's only taking up half the page??
This site is made to be printed/PDF'd, so it doesn't have to use flexible values.
Thanks!
Here is a link to a sample document, I'll have some code soon
http://i.stack.imgur.com/l2Dl1.png
/*The rules go here*/
#page-container {
background: blue;
margin: 0.79in 0.79in 0.79in 0.79;
width: 7.5in;
height: 11in;
}
.name {
font-size:22pt;
font-weight:bold;
}
.sections {
margin: 10px 0 0 0;
font-weight:bold;
text-decoration:underline;
clear:right;
}
.jobtitles {
font-weight:bold;
}
.leftside {
float:left;
}
.rightside {
float:right;
width:50%;
}
.years {
float: right;
font-weight:bold;
padding-right: 1%;
}
.desc {
width: 760px;
}
ul {
list-style-type: none;
padding:0;
margin:0;
}
#footer {
text-align: center;
font-weight: bold;
}
The only reason its blue is so I can see the container.