Open luizluan opened 8 years ago
You are running the code in Node.js? Are you using a browser? If so, you need to start up a web server to serve your project up. Run npm install -g http-server, then from the terminal go to your project directory and run http-server. You should then open a browser and go to localhost:8080. That should fix your problem.
I put on web server another error Uncaught (in promise) TypeError: document.getNamedFlow is not a function(…)
Problem Resolve, but I clicked on print nothing happens.
Can you provide more info? What are you doing exactly? Are you doing the example? Perhaps post some code
Thanks for answering , I 'm doing a website ( asp.net , mvc , angular js ) where I have to print the header and footer on every page , I was using jspdf but the function that copies the html is with bugs do not want print more than one page with content only the old version of the plugin does this but it does not support styles .
So I decided to throw the content to a separate page and print it, the problem that only Firefox prints the header and footer on every page chrome prints only in the first .
So I use your solution, I configured references , and used initiated and sent to print with the id of the div that was content nothing happened. No error in the angular , nothing. I believe it is a conflict with a script that I am using .
I have no idea if your solution would be appropriate, in my application the header and footer is taken from the database they are in html.
How are you printing? Are you clicking print or ctrl+p? If so, you must call PrintHAF.print()
I'm not exactly sure of your setup, but if you could post a small reproducible example, then maybe we can find the issue. Perhaps try it out on a simpler example than your full page that you are trying to print. Make a plain html page and put some example content in and see if you can get it to work
I tested on a clean new project and it worked. : | ... I'll test on my main project again if it works thank you very much . He served perfectly the way I needed .
Do not print inside a modal :| only in html page.. You could create a parameter to add html code.
` PrintHAF.init({
size: 'legal',
marginTop: 48,
marginBottom: 48,
marginLeft: 84,
marginRight: 84,
createHeaderTemplate: function(pageNumber) {
var header = document.createElement('div');
header.innerHTML = '<h2>Header</h2>' + pageNumber;
return header;
},
createFooterTemplate: function(pageNumber) {
var footer = document.createElement('div');
footer.innerHTML = '<h2>footer</h2>' + pageNumber;
return footer;
}
createBodyTemplate: function() {
var body = document.createElement('div');
body.innerHTML = '<div>Hello</div>';
return body;
}
});
PrintHAF.print();`
Thank you any way :)
I'll have to look into this maybe, I'm wondering why it won't print from a modal, I would think it should work as long as the domID
is set properly
I face same issue. getting error print-headers-and-footers.js:194 Uncaught (in promise) TypeError: document.getNamedFlow is not a function(…) at document.getNamedFlow('haf-content')
css-regions-polyfill.js:2696 XMLHttpRequest cannot load file:///C:/Users/luiz/Desktop/print-headers-and-footers-master/src/print-headers-and-footers.css. Cross origin requests are only supported for protocol schemes: http, data, chrome, chrome-extension, https, chrome-extension-resource.a.exports.g.loadStyleSheetTag @ css-regions-polyfill.js:2696