Re: [SLUG] Adding text to a postscript file
Hi all It's hard to do this in postscript. I know a LaTeX way though. You said it was from a PDF. Use the PDF directly. Include it into a latex doc (myfile.tex) using \includepdf then write over the top of it using a picture environment to get an exact placement for your text. When you run pdflatex myfile.tex you will get a file myfile.pdf that will contain the ticket and your text. Below is the latex doc to use. % Run this as pdflatex myfile.tex \documentclass{article} \usepackage{pdfpages} \begin{document} \includepdf[pages={1,2}]{some.pdf} % Now place your text. \begin{picture}(0,0) \setlength{\unitlength}{1mm} \put(1,2){Your text} \put(1,4){More text} \end{picture} \end{document} If you need help with this I can do a run for you as a test. Mike Lake -- SLUG - Sydney Linux User's Group Mailing List - http://slug.org.au/ Subscription info and FAQs: http://slug.org.au/faq/mailinglists.html
Re: [SLUG] Adding text to a postscript file
Michael Lake wrote: It's hard to do this in postscript. I'm actually making good progress :-). I know a LaTeX way though. You said it was from a PDF. Use the PDF directly. Include it into a latex doc (myfile.tex) using \includepdf then write over the top of it using a picture environment to get an exact placement for your text. When you run pdflatex myfile.tex you will get a file myfile.pdf that will contain the ticket and your text. Below is the latex doc to use. I would use this method if I was there to check and valid the output. However, these documents are going to be mangled on embedded boxes all over the world. The latex method you propose seems just a little fragile. I'm actually making good progress on inserting raw postscript commands directly into the postscript. Erik -- - Erik de Castro Lopo - Spammer: Any of you guys looking for a permanent position in Scotland? Kaz Kylheku: No, I'm looking for a thug in Scotland who might be interested in beating up off-topic Usenet spammers, on a pro bono basis. -- SLUG - Sydney Linux User's Group Mailing List - http://slug.org.au/ Subscription info and FAQs: http://slug.org.au/faq/mailinglists.html
[SLUG] Adding text to a postscript file
Hi all, I have a small postscript file which is a template for a ticket. I now need to find a way to add custom text to this file before printing and I need to be able to do this from the command line. Anybody have any suggestions or pointers? Cheers, Erik -- - Erik de Castro Lopo - Gambling(n): A discretionary tax on those asleep during high school maths. -- SLUG - Sydney Linux User's Group Mailing List - http://slug.org.au/ Subscription info and FAQs: http://slug.org.au/faq/mailinglists.html
Re: [SLUG] Adding text to a postscript file
Erik de Castro Lopo wrote: I have a small postscript file which is a template for a ticket. I now need to find a way to add custom text to this file before printing and I need to be able to do this from the command line. Anybody have any suggestions or pointers? Postscript is plain text (ASCII) containing Postscript program code and data. Try 'sed' to edit it in a batch fashion. cheers rickw -- _ Rick Welykochy || Praxis Services Say what you will about the miracle of unquestioning faith, I consider a capacity for it terrifying and absolutely vile. -- Howard W Campbell in Kurt Vonnegut Jr's Mother Night -- SLUG - Sydney Linux User's Group Mailing List - http://slug.org.au/ Subscription info and FAQs: http://slug.org.au/faq/mailinglists.html
Re: [SLUG] Adding text to a postscript file
Erik de Castro Lopo wrote: I have a small postscript file which is a template for a ticket. I now need to find a way to add custom text to this file before printing and I need to be able to do this from the command line. If you are printing via CUPS then you can add a custom filter that modifies the file before it is sent to the printer. I do this for a custom label that cannot be modified when the job is generated. In the printer ppd file add a line like: *cupsFilter:application/vnd.cups-postscript 0 hplabel where hplabel is the name of the filter file. This is the contents of the hplabel filter file: #!/usr/bin/perl while (STDIN) { s/5 5 265 385/5 5 220 385/; s/297 420/225 395/; print STDOUT $_; } This file should be made executable and placed in the cups filer directory. On my debian system that is /usr/lib/cups/filter/ -- Mark Pearson BSc (Computing) Technical Support, Dept Nuclear Medicine Concord Hospital, Hospital Road, Concord, NSW 2139, Australia Phone:+61-2-97676339 or +61-297677450; FAX:+61-2-97677451 -- SLUG - Sydney Linux User's Group Mailing List - http://slug.org.au/ Subscription info and FAQs: http://slug.org.au/faq/mailinglists.html
Re: [SLUG] Adding text to a postscript file
Rick Welykochy wrote: Postscript is plain text (ASCII) containing Postscript program code and data. That was my first thought too. Unfortunately it simply doesn't work as expected. If I replace 'tag1' in the original with 'Erik' I get a blank where the 'tag1' used to be. Here are some more data points: tag11 - tag1 tag111- tag11 tag1 - tag tag123- tag1 I think the problem is that the Postscript is out of adobe acrobat converted from a PDF original. The designer guy who is doing the conversion is already disabled embedded fonts but that only solves some of the problems. Erik -- - Erik de Castro Lopo - It's a shame that so many people think all Windows programmers are idiots, when it's actually just 99% of them. -- Damana Madden -- SLUG - Sydney Linux User's Group Mailing List - http://slug.org.au/ Subscription info and FAQs: http://slug.org.au/faq/mailinglists.html
Re: [SLUG] Adding text to a postscript file
Erik de Castro Lopo wrote: Rick Welykochy wrote: Postscript is plain text (ASCII) containing Postscript program code and data. That was my first thought too. Unfortunately it simply doesn't work as expected. It turns out all this screw up was caused by something my colleague Peter Miller calls generator side font kerning. A better solution to this problem seems to be to insert raw Postscript into the file instead trying to replace text in the file. The safest place to do this seems to be straight after the %%EndPageSetup. Erik -- - Erik de Castro Lopo - One of Subversions biggest weaknesses is its lack of adequate internal tracking for merges. -- William Nagle in Subversion Version Control -- SLUG - Sydney Linux User's Group Mailing List - http://slug.org.au/ Subscription info and FAQs: http://slug.org.au/faq/mailinglists.html