cleidigh / printing-tools-ng

PrintingTools NG Thunderbird Extension - Printing Utilities
Other
36 stars 17 forks source link

Add Advanced options to set Edge margins for headers and footer #258

Open b30047 opened 5 months ago

b30047 commented 5 months ago

I can't set the distance of header and footer line from top or bottom. They are always near the page margins (I print A4). Strange enough when I print to letter format and afterwards let PDF Expert convert the pages to A4 I get a reasonable whiteroom form the margins. But this is a cumbersome process.

In the meantime I found a tip from nikitalita that seems to work when printing to PDF:

`Go to about:config, add the following "number" settings:

print.printer_Mozilla_Save_to_PDF.print_edge_bottom
print.printer_Mozilla_Save_to_PDF.print_edge_top
print.printer_Mozilla_Save_to_PDF.print_edge_left
print.printer_Mozilla_Save_to_PDF.print_edge_right

And set them all to "10" (which is about 1/10th of an inch)`

Currently I test "30"

cleidigh commented 5 months ago

@b30047 Thanks for posting here where we can discuss. That's very interesting what you found because I already did a check with edgeTop and had no success. From your post I understand you did? If so I have to check my experiment because I was doing it programmatically versus within the prefs, although it would not make sense .

I will try some further experiments. If this works I can probably do a printingtools preference that would apply to all printers, but I don't think I would be able to get these into the ui yet as that's really tight right now.

Anyway let's see what functions. @cleidigh

b30047 commented 5 months ago

Example:

240627 - [cleidigh_printing-tools-ng] Position of header and footer lines (Issue #258).pdf

cleidigh commented 4 months ago

@b30047 @kiki-ja @tidebre67

This is some new functionality that I implemented in response to @b30047 . I took the time to generalize it so we can add more options in the future.

So the OP asked for the ability to set the edge margins to control where the headers and footers show. For now I have implemented this as the first advanced printer option. Right now you set them in debug options, I may move later. So here is how you use it:

The options are set in the Debug options in the Misc tab. The options are space separated as usual. The format is :

P:printer-name::S:option-name=value

The printer name has the spaces escaped with underscores and the built in Save to PDF is Mozilla_Save_to_PDF

Another example Microsoft_Print_to_PDF

The current option-name possibilities are: edges, edgeTop, edgeBottom, edgeLeft, edgeRight

edges is a pseudo option that sets all the edge margins to the same value. The edge margins are in inches.

Examples:

P:Mozilla_Save_to_PDF::S:edges=0.25 P:Microsoft_Print_to_PDF::S:edgeTop=0.1

This all works on any printer assuming they respect these options. Note because of the way these options work, if you set one edge you have to set them all, that's why I added the edges pseudo option.

I also added a decent amount of error handling.

Very interested in people's responses. It's in beta 3, download here:

@cleidigh

kiki-ja commented 4 months ago

PTNG 3.1.0-b3 Thunderbird 128.0 b3 64bit Windows 10 Pro 22H2 64bit

Test Report: The following steps were performed

(1) Debug options:    P:Mozilla_Save_to_PDF::S:edges=0.25    misc tab -1

(2) Print preview:    Options = Print headers and footers to ON    Margins = Default or Custom (inches or mm)

(3) I was able to print at the inch position I set.    Test Message for PrintingTools NG  PrintingTools NG 用のテストメッセージです。       Issue: 1.Print preview requires 'Print headers and footers' to be turned on every time.   print preview - 3

2.Margins must be selected and specified each time as well. (The default cannot be immobilized).   margins       Other: Cannot copy and paste with mouse in debug options. #172

@kiki-ja

tidebre67 commented 4 months ago

Windows 10 Home 22H2 Thunderbird 115.12.2 (64-Bit) PTNG 3.1.0-b3

@cleidigh could not see any issue.

Issues mentioned by kiki-ja: i do not have these.

cleidigh commented 4 months ago

@tidebre67 Thanks! What do you think of the feature, do you ever want to set the headers and footers to be farther away than the defaults?

I'm very confused about @kiki-ja report. None of the logic has changed to show the custom margins and the headers and footers is enabled by the preview if any are non empty, ptng doesn't have to do anything.

@kiki-ja I have added some debug to the preview window settings and will post tonight. @cleidigh

cleidigh commented 4 months ago

@kiki-ja Very odd that anything has changed with the preview settings. I made b4 With preview debug. Add printsettings to debug options Then do print and capture console, but before you copy, click the expand twisties on both the initial and final preview html debug lines to fully expand. If b4 is still not working fall back to b2 before any of this was added. @cleidigh

cleidigh commented 4 months ago

@b30047 Did you get to try the beta? @cleidigh

kiki-ja commented 4 months ago

PTNG 3.1.0-b4 Thunderbird 128.0 b6 64bit Windows 10 Pro 22H2 64bit

@cleidigh I have been able to confirm about the Issue and I stand corrected.

Issue: 1.Print preview requires 'Print headers and footers' to be turned on every time.

I had left headers and footers empty (blank) in the PTNG options. I confirmed that by default, in print preview, they are always on.

2.Margins must be selected and specified each time as well. (The default Cannot be immobilized).

In 'Mozilla_Save_to_PDF' the margins are all '0.5' by default. In print preview, I have confirmed that it will always be 'Custom'. I found that I have to manually switch to 'Default'. I always use 'Custom' so no problem.

@kiki-ja

tidebre67 commented 4 months ago

@tidebre67 Thanks! What do you think of the feature, do you ever want to set the headers and footers to be farther away than the defaults?

I'm very confused about @kiki-ja report. None of the logic has changed to show the custom margins and the headers and footers is enabled by the preview if any are non empty, ptng doesn't have to do anything.

@kiki-ja I have added some debug to the preview window settings and will post tonight. @cleidigh

@cleidigh Windows 10 Home 22H2 Thunderbird 115.12.2 (64-Bit) now PTNG 3.1.0-b4

also here no issues .

once margins set in general not changed again. I like to see &PT ,but due to Windows language it looks 1 von 3 or so. This cannot be changed to 1/3 as far as i know. Therefore i leave header abd footer blank currently.

cleidigh commented 4 months ago

@tidebre67 I wonder if we can get the total pages so we could format our own pages-total or whatever... @cleidigh

cleidigh commented 4 months ago

@kiki-ja That is good. I was confused by it not working. Hopefully we will get some feedback from @b30047 @cleidigh

cleidigh commented 4 months ago

@b30047 Can you please let me know if you have tested the beta. I did a lot of work on this. Thanks @cleidigh

b30047 commented 4 months ago

@cleidigh I'm sorry, I had to spend a few days in hospital. I'll be testing the beta version from tomorrow.

cleidigh commented 4 months ago

@b30047 Sorry, I hope everything is ok! No rush, whenever it's good. @cleidigh

cleidigh commented 4 months ago

@tidebre67 @kiki-ja @b30047 I have added a new Advanced Options pref/field in b5, Still have to do help. Same rules, just move from debug options.

The options are set in the Advanced options in the Misc tab. The options are space separated as usual. The format is :

P:printer-name::S:option-name=value

The printer name has the spaces escaped with underscores and the built in Save to PDF is Mozilla_Save_to_PDF

Another example Microsoft_Print_to_PDF

The current option-name possibilities are: edges, edgeTop, edgeBottom, edgeLeft, edgeRight

edges is a pseudo option that sets all the edge margins to the same value. The edge margins are in inches.

Examples:

P:Mozilla_Save_to_PDF::S:edges=0.25 P:Microsoft_Print_to_PDF::S:edgeTop=0.1

This all works on any printer assuming they respect these options. Note because of the way these options work, if you set one edge you have to set them all, that's why I added the edges pseudo option.

I also added a decent amount of error handling.

@librelegal you may be interested in this new functionality...

@cleidigh

b30047 commented 4 months ago

macOS Ventura Version 13.6.7 Thunderbird 115.12.2 (64-Bit) PTNG 3.1.0-b5

@cleidigh no issues here. Thank you for your excellent work!

cleidigh commented 4 months ago

@b30047 Great, thanks for the original request! @cleidigh

tidebre67 commented 4 months ago

@cleidigh rules in advanced options in b5 work like in debug. great.

cleidigh commented 4 months ago

@tidebre67 Thanks very much. I don't think we can get the total page count unfortunately. It has to be rendered. It's a shame they don't provide it as a separate option. @cleidigh

tidebre67 commented 4 months ago

@cleidigh agree, yes it's a shame, but it is as it is. But there are worse things in the world.

cleidigh commented 4 months ago

@tidebre67 Yes indeed. @cleidigh

kiki-ja commented 4 months ago

PTNG 3.1.0-b5 Thunderbird 128.0 b6 64bit Windows 10 Pro 22H2 64bit

Test Report: Advanced options worked fine. Setting the headers and footers edge margins applied to other printers as well. The following is an example of the settings in 'Mozilla_Save_to_PDF'printer, but the same results were obtained on another 'CubePDF' printer.

[Example: P:Mozilla_Save_to_PDF::S:edges=0.5] Advanced-MozillaPDF-edges050

[Example: Print preview] MozillaPDF-edges050

[Example: CubePDF Printer] Advance-MozillaPDF-CubePDF-edges050

[Example: Print preview] CubePDF-edges050

@kiki-ja

cleidigh commented 4 months ago

@kiki-ja I partially confirmed your observation. There is an issue, but some of my tests today were odd. Regardless of the multiple settings , I found times where the settings for a given printer did not respect the preferences. Have to continue experiments. @cleidigh

cleidigh commented 4 months ago

@kiki-ja @b30047 @tidebre67 Fix for a setting going to other printers in advanced options in b7 @cleidigh