Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings
Discussion options

Hi,

I have text values that are set by an external software (it does find&replace for placeholders) and the values have spaces at the right (to fill the maximum field length I suppose).

I am new in postscript and trying to find a working example of trimming right spaces before calling the /code128 barcode generator. No success so far.

Is there an option in postcriptbarcode generators to do the trim? Or any well known postscript template that makes the same?

Thanks!

You must be logged in to vote

Just ask ChatGPT:

Hi,

I have text values that are set by an external software (it does find&replace for placeholders) and the values have spaces at the right (to fill the maximum field length I suppose).

I am new in postscript and trying to find a working example of trimming right spaces before calling the /code128 barcode generator. No success so far.

Is there an option in postcriptbarcode generators to do the trim? Or any well known postscript template that makes the same?

Thanks!

ChatGPT output:

In PostScript, there isn't a built-in right-trim function, but you can create one fairly easily. The postscriptbarcode library doesn't have a built-in trim option, so you'll need to handle th…

Replies: 1 comment · 1 reply

Comment options

Just ask ChatGPT:

Hi,

I have text values that are set by an external software (it does find&replace for placeholders) and the values have spaces at the right (to fill the maximum field length I suppose).

I am new in postscript and trying to find a working example of trimming right spaces before calling the /code128 barcode generator. No success so far.

Is there an option in postcriptbarcode generators to do the trim? Or any well known postscript template that makes the same?

Thanks!

ChatGPT output:

In PostScript, there isn't a built-in right-trim function, but you can create one fairly easily. The postscriptbarcode library doesn't have a built-in trim option, so you'll need to handle this before passing the data to the barcode generator.

Here's PostScript code that uses a function to trim right spaces:

%PS

% ... BWIPP resources ...

/rtrim {
    dup length 1 sub
    { dup 2 index exch get 32 ne { 1 add exit } if 1 sub dup 0 lt { exit } if } loop
    0 exch getinterval
} bind def

0 0 moveto
(BARCODE123   ) rtrim
()
/code39 /uk.co.terryburton.bwipp findresource exec

showpage

[ The usual waffle ensues... ]
...

You must be logged in to vote
1 reply
@APP-OYTEC
Comment options

That example works! Before I created this post I tried several prompts with ChatGPT indeed. All the examples were crashing the PS viewer (so I opted to see if there's some trim option in the barcode generators).
In fact if I prompt now the text of the post, the Chatgpt output to me is different that the one you received, and it makes the PS viewer crash.
Thanks a lot for your answer.

Answer selected by terryburton
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
2 participants
Morty Proxy This is a proxified and sanitized view of the page, visit original site.