Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

129
Views
Javascript print with styles

I'd like to ask if there's an option to print(send to printer) in js some part of website with css styles ?

I've created code:

  let print_area = window.open();
print_area.document.write(print_div.innerHTML);
  print_area.document.close();
  print_area.focus();
  print_area.print();
  print_area.close();

it prints exactly what I want, but I have no css styles there(but I've created media print)

my project on jsfiddle: https://jsfiddle.net/z58pr1fL/

about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

I advice to create a css file for printer and insert this:

(…)
<head>
   (…)
   <link rel="stylesheet" media="print" href="print.css" />
   (…)
</head>
(…)

Inside this print.css subtract lots of colors as you can. Just for save inks in your users :)

Keep only border of your elements and texts with the shades of grey.

You could create a button for send to user's printer like this:

  <button type="button" onClick="window.print()">

or the best way is

  <button type="button" onClick="./path/of/javascript/files/printer.js">

printer.js

'use strict'
window.print();

If you not convince, try window.print() in your console.

about 4 years ago · Juan Pablo Isaza Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!