How to place printer driver parameters in postscript print file? - printing

i have a postscript file, which has heavily printer driver setting dependencies. I am trying to bundle printer settings into my postscript printfile and passthrough it to the printer. The passthrough works just fine with `lpr -l . But i am not able to bring some options from the ppd directly into the postscript file.
Xerox pdd file snipped
*OpenUI *OutputMode/Print Quality: PickOne
*OrderDependency: 46.0 AnySetup *OutputMode
*DefaultOutputMode: HighSpeed
*OutputMode HighSpeed/High Speed: "
<</PostRenderingEnhance true
/PostRenderingEnhanceDetails currentpagedevice
1 index get 1 dict copy
dup /Type 33 put
dup /OutputMode (high-speed) put
>> setpagedevice
"
*End
*OutputMode HighQuality/High Quality: "
<</PostRenderingEnhance true
/PostRenderingEnhanceDetails currentpagedevice
1 index get 1 dict copy
dup /Type 33 put
dup /OutputMode (highest-quality) put
>> setpagedevice
"
*End
*OutputMode HighResolution/High Resolution: "
<</PostRenderingEnhance true
/PostRenderingEnhanceDetails currentpagedevice
1 index get 1 dict copy
dup /Type 33 put
dup /OutputMode (highest-resolution) put
>> setpagedevice
"
*End
*CloseUI: *OutputMode
When i place the highest-resolution part at the beginning of the %%BeginPrelog part, than i get an invalid file:
<</PostRenderingEnhance true
/PostRenderingEnhanceDetails currentpagedevice
1 index get 1 dict copy
dup /Type 33 put
dup /OutputMode (highest-resolution) put
>> setpagedevice
When i evaluate the correctness of the file via ps2pdf i get the following error:
Error: /undefined in --get--
Operand stack:
--nostringval-- PostRenderingEnhance true PostRenderingEnhanceDetails --dict:210/309(ro)(L)-- PostRenderingEnhanceDetails
Execution stack:
%interp_exit .runexec2 --nostringval-- --nostringval-- --nostringval-- 2 %stopped_push --nostringval-- --nostringval-- --nostringval-- false 1 %stopped_push 1990 1 3 %oparray_pop 1989 1 3 %oparray_pop 1977 1 3 %oparray_pop 1833 1 3 %oparray_pop --nostringval-- %errorexec_pop .runexec2 --nostringval-- --nostringval-- --nostringval-- 2 %stopped_push --nostringval--
Dictionary stack:
--dict:731/1123(ro)(G)-- --dict:0/20(G)-- --dict:75/200(L)--
Current allocation mode is local
Current file position is 308
GPL Ghostscript 9.50: Unrecoverable error, exit code 1
Nevertheless, the setpagedevice options from this post works just fine:
How to select PostScript printer output tray
So i do not know how to convert the ppd option to valid postscript code. Does anyone have a clue here, how to get a valid postscript file?

You are trying to apply a device-specific control (/OutputMode) to a device which does not support that control. Not only that, but the code you include acesses the current page device dictionary and assumes that there will be a PostRenderingEnhanceDetails dictionary in it. The code makes no attempt to check if the required data exists which means it will only work on a device which has a /PostRenderingEnhanceDetails entry in the page device dictionary. The pdfwrite device (which is what ps2pdf uses) does not have such an entry, which is why you get an error.
There may be nothing wrong with your PostScript, its simply that you can't apply it to that device. Note that all the keys in the question you link to are standard page device dictionary entries, OutputMode is not and there is no PostRenderingEnhanceDetails entry either.
The PostScript code in the PPD (PostScript Printer Description) is all that you need to use, but the opint of a PPD is to include PostScript that will only work reliably on the printer its intended for. You can't use Ghostscript to test the correctness of device-specific PostScript configured for a non-Ghostscript device.

Related

ImageMagick `-duplicate` but to beginning of sequence

-duplicate
convert img*.png -duplicate 3 out.gif
makes
0 1 2 2 2 2
where 0 is img0.png, and 1 is img1.png, etc, making a GIF. But can I make below?
0 0 0 0 1 2 2 2 2
that is, append to end and start? I get I can use indexing to make
0 1 2 2 2 2 0 0 0
which is identical in a loop, but I need the 0s at start in context.
TL;DR for 0 0 0 1 2 3 ... 20 21 21 21 (any number of images) do
convert img*.png -write mpr:imgs -delete 0--1 mpr:imgs[0,0,0,1--1,-1,-1] out.gif
Using ImageMagick v6 on Windows command line, this command will let you arrange the order and number of images in any way you need.
convert img*.png -write mpr:imgs -delete 0--1 mpr:imgs[0,1,2,2,2,2,0,0,0] out.gif
That reads the 3 input images, copies them all into a memory register named "mpr:imgs", deletes the input images from the command, then reads the images from that memory register as you specify in the square brackets. The image index 0 is the first image read into the command, 1 is the second, etc.
Also, using -duplicate you can specify which image in the list you want to use according to their order in the list. This command will give the same result as the one above...
convert img*.png -duplicate 3 -duplicate 3,0 out.gif
The command reads the three images, then -duplicate 3 makes 3 more of the last image in the list, then -duplicate 3,0 makes 3 more of the first image in the list, index 0.
Another approach would be to use ( -clone ... ) inside parentheses to create the number of duplicates in the order you want.
convert img*.png ( -clone 2,2,2 -clone 0,0,0 ) out.gif
That reads the 3 input images, clones the third image 3 times, then clones the first image 3 times, giving the same result as the commands above.
These commands are in Windows syntax. For a *nix OS you'd have to escape the parentheses with backslashes "\(...\)".
Also helpful are -swap, -reverse, -insert, and -delete to manipulate the order of images in the list.
You should be able to load your first image, make any duplicates you need, then load the second and make duplicates and load the third and make any duplicates:
convert img0.png -duplicate 3 img1.png img2.png -duplicate 3 ...
will give your desired image sequence:
0 0 0 0 1 2 2 2 2

"no next heap size found: 18446744071789822643, offset 0"

I've written a simulator, which is distributed over two hosts. When I launch a few thousand processes, after about 10 minutes and half a million events written, my main Erlang (OTP v22) virtual machine crashes with this message:
no next heap size found: 18446744071789822643, offset 0.
It's always that same number - 18446744071789822643.
Because my server is very capable, the crash dump is also huge and I can't view it on my headless server (no WX installed).
Are there any tips on what I can look at?
What would be the first things I can try out to debug this issue?
First, see what memory() says:
> memory().
[{total,18480016},
{processes,4615512},
{processes_used,4614480},
{system,13864504},
{atom,331273},
{atom_used,306525},
{binary,47632},
{code,5625561},
{ets,438056}]
Check which one is growing - processes, binary, ets?
If it's processes, try typing i(). in the Erlang shell while the processes are running. You'll see something like:
Pid Initial Call Heap Reds Msgs
Registered Current Function Stack
<0.0.0> otp_ring0:start/2 233 1263 0
init init:loop/1 2
<0.1.0> erts_code_purger:start/0 233 44 0
erts_code_purger erts_code_purger:wait_for_request 0
<0.2.0> erts_literal_area_collector:start 233 9 0
erts_literal_area_collector:msg_l 5
<0.3.0> erts_dirty_process_signal_handler 233 128 0
erts_dirty_process_signal_handler 2
<0.4.0> erts_dirty_process_signal_handler 233 9 0
erts_dirty_process_signal_handler 2
<0.5.0> erts_dirty_process_signal_handler 233 9 0
erts_dirty_process_signal_handler 2
<0.8.0> erlang:apply/2 6772 238183 0
erl_prim_loader erl_prim_loader:loop/3 5
Look for a process with a very big heap, and that's where you'd start looking for a memory leak.
(If you weren't running headless, I'd suggest starting Observer with observer:start(), and look at what's happening in the Erlang node.)

Error on convert pdf to png using ImageMagick

Give error while convert pdf to png by using below command :
convert -density 300 -depth 8 -quality 85 655382767_1460008284.pdf[0-9] 655382767_1460008284.png
OS : Redhat 64 bit 6.7
ImageMagick : version 6.7.2-7 2015-02-27 Q16
Ghostscript : GPL Ghostscript 8.70 (2009-07-31)
Its give below error :
+++++++++++++++++++++++++++++++++
Error: /ioerror in --showpage--
Operand stack:
1 true
Execution stack:
%interp_exit .runexec2 --nostringval-- --nostringval-- --nostringval-- 2 %stopped_push --nostringval-- --nostringval-- --nostringval-- false 1 %stopped_push 1862 1 3 %oparray_pop 1861 1 3 %oparray_pop 1845 1 3 %oparray_pop --nostringval-- --nostringval-- 4 1 8 --nostringval-- %for_pos_int_continue --nostringval-- --nostringval-- 1745 0 9 %oparray_pop --nostringval-- --nostringval--
Dictionary stack:
--dict:1157/1684(ro)(G)-- --dict:1/20(G)-- --dict:75/200(L)-- --dict:75/200(L)-- --dict:106/127(ro)(G)-- --dict:286/300(ro)(G)-- --dict:22/25(L)-- --dict:4/6(L)-- --dict:27/40(L)--
Current allocation mode is local
Last OS error: 28
GPL Ghostscript 8.70: Unrecoverable error, exit code 1
convert: Postscript delegate failed 655382767_1460008284.pdf': No such file or directory # error/pdf.c/ReadPDFImage/664. convert: missing an image filename655382767_1460008284.png' # error/convert.c/ConvertImageCommand/3015.
++++++++++++++++++++++++++++++++++
Please help me to fix it.
Also some other pdf files are converted perfactly to png.
Please find attachment of pdf file which are making issue on converting to png using Imagemagick convert command.
enter link description here
ioerror means there was an I/O error, which may mean that the disk is full, or there was some other problem. Try using a lower resolution ('density' in IM terms I think). Given that you have 8 pages, each page is 32x76 inches and you have a resolution of 300 dpi you are looking at producing a lot of data, about 1.8Gb if depth=8 means greyscale.
There could be any number of other reasons why there was an ioerror, the next thing to do is to try a more recent version of Ghostscript 8.70 is now 6 years old..... As Mark Setchell suggests you could also try using a more recent version of ImageMagick, though I doubt that will help, since its clearly an error being returned from Ghostscript.

CGPDFScanner - \x15 character while scanning

I am trying to extract the text of page 5 in pdf.
The pdf have a font YLJAAA+CMSY10 which has no mappings (CMap) or even encodings (default encoding or /Differences). While extracting text, after string "tetex package" CGPDFScanner returns "\x15" character which is encountered many times. When this character is encountered current font is the above mentioned font which has nothing to extract the text from pdf string.
What is this \x15 character?
Thanks.
I found 2 (not "many") occurrences of this:
[ (\025) ] TJ
which is a number in octal – this is the number that is \x15 in hexadecimal.
The font definition for "YLJAA+CMSY10" in the PDF carries no special encoding, so it has the default encoding for "CMSY" ("Computer Modern Symbol"):
114 0 obj
<<
/Type /Font
/Subtype /Type1
/BaseFont 210 0 R % -> "/YLJAAA+CMSY10"
/FirstChar 0
/FontDescriptor 211 0 R
/LastChar 127
/Widths 204 0 R
>>
211 0 obj
<<
/Ascent 750
/CapHeight 683
/CharSet (/bullet/greaterequal/arrowright/arrowdblright/element/negationslash/backslash/radical)
/Descent 0
/Flags 4
/FontBBox [ -29 -960 1116 775 ]
/FontFile 205 0 R
/FontName 210 0 R % -> '/YLJAAA+CMSY10'
/ItalicAngle -14
/StemV 85
/XHeight 430
>>
endobj
In itself, this still says nothing definitive: a PDF producer may reorder glyphs and encodings at will, as long as it does the same with the embedded font). Assuming the font set is not reordered, checking a random list of CMxx encodings shows that the character code 0x1F could well be GREATER-THAN OR EQUAL TO (Unicode U+2265).
Acrobat agrees; inspecting the font in the PDF shows that character code 21 (decimal) is named 'GREATER-THAN OR EQUAL' and looks like it as well.

Difference between variable.functionName and variable["functionName"]

I know that you can get variables and call functions both by using the name directly
variable.functionName
or using the name as a string
variable["functionName"] or variable[functionNameString]
Now my question is:
Is there any resulting difference in these different ways or are they completely interchangeable?
I am mostly interested about performance here, but any enlightenment is welcome.
The PUC-Rio Lua 5.1 byte code for
print(variable.functionName)
print(variable["functionName"])
print(variable[functionNameString])
is
main <var.lua:0,0> (14 instructions, 56 bytes at 0xafe530)
0+ params, 3 slots, 0 upvalues, 0 locals, 4 constants, 0 functions
1 [1] GETGLOBAL 0 -1 ; print
2 [1] GETGLOBAL 1 -2 ; variable
3 [1] GETTABLE 1 1 -3 ; "functionName"
4 [1] CALL 0 2 1
5 [2] GETGLOBAL 0 -1 ; print
6 [2] GETGLOBAL 1 -2 ; variable
7 [2] GETTABLE 1 1 -3 ; "functionName"
8 [2] CALL 0 2 1
9 [3] GETGLOBAL 0 -1 ; print
10 [3] GETGLOBAL 1 -2 ; variable
11 [3] GETGLOBAL 2 -4 ; functionNameString
12 [3] GETTABLE 1 1 2
13 [3] CALL 0 2 1
14 [3] RETURN 0 1
As you can see the first two lines generate exactly the same byte code (and thus take the same amount of time), while the third line has an additional (global) variable access.
The first line only works since "functionName" is a valid Lua identifier and not a reserved word. Lines 2 and 3 don't have restrictions about the format of the string key.
They are the same. From the manual:
... To represent records, Lua uses the field name as an index. The language supports this representation by providing a.name as syntactic sugar for a["name"].

Resources