Skip to content
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

Can we add US Letter to the PrintDialog page sizes? #757

Closed
eldang opened this issue Apr 6, 2022 · 5 comments
Closed

Can we add US Letter to the PrintDialog page sizes? #757

eldang opened this issue Apr 6, 2022 · 5 comments

Comments

@eldang
Copy link

eldang commented Apr 6, 2022

This would be convenient for users in the US & Canada, and I think it's an easy change but I don't have all the tooling installed to do it properly myself. I think it would just involve adding one more item to the list here:

ol_control_PrintDialog.prototype.paperSize = {
'': null,
'A0': [841,1189],
'A1': [594,841],
'A2': [420,594],
'A3': [297,420],
'A4': [210,297],
'A5': [148,210],
'B4': [257,364],
'B5': [182,257]
};
with the value 'US Letter': [215.9,279.4] (and if the size needs to be in integers I think it would be safer to round down to avoid rescaling).

@eldang
Copy link
Author

eldang commented Apr 6, 2022

In case this is helpful to anyone else, I've been able to add a paper size on the client side with the following hack:

	printControl.paperSize['US LETTER'] = [200,215]; // this is actually somewhat smaller than US Letter, but seems to be necessary to get the scale bar & N arrow to print.  This may be machine-dependent; I haven't done that testing yet.
	printControl.setSize('US Letter'); // makes it the default option in the dialog
	map.addControl(printControl);
	$('li.ol-size select').append('<option value="US LETTER">US Letter - 8.5x11 in</option>'); // makes the option available in the dropdown

This is good enough for my purposes!

If anyone does pick up adding the size to the basic package, I think that this line:

size = size.toLocaleUpperCase();

might also need to be changed, because it seems to bake in the assumption that size names have no lowercase characters, which works well for ISO 216 sizes but would mean that US Letter would have to be spelled out as "US LETTER".

Viglino added a commit that referenced this issue Apr 7, 2022
@Viglino
Copy link
Owner

Viglino commented Apr 7, 2022

I've added the 'US Letter' size to the PrintControl.
Line 827 has been changed to enable case insensitivity: ie you can use printControl.setSize('US Letter'); , printControl.setSize('us letter'); or printControl.setSize('US LETTER'); as well.

@Viglino
Copy link
Owner

Viglino commented Apr 7, 2022

NB: you can add your own size

// Add new size
ol.control.PrintDialog.prototype.paperSize['My size'] = [100,100];
// New control
var printControl = new ol.control.PrintDialog();

@eldang
Copy link
Author

eldang commented Apr 7, 2022

Thank you! And this is a much tidier way to add a custom size than the sample code I posted.

@eldang
Copy link
Author

eldang commented May 11, 2022

Hooray! Thank you for including this in https://github.com/Viglino/ol-ext/releases/tag/v3.2.24

It took me a couple of weeks to get around to testing the update, but it's all working nicely and I've removed my custom size code from my project. Closing this issue as it's fully resolved.

@eldang eldang closed this as completed May 11, 2022
Siedlerchr added a commit to Siedlerchr/ol-ext that referenced this issue Aug 20, 2022
* origin/master:
  [BUG] WMS dialog position
  Update index.html
  [UPD] add edugeo
  [BUILD]
  Don't call forEach on selectcluserfeatures if that doesn't exist
  [VER]
  [UPD] + [LINT]
  [ADD] bdtopo vtile
  [BUILD]
  [ADD] Paper SVG filter
  Update README.md
  [UPD] optional opacity
  [BUILD]
  [ADD] US letter Viglino#757
  [BUG] displacement on new version
  [BUILD]
  [UPD] fold
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants