-
Notifications
You must be signed in to change notification settings - Fork 27
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Modify Parts of the Header/Footer Info #163
Comments
This is one of those things that looks straightforward but isn't. Headers and footers are outside of the scope of HTML and CSS standards, so they are not consistent between browsers. I was going to tell you that the Chromium family of browsers provides direct control of header and footer content with symbols for various pieces of metadata including the ones that interest you, but I just checked, and it appears to have been removed. A general solution would require me to switch off browser generated headers and footers, set margins to zero and take over the entire page. As you can imagine this represents a huge leap in complexity because I have to take over pagination as well. This is actually not impossible and there is a library with which I have been experimenting. The biggest problem is finding a reliable cross browser programmatic way to turn off browser generated headers and footers -- so far this appears to be impossible. |
I see, I was suspecting that they might be tied to the browser since printing from other applications was changing the header and footer formatting. I was going to open another issue asking whether there could be a command to just save the current code selection or file directly to a PDF (foregoing the need to bring up a browser and select which printer (in this case, a virtual PDF printer) you would want to use). Then after clicking/invoking said command, it simply brings up a file dialog of what to name the saved PDF and where to place it. But it sounds like the plugin currently relies on the browser to generate the PDF (along with headers and footers in that PDF as you stated), so would probably be very complicated. The best solution I know of so far is using Notepad++, in which you can easily customize the header and footer contents (see screenshot). I understand that this would probably be too much to ask for a plugin, but this would be my ideal as then I could eliminate using Notepad++ entirely. |
Yes, exactly. PDF generation is a side effect of exploiting the ubiquity of print capable browsers. Someone told me that Electron (the basis of VS Code) has printing capabilities, so I investigated. It's true, and they do it by controlling Chrome. If I were to abandon support for browsers other than Chromium and its ilk, CRDP (Chrome Remote Debugging Protocol) would allow me to stick my programmatic hand up Chrome's digital butt and do anything I need to, including create a new user profile so I can set things up the way I need without affecting user preferences. All of my research suggests that this is what I'll have to do if I want to take Print any further. This runs counter to Print's philosophy of platform independence, but the payoff is large. |
@ryanwwest See #265 for details. I'm reopening this. It won't be quick but I know how to do it. |
Cool thanks! Would love to hear what you figured out. |
It turns out that the current crop of browsers honour this @media print { @page { margin: 0; } } That suppresses the browser generated margins, headers and footers. I can then use It's a heavyweight solution but it solves so many otherwise intractable problems it's not funny. For example, it gives me a way to make multi-document print-jobs start each file on the right-hand page for people with duplexing printers. |
I would like to be able to modify some, but not all, of the header/footer info. Specifically, I want to hide the date and bottom-left 'localhost' text, and include the full filepath (not just the filename) at the top. Is this possible?
The text was updated successfully, but these errors were encountered: