/    Sign up×
Community /Pin to ProfileBookmark

Random problems printing HTML pages

I’ve had some code developed that creates invoices in HTML pages by reading a CSV file

I can’t explain why, but the HTML content just doesn’t print sometimes
The worst thing is that it happens 50% of the time<br>So, sometimes OK, other times a big pain

When the problem comes, I can print fine in any other web pages fine – the problem seems to be JUST the HTML pages that have been generated

IMPORTANT: I can only use Chrome
One of the text fields needs to be turned sideways – the developer said the code only worked on Chrome

The only thing I guessed that could possible affect the printing was the media code in the CSS

I’ve given it below… just in case it’s relevant:

[CODE]
@media print {
.invoice2
{
border: initial;
border-radius: initial;

width: 21cm;
height: 29.7cm;
/*min-height: initial;*/
box-shadow: initial;
background: initial;
margin: 0;
overflow: hidden;
}
.not_last_page
{
page-break-after: always;
}
.not_for_print
{
visibility: hidden;
}

}
[/CODE]

Not sure if anyone can help. The problem seems to be a weird one
I thought I’d ask anyway

Thanks in advance

OM

to post a comment
CSS

2 Comments(s)

Copy linkTweet thisAlerts:
@jedaisoulOct 03.2014 — All I can suggest is:

  • 1. You need to be more methodical in distinguishing the circumstances when the problem occurs, and when it does not. It is (almost certainly) NOT random, that's just an excuse.


  • 2. There may be more than one cause. So try commenting-out the print-specific CSS, and see what it does. Then try selectively re-enabling sections of it until, hopefully, you isolate code that is contributing to the problem.
  • Copy linkTweet thisAlerts:
    @deathshadowOct 03.2014 — 1) "initial" is too new and buggy, even in Chrome, to be relied upon -- I'm not even sure it's supported for print media yet.

    2) MOST of the values having "initial" set on them shouldn't need it unless you've done something stupid like sent your stylesheets without media targets in the first place... see why I don't advocate omitting a "MEDIA" attribute or using the "ALL" value on it.

    3) as confirmed by trying to use a media query to modify whatever the hell is going on there for print. Print should be a whole separate stylesheet using the MEDIA attribute on LINK, not wasting time trying to change it's style.

    4) trying to set physical print dimensions is most always broken cross browser.

    5) Assuming your browsers even obey the PRINT media and don't override it with their own crap. (though that's much more of a FF and IE thing).

    6) you don't need chrome just to rotate an element, any proper CSS3 capable browser should be able to do it.

    Really with how stuff is being overridden for print, it looks like the entire page building methodology is flawed/broken -- but that's hard to say for sure without seeing the CSS that's being overridden with "initial" and the markup said CSS is being applied to.

    The latter being the big issue since CSS without the HTML is like trying to diagnose what's wrong with the engine in a car without opening the hood or a proper jack.
    ×

    Success!

    Help @OM2 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.8,
    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,
    )...