| <<<Back 1 day (to 2018/05/23) | 20180524 |
kens | cs1 did you have a question ? | 09:26.53 |
cs1 | typing it up now. It's a bit confusing so I have to be careful with how I word things | 09:27.27 |
kens | Ah OK | 09:27.31 |
cs1 | Hey everyone, was wondering if I'd be able to get some guidance with an issue I'm having. A printed document containing 3 printable coupons to each page I've derived from a .spl file is printing to .pdf such that the various textboxes and images that create one individual coupon are selectable as individual objects. I'd like to ideally process each whole coupon from the .pdf into separate .tiff images so as to be able to sort them | 09:32.42 |
| however so far I've only been able to do this in Illustrator using the Export Selection feature (having selected all necessary text and images for one whole coupon) to .tiff. Is there a way to perhaps merge or otherwise concatenate multiple objects in a given area to become one object and/or export that as a .tiff image using ghostscript? | 09:32.51 |
kens | Ghostscript doesn't 'export' anything, it renders stuff. Or in the case of the high level devices it repackages marking operations as high level marking operations in another page description language. | 09:34.09 |
| Now having said that..... | 09:34.15 |
| It 'sounds like' what you are asking is to have sections of a page rendered to TIFF, rather than the entire page | 09:34.37 |
| That is possible, but non-trivial with the current Ghostscript implementation of the PDF interpreter | 09:35.24 |
cs1 | Correct, and if possible I'd like to specify the sections and process, say, a 50-page .pdf (sections are the same coordinates page-to-page). | 09:35.32 |
kens | Essentially what you need to do is set up a clip, and translate the page origin so that the relevant section of the contents is within the clip, then render the page. | 09:36.45 |
cs1 | Interesting. If it's of any help visualizing, I made a post about this here (did not get a workable solution) : https://stackoverflow.com/questions/50403903/concatenating-forcing-selectable-areas-of-pdf-file | 09:36.46 |
kens | Ah you only tagged your post with PDF, I don't often look in there because there's too much traffic and too many silly questions :-) | 09:37.22 |
cs1 | Ah, gotcha :) Though I should add - I am no longer using CUPS but rather .spl files | 09:38.15 |
| Both present the same issue, however | 09:38.30 |
kens | Well, as long as the input is in a format Ghostscript can handle, then its possible to do this. Its easiest with PostScript, hardest with PCL or XPS as an input I would think. | 09:38.50 |
| PostScript and PDF input would be reasonable easy to deal with. | 09:39.04 |
| It mihgt be possible to do this with a BeginPage procedure, and a hook to redefine the media size. | 09:39.48 |
| Be aware that '.spl' files doesn't really mean much | 09:40.02 |
| These are simply files stored by the Windows print spooler before sending to the pritner. As far as I'm aware these are stored in the printer language. | 09:40.32 |
| You do realise that to get three different TIFF files from the page, you would need to process it three tiems ? | 09:41.22 |
cs1 | Gotcha - I am working with .pdf. And indeed I do - to accomplish this as I am now, I'm click-dragging an area that highlights the needed sections and exporting the selection to .tiff. Ideally I'd like to automate the process (given same positioning on each successive page), but wanted to explore my options before I decided to learn how to script something like that. | 09:43.20 |
kens | Is one of the files on SO an example I can play with ? | 09:43.45 |
cs1 | I could upload a better one that's printed 3 to a page for you, probably a better example. | 09:44.16 |
kens | That would be useful, yes. I'd want to try it out before I reccomend anything | 09:44.32 |
cs1 | Here you are: https://bit.ly/2kl4zFG | 09:46.09 |
kens | OK I'll need to go off and experiment, this will tkae some minutes at least. I'm assuming you want each of the three areas outlined with scissor marks rendered to separate TIFF files ? | 09:47.10 |
| Oh by the way, that PDF file has a problem with a font | 09:47.38 |
| CIDFont+F1 contains a bad /BBox | 09:47.54 |
| Ah crappy Microsoft software.... | 09:48.19 |
cs1 | Ah, one sec, that might be bad | 09:50.55 |
kens | Its probably OK I'll let you know if its not | 09:51.06 |
cs1 | I use Microsoft's built in pdf printer to print page 1 of 1 - can you still highlight text? Should be able to. | 09:51.25 |
| RE: your question, that's exactly correct | 09:51.42 |
kens | Don't know, its not really relevant to what I'm doing | 09:51.43 |
cs1 | Gotcha, thanks for taking a crack at it :) | 09:52.05 |
kens | FWIW the few portions of the content that are text are selectable. Mostly the text is in fact image | 09:52.22 |
cs1 | I believe you're correct - I think just the border, fine print, expiration and a few other elements are actual text IIRC, the rest being images | 09:55.45 |
kens | I didn't look in detail, but a lot of it is image | 09:56.02 |
| OK so its reasonably simple to do. | 09:57.43 |
cs1 | Glad to hear it!1 | 09:58.18 |
kens | First thing is to set up the desired emdia size, and prevent it being changed. I chose to use the full width and 1/3 the height of the original file. So: | 09:58.35 |
| -dDEVICEWIDTHPOINTS=612 -dDEVICEHEIGHTPOINTS=26 -dFIXEDMEDIA | 09:58.35 |
| That sets the media size to 612x260 and prevents it being altered | 09:58.51 |
| ThThen run the page the first time. The output will be the bottom third of the page | 09:59.13 |
| For teh second pass we need to alter the position of the contents so that teh midfdle third of the page lies inside the media. To do this we use a BeginPage procedure: | 10:00.19 |
| -c "<</BeginPage {-260 translate}>>setpagedevice" -f | 10:00.19 |
| And for the thrid pass, we just increase the translate: | 10:01.06 |
| -c "<</BeginPage {-520 translate}>> setpagedevice" -f | 10:01.06 |
cs1 | Awesome, I see what you're saying | 10:01.11 |
kens | Hmm actually that's not corrrect sorry | 10:02.02 |
| translate takes 2 parameters, that should throw an error | 10:02.31 |
| Should be 0 -260 translate | 10:02.41 |
| let me just try that again here | 10:02.47 |
| Yes that's better :-) | 10:03.27 |
| and obviously 0 -520 translate for the secodn case | 10:03.54 |
cs1 | Fantastic. I'll get on really well with that I think. Now the question is how to go about defining those values such that they crop (so to speak) the borders rather than sides of the page. Or is -dDEVICEWIDTHPOINTS applied from the exact center, making that rather easy? | 10:04.20 |
kens | Now obviously you could get a tighter fit by meddling with the DEVICEWIDTHPOINTS and DEVICEHEIGHTPOINTS and altering the translate as required | 10:04.51 |
| The first parameter is the x shift, the second is the y shift | 10:05.05 |
| no DEVICEWIDTH is the actual width, and teh origin of the content is normally at 0,0 = bottom left. | 10:05.38 |
cs1 | Got it | 10:06.11 |
kens | So you can make the width narrower, and shift the content to the left until the border just touches the left edge | 10:06.36 |
| By fiddling with the numbers | 10:06.44 |
| Hmm -20 was too mcuh :-) | 10:07.09 |
cs1 | Well great, that should be plenty workable for me | 10:07.19 |
kens | Oh oops typo I put -200 :-D | 10:07.21 |
cs1 | Haha, not a worry, my whole process here has been plently of T&E. It's just past 3am where I'm at so you can imagine how long I've been trying to figure this out ;) | 10:08.26 |
kens | Hmmm you must be far to the West of us, West Coast US ? | 10:09.07 |
| BTW the units are PostScript points 1 point = 1/72 inch | 10:10.04 |
| So if you can measure the distances you can enter precise values | 10:10.15 |
cs1 | Seattle, specifically! Nevertheless you've undoubtedly shaved off a solid couple days of grief with your insight here, which is very much appreciated | 10:10.34 |
kens | NP | 10:10.40 |
cs1 | Even better! | 10:10.42 |
kens | For me -78 -38 translate gets the llowest coupon pretty tight to the bottom left corner of the page | 10:11.30 |
cs1 | So theoretically then I could trim 2 of 4, or 4 of 4 sides that way? | 10:15.20 |
kens | Yes rendering a subset of the page (any rectangular subset) can be done trivially like this | 10:15.42 |
cs1 | I *think* the right side of the page is taken care of with the first setting, but am not too sure without doing it myself | 10:15.55 |
kens | Non-rectangular areas can be done too, but that's more complicated | 10:16.03 |
| You need to set teh media size to the actual width and height you need | 10:16.21 |
| Then move teh content until its precisly under that 'window' | 10:16.35 |
cs1 | Oh, right right right I understand now :) | 10:16.48 |
kens | Note that for multi-page files, you can run the entire file and get multiple TIFF files out (using the %d filename syntax) each of which renders the same portion of the page. Then rerun again with different parameters to render a different portion of the page, and so on | 10:19.24 |
| I'm afraid you do need to do one pass through the file for each page section though | 10:20.15 |
cs1 | That's still miles faster than doing each by hand, I'll take it :P | 10:26.22 |
deekej | hello chrisl, Fabian is asking if you could merge this PR, please: | 11:55.07 |
| https://github.com/ArtifexSoftware/urw-base35-fonts/pull/24 | 11:55.08 |
chrisl | Um, odd - I didn't get a notification of that pull request.... | 11:58.13 |
deekej | chrisl: no problem, it happens sometimes :) | 12:00.31 |
chrisl | It's worrying because I rely on the mailed notifications, since I don't regularly visit that repo on github | 12:01.13 |
deekej | ah, hmm | 12:01.40 |
chrisl | deekej: and https://github.com/ArtifexSoftware/urw-base35-fonts/releases/tag/20170801.1 | 12:03.56 |
deekej | chrisl: thanks :) I think Fabian will like that ;) | 12:05.00 |
chrisl | Hopefully, if you can confirm it's all okay (when you have time), then I'll take the pre-release flag off it | 12:05.45 |
deekej | chrisl: I'm still waiting on some reply from Juergen Willrodt from URW | 12:06.24 |
chrisl | deekej: You may have a long wait (based on past experience) | 12:06.42 |
deekej | He was fixing the StandardSymbolsPS.otf and some other versions as well | 12:06.44 |
| yeah, it already takes some time | 12:06.55 |
| he has fixed it partially, so we are waiting for the final fix | 12:07.08 |
| IMHO, I would wait for the fix, and maybe doing .2 release | 12:07.27 |
| I'm okay with keeping the Pre-release flag for there now | 12:07.40 |
| *there for now :D | 12:07.46 |
chrisl | OKay | 12:07.47 |
| Off out for a couple of hours... | 12:23.43 |
ray_laptop | kens: re the interaction with cs1, I usually use /Install { } to translate rather than BeginPage because it alters the initial graphics state in case an 'initgraphics' operator is used | 15:07.34 |
| kens: but since the input is PDF, and you know the PDF interpreter so well, BeginPage worked as well | 15:08.43 |
| PostScript from some random source is more of an issue, particularly if the file has "setpagedevice" in the header | 15:09.48 |
| kens: (note this is a comment for the logs, since I know you already know all this) :-) | 15:10.24 |
| Forward 1 day (to 2018/05/25)>>> | |