| <<<Back 1 day (to 2018/04/23) | 20180424 |
cybrNaut | ray_laptop: is trimbox what I need? The physical paper is A4. The printer cannot print in the left 3mm of the edge, or within 5mm of the other sides. So I'm trying to define a printable region. | 12:56.36 |
| The original file does not need to be scaled, but it needs to be shifted because graphviz generates the PS file with the content nearly touching the far left edge of the paper | 12:57.50 |
kens | What exactly are you trying to achieve ? Do you want to remove the content in the non-printable area ? Shift it (and scale the page) ? Something else ? | 12:58.00 |
cybrNaut | scaling should not be necessary. But it needs to be shifted to the right. | 12:58.59 |
kens | So you want to create a PDF file from a PostScript file, but offset teh PDF content by an x,y amount ? | 12:59.02 |
cybrNaut | yes.. but lemme just confirm my source is ps | 12:59.26 |
| yes.. my source file is postscript | 13:00.01 |
kens | You could call setpagedevice with a PageOffset array. De | 13:00.05 |
| -c "<</PageOffset [x y]>> setpagedevice" -f input.ps | 13:00.34 |
cybrNaut | hmm.. i've tried that | 13:00.48 |
| i used this to be exact => -c '.setpdfwrite <</PageOffset [8.5 14]>> setpagedevice' | 13:01.00 |
kens | Then possibly your PostScript does something like initgraphics | 13:01.01 |
cybrNaut | and i also tried that w/out the ".setpdfwrite" | 13:01.09 |
kens | You don't need to execute .setpdfwrite | 13:01.15 |
| I think your best bet is going to be to post an example PostScirpt file somewhere to look at | 13:01.31 |
cybrNaut | ok.. i'll need a min | 13:03.12 |
| http://termbin.com/g3br <= that's the postscript | 13:08.30 |
kens | Right just a moment | 13:08.36 |
| Umm I meant a URL I could download it from..... | 13:09.02 |
| Well it doesn't execute setpagedevice so I can't see an immediate problem | 13:10.37 |
cybrNaut | https://gpldr.in/v/wrsnQaOjgk/qMzf23zJB7w3hqNI | 13:11.01 |
| i think my problem is quite fundamental.. that is, I get just a blank page if I use -c '<</PageOffset [8.5 14]>> setpagedevice' | 13:11.58 |
| my full cmd looks like this => gs -o /tmp/diagram_a4.pdf -sDEVICE=pdfwrite -sPAPERSIZE=a4 -dFIXEDMEDIA -dPDFFitPage -dCompatibilityLevel=1.4 -c '<</PageOffset [8.5 14]>> setpagedevice' /tmp/cf.ps | 13:12.25 |
kens | Well PageOffset works as expected for me | 13:12.26 |
| The x and y numbers are in PostScript units | 13:12.49 |
| 1/72 inch | 13:12.53 |
cybrNaut | this switch breaks it, so it's just a blank pg: -c '<</PageOffset [8.5 14]>> setpagedevice' | 13:12.56 |
| right, that's my understanding.. I converted from 3mm and 5mm | 13:13.24 |
kens | You've used ' not " there. You need a double quote not a single quote | 13:13.24 |
| For the purposes of experimentation, I used big numbers | 13:13.42 |
| gs -sDEVICE=pdfwrite -sOutputFile=out.pdf -c "<</PageOffset [100 100]>> setpagedevice" -f bad.ps | 13:14.22 |
| That produces for me a PDF file with the content significantly shifted up and right | 13:14.36 |
| ~1.5 inches in each direction | 13:14.45 |
cybrNaut | the quoting makes no difference for me (and nor should it, since nothing in the quotes need a shell interpretation) | 13:14.57 |
kens | Its not going to the shell, its going to Ghostscript | 13:15.14 |
cybrNaut | then I guess i need to escape the quotes? The shell will treat the quotes before gs gets them | 13:15.58 |
kens | If the shell is going to hammer the quotes then yes, you'll need to escape them | 13:16.17 |
| What shell are you using ? | 13:16.39 |
| Pretty sure this works OK for me | 13:16.47 |
cybrNaut | bash | 13:17.18 |
| so to ensure that gs receives quotes, i ran this and it failed => gs -o /tmp/diagram_a4.pdf -sDEVICE=pdfwrite -sPAPERSIZE=a4 -dFIXEDMEDIA -dPDFFitPage -dCompatibilityLevel=1.4 -c \"'<</PageOffset [8.5 14]>> setpagedevice'\" /tmp/cf.ps | 13:17.48 |
kens | failed how ? | 13:18.11 |
| What version of GS are you using ? Where did you get it ? | 13:18.25 |
cybrNaut | Error: /undefined in " | 13:18.32 |
| GPL Ghostscript 9.20: Unrecoverable error, exit code 1 | 13:18.40 |
kens | OK so that means the " got passed through to the PostScript interpreter | 13:18.50 |
cybrNaut | it's the standard debian stable version | 13:18.53 |
kens | Which is not going to work | 13:18.56 |
Robin_Watts | The purpose of the quotes around the << ... >> setpagedevice is to ensure that that gets passed to gs as a single argument. | 13:19.14 |
| i.e. the quotes are intended for the shell. | 13:19.24 |
kens | Yeah that's not what I asked. Did you get it from our source and build it, or from a package ? Packagers often add 'stuff' which can break it. | 13:19.24 |
| Running the command line I gave from a Fedora bash shell works perfectly well for me | 13:21.13 |
| Results in a PDF file where the content is shifted up and right, as expected | 13:21.25 |
| So I suggets you try running the command I gave | 13:21.43 |
cybrNaut | i'm not sure I installed ghostscript separately.. it may have been installed as a dependency to something else. In any case, what I have is the equivalent to have run "aptitude install ghostscript" from the official debian repos | 13:21.57 |
kens | Yes which is a package | 13:22.08 |
| I still usggest you run the comment mline I gave earlier, exactly as is, with teh double quotes | 13:22.23 |
| For me that produces (on Fedora) a PDF file where the content is shifted up and right by ~1.5 inches | 13:23.05 |
| MY God my typing is haywire | 13:23.19 |
| Trying to look at a screen 90 degrees to my keyboard..... | 13:23.38 |
| But the command line was a cut and paste so it shoudl be correct. | 13:23.57 |
cybrNaut | if I run your cmd, it seems to work | 13:24.20 |
kens | OK so if you substitute your numbers you should be good to go then | 13:24.37 |
cybrNaut | so something is conflicting with one of these options => -sPAPERSIZE=a4 -dFIXEDMEDIA -dPDFFitPage -dCompatibilityLevel=1.4 | 13:24.50 |
kens | Oh well | 13:24.57 |
| If you set -dPDFFitPage then you are going to screw things up | 13:25.12 |
| Because that command sets the media size to A4, makes it unalterable, and then scales the contetn to fit precisely | 13:25.37 |
cybrNaut | I thought i tried w/out that, but I tried so many things.. I'll confirm | 13:25.43 |
kens | If all you want to do is shift the content, then just /PageOffset will be fine. | 13:26.03 |
| If you want to do more complicated stuff, like scaling and repositioning the scaled content, then that gets more complicated | 13:26.25 |
cybrNaut | i think i found the problem w/my command | 13:29.13 |
| bizarre... it's simply the "-f" | 13:29.21 |
| i was omitting that, which generally works | 13:29.30 |
kens | Not in this case | 13:29.36 |
cybrNaut | but in this case the -f is critical | 13:29.42 |
kens | -c says 'treat the following as PostScript, up until the -f' | 13:29.53 |
| So if you don't provide a -f then *everything* following is treated as PostScript | 13:30.08 |
| Including the input filename | 13:30.14 |
cybrNaut | ahh! so that's why my -c commands have been terminating and doing nothing | 13:30.20 |
kens | I would guess so yes | 13:30.31 |
| Id expect an error mind you | 13:30.40 |
cybrNaut | not in my case. I prints banner, copyright info, and quits pretty quickly | 13:32.20 |
| yet it still produces a file (a blank page) | 13:32.38 |
kens | pdfwrite will often produce an empty PDF file when errors occur | 13:33.03 |
| Because it starts writing the file as soon as the device is opened | 13:33.12 |
cybrNaut | when I use the -f, then it takes more time, writes junk like "Loading NimbusRoman-Italic font..", and works | 13:33.13 |
kens | The 'junk' is important | 13:33.26 |
| Its informing you that your PostScript program doens't include the fonts it uses, so Ghostscript is having to search for replacements | 13:33.51 |
| Which may, or may not,, be what you wanted | 13:34.04 |
cybrNaut | well, sounds like I could do some gold-plating on it | 13:34.37 |
| maybe graphviz isn't smart about choosing a font that I have | 13:34.55 |
kens | When I try your commane line without a -f then I get an 'undefined' error on the filename, as I expect | 13:35.03 |
| Because the filename isn't a valid PostScript operator, or defined PostScript object | 13:35.18 |
cybrNaut | i just noticed it depends on whether the trailing file is pathed or not | 13:35.54 |
| foo.ps gives the error.. /tmp/foo.ps gives no error | 13:36.06 |
kens | Oh well if you put a '/' in there then that makes it into a PostScript name object | 13:36.19 |
| So that won't throw an error | 13:36.31 |
| It simply doesn't do anything actually useful | 13:36.38 |
cybrNaut | i was thinking about a bug report.. but i guess if "/tmp/foo.ps" is valid postscript code, it wouldn't be reasonable to expect the tool to be smart enough to detect an error | 13:38.23 |
kens | PostScript introduces name object with the '/' character | 13:38.50 |
| SO /tmp/foo.ps pushes tow name objects onto the PostScript stack. First /tmp then /foo.ps | 13:39.16 |
| Then you close the input | 13:39.29 |
| Since you haven't exeuted a showpage, none of the marking operations (which you haven't executed anyway) get transferred to teh output | 13:39.59 |
| So you get a blank output file. | 13:40.06 |
| So its not a bug, the interpreter is behaving exactly as it should in this case. | 13:40.28 |
cybrNaut | right.. that's what i was realizing | 13:40.51 |
| i was actually looking for a "-i" of sorts.. a parameter that would explicitly name the input file, and there didn't seem to be one | 13:42.27 |
| if there was, I wouldn't have gotten silently stung | 13:42.49 |
kens | Normally the input file(s) are simply listed one after another on the command line | 13:42.51 |
| separated by any other command line switches you want | 13:43.00 |
| So you can change the processing for each file. | 13:43.12 |
| Alternatively you can use the @file syntax | 13:43.22 |
| And provide all the input files in a file | 13:43.42 |
| That is provide all the input file *names* in a file | 13:43.52 |
cybrNaut | in my case that's not convenient.. I'll just try to be diligent | 13:47.21 |
| anyway, thanks for the help | 13:47.27 |
kens | NP | 13:47.33 |
Robin_Watts | gotta reboot. VS profiler being funny. | 13:52.28 |
| Forward 1 day (to 2018/04/25)>>> | |