question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

The printed font has become the normal font size

See original GitHub issue

System:(windows7 ultimate sp1 x64)

browser:(Microsoft Edge 是最新版本。 版本 87.0.664.30 (官方内部版本) beta (64 位))

Print.js version:1.5

html:

<form method="post" action="#" onclick="return false;" runat="server" id="printJSform" name="printJSform">
<span class="h3">XXXXXXXXXX</span>
<h3>XXXXXXXXXX</h3>
</from>

script:

printJS({ printable: "printJSform", type: "html", css: ['../bootstrap/css/bootstrap.min.css?v1'], targetStyles: ["*"] });

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:5 (1 by maintainers)

github_iconTop GitHub Comments

1reaction
crabblycommented, Nov 20, 2020

Hey guys, the library has properties for font family and size, and those properties have default values. They are already deprecated and will be removed in the next version of the library. I hope we can release that soon. In the meantime, please manipulate these values. https://github.com/crabbly/Print.js/blob/master/src/js/init.js#L46

Also, for better print results, instead of using targetStyles, I would recommend using the style and css properties instead. You can pass your stylesheets into the css property, or simple styling with style.

To manipulate the print results even more, I recommend also exploring print media queries. This will give you a better control over the print results without affecting your interface layout. Hope this helps. Feel free to reopen this issue if necessary.

0reactions
liamngthcommented, Jan 11, 2021

@crabbly I am facing an issue when setting font-size. Can you help to check if there is any issue with the code? I am using vue framework template:

<div id="hidden_template" >
   <div class="header-t1">This is a header</div>
 </div>
methods: {  
    print() {  
      printJS({  
        printable: this.$refs.pdf.$el.id,  
        type: 'html',  
        style: '#hidden_template {display: block!important}',  
        css: 'a css file inserted here',  
        targetStyles: ['*'],  
      });  
    },  
}

style.css here:

... some css code here
@media print {  
.header-t1 {  
  font-size: 20pt;  
}  
...  

in print preview, the font size isn’t changed.

Read more comments on GitHub >

github_iconTop Results From Across the Web

How do I adjust the font size on my printer? - CDP Help Center
Sometimes, your font may be too large or small when printing. This article discusses how to adjust the font size. · 1. Locate...
Read more >
My printer is printing text too small and I've changed text size
All I have been trying to do is print out mapquest driving instructions-I select the size font and the print comes out sooo...
Read more >
How to: Restore the default displayed font size on your computer
To set your computer's displayed font size to default: Browse to: Start>Control Panel>Appearance and Personalization>Display. Click Smaller - 100% (default).
Read more >
Font Size changes when switching to a different printer
It may happen that the font size changes unexpectedly for some text in a label design when using a different printer than the...
Read more >
How to Make Your Printer Print Bigger Fonts
Increase the font size when printing a web page. Click "File" and select "Print Preview." Change the "Scale" percentage to make it larger....
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found