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

Barcode with newlines creates unreadable Stamp and Eps images #11

Closed
geusebi opened this issue Apr 26, 2020 · 4 comments
Closed

Barcode with newlines creates unreadable Stamp and Eps images #11

geusebi opened this issue Apr 26, 2020 · 4 comments

Comments

@geusebi
Copy link

geusebi commented Apr 26, 2020

The comment %%BarcodeData cause Eps and Stamp images to be unreadable because the data is leaking out of comments boundaries

iec16022 -s 104x104 -f Eps -i <(printf "line1\nline2\nline3") | sed -n 2,7p
%%Creator: IEC16022 barcode/stamp generator
%%BarcodeData: line 1
line 2
line 3
%%BarcodeSize: 104x104
%%BarcodeFormat: ECC200

The barcode should be properly escaped or split over multiple lines, e.g.:

iec16022 -s 104x104 -f Eps -i <(printf "line1\nline2\nline3") | sed -n 2,5p
%%Creator: IEC16022 barcode/stamp generator
%%BarcodeData: line1\nline2\nline3
%%BarcodeSize: 104x104
%%BarcodeFormat: ECC200
@rdoeffinger
Copy link
Owner

Sorry, I had missed this somehow.
It seems a bit overkill to me for just a comment, wouldn't it be reasonable to just replace anything problematic with a space instead for much simpler code?

@geusebi
Copy link
Author

geusebi commented Mar 31, 2021

To me it's reasonable enough as long as the resulting EPS is valid and readable.
I wrote the code this way just to stick to the language reference.
Replacing \n and \f with spaces is a good compromise.

I can update the PR tomorrow if you want me to.

@rdoeffinger
Copy link
Owner

Thanks for the offer, but I pushed my own version of it in commit 712ca1d
I thought it safest to remove all control characters, and to do it in a way that also works for the other output formats like PNG.
I actually meant to credit you in the commit message for finding it and proposing the original solution but forgot in the end, sorry.
Great if you can test it.
Re-open if there's any issue/concern with it.

@geusebi
Copy link
Author

geusebi commented Apr 1, 2021

I'll test it during the weekend but it already looks good to me.
Many thanks for your work and for thinking to credit me, no problem if you forgot. That's still a nice gesture

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants