| <<<Back 1 day (to 2020/02/01) | Fwd 1 day (to 2020/02/03) >>> | 20200202 |
pdfguy | Test. | 08:43.43 |
| Well, I'm trying to use GhostScript (which I have installed) to convert a plaintext document into a PDF. Somebody gave me a PostScript program/script from 1992 which did seem to work, but which messed up the margins, so I cannot use it. | 08:44.29 |
| The reason it messed up the margins is because it did not define a "page size", which seems crazy but true. | 08:44.47 |
| And in spite of my best efforts, I was never able to modify the PostScript to make it work. | 08:45.02 |
| So now I'm wondering if this rather basic/common thing is perhaps even built into GhostScript? Or is there some "recommended template PostScript" somewhere that I'm supposed to use for this? | 08:45.35 |
| The plaintext document expects a proportional-width font (Courier or Courier New) and uses 80 chars per line. | 08:46.05 |
kens | pdfguy (aka Lucina Evans) I already answered your questions on Stack Overflow to the best of my ability. If you want to modify a PostScript program you're going to ghave to learn at least the basics of PostScript. | 09:13.28 |
| No what you want is not built into Ghostscript. There are various PostScript programs which do (badly) what you are trying to do. The reason they do it badly is because text layout is actually a very complex area. | 09:14.15 |
pdfguy | @kens Well, I don't really wanna modify it. I just want to accomplish the conversion, and this was the closest I've ever gotten. | 09:14.25 |
| Yes, but since the input format is essentially a "text blob column" (with 80 chars), it seems like the hard really work has already been taken care of. | 09:15.02 |
kens | I've given you what information I can. Your program assumes a fixed media size, but does no requet that size media. I've told you what PostScript command will request the media size you want | 09:15.07 |
pdfguy | I tried to add the code you showed but it either became part of the output, or was ignored, depending on where it was put. | 09:15.31 |
kens | You say that doesn't work, but you haven't supplied an example of what you've done | 09:15.33 |
| So its impossible for me to say what the problem is | 09:15.46 |
pdfguy | Is there some kind of "repository" of common PostScript scripts? | 09:18.28 |
kens | No. | 09:18.33 |
pdfguy | It seems like this would be used daily by countless people in countless situations. | 09:18.42 |
kens | Not since the 1980s | 09:18.55 |
pdfguy | People still write plaintext walkthroughs for video games and stuff. | 09:19.42 |
| E-mails to various mailing lists use plaintext, etc. | 09:19.53 |
kens | But they don't use PostScript | 09:20.00 |
| PostScript was (and is) intended as a programming language for printing | 09:20.22 |
pdfguy | Making a PDF can be considered a form of "printing", except it's not physical. | 09:21.19 |
| As mentioned earlier, I have tried a million methods to accomplish this what I originally thought would be a basic task, but nothing does it. | 09:21.41 |
kens | There are many, many text to PostScript/PDF solutions out there. | 09:22.05 |
| If you want ot use a PostScript program we obviously don't have a problem with that, but you are going to have to learn something about the language | 09:22.32 |
| If you want to modify the program | 09:22.39 |
pdfguy | I know there are many of those, since I've tried them all. And they don't work. | 09:23.49 |
| @kens I just tried running the script with "ps2pdf -sPAPERSIZE=a4" (after digging up that option, which was not easy). Same thing. | 09:31.24 |
| It seems to not care about any specified papersize and just adds insane margins. | 09:31.38 |
kens | Well yes, since A4 is not 11 inches in length | 09:31.40 |
| and your program expects 11 inch length media | 09:31.56 |
pdfguy | Hmm... Changing "/pageheight 11 inch def" to "/pageheight 11.7 inch def" does make it look a bit saner, but still, it seems to waste quite a lot of margins, but maybe that's how things are preferred... I assume I have to also set the pagewidth to the A4 width for it to be horizontally centered. | 09:35.27 |
| (11.7 inches is the height of A4) | 09:35.42 |
kens | I don't remember the program in detail, but I don't believe it did horizontally centre the text at all. | 09:36.14 |
| It simply set a 1 inch left white space | 09:36.22 |
pdfguy | Seems like it... | 09:36.51 |
kens | Well I've retrieved the program from Stack Overflow, and it works as expected for me | 09:48.09 |
pdfguy | Probably because your system defaults to the 11-inch page instead of 11.7. | 09:49.21 |
kens | No | 09:49.25 |
| I set -sPAPERSIZE=letter | 09:49.34 |
| So that's US Letter which is 11 inches in length | 09:49.42 |
| I have a strong suspicion I kow what you're doing, but I cannot tell without seeing the exact program you are using (including the text) | 09:50.09 |
pdfguy | I mean, as mentioned, I "kinda" have it working since I set the =A4 and changed the 11 to 11.7, as well as the leftmargin to 0.8 instead of 1 inch, but it feels like it "works by accident" and is "rather fragile". | 09:51.02 |
kens | Like I said, I suspect I understnad your problem, to prove it I'd need to see your program, as I've mentioned several times before. If you're not prepared to share it there's not a lot I can say other than 'works for me;' | 09:52.01 |
pdfguy | kens: Right now: Literally your script, with "11 inch" changed to "11.7 inch". And "ps2pdf -sPAPERSIZE=a4 ..." for the command. | 10:01.17 |
kens | Can't be my program | 10:01.31 |
| Mine is here I haven't shared it anywhere | 10:01.39 |
pdfguy | text2ps.ps | 10:02.06 |
kens | How is that my program ? | 10:02.42 |
| THis is the output of my program, converted to PDF: | 10:05.08 |
| https://www.dropbox.com/s/yjtg2cxa7xiqkto/out.pdf?dl=0 | 10:05.08 |
| A couple of points: The program does not center the text, it simply adds a 1 inch white space at the left. It doesn't use a proportional font, it uses Courier, which is a fixed-width font. If the number of characters and the character width happen to line up so that the remaining white space at the right edge is more or less 1 inch, then it will look centered, but it isn't. Altering the font, font size or media width will mean t | 10:14.51 |
| he white space at left and right might differe marekedly | 10:14.51 |
ray_laptop | pdfguy: kens: for people that want to take plain text into a formatted page, I usually recommend 'enscript' It's been around for YEARS (>30) and does the 'formatting' with lots of control (without needing to learn PostScript programming | 19:56.34 |
| that being said, the options can be rather daunting for anything advanced | 19:57.42 |
| <<<Back 1 day (to 2020/02/01) | Forward 1 day (to 2020/02/03)>>> | |