I am trying to allow the user to select an appropriate paper size for their printer within my own print settings dialog. Does anyone know a workable solution - preferably cross platform but otherwise OSX.
If I use a TPageSetupDialog then when executed it produces an error in the PASever window of Invalidpmobject although the dialog shows but doesn't seem to affect the current printers paper size. There doesn't seem to be any proerties to see what the user selected either.
I need to set the paper size without actually printing as the user needs to be able to adjust things with the new paper size first.
I finally figured out the problem so here is the solution for anyone else with the problem:
Use TPageSetupDialog but you must set valid pagewidth and pageheight values for the current printer before calling it - otherwise you get an error reported in PAServer window and the printer selection box will be set to "any printer" instead of the current printer name.
Unfortunately you cannot derive the paper size directly from the printer pagewidth and resolution because it reports printable area not paper size. So I set a default of A4 whenever the user chooses another printer. I guess you could set the nearest standard paper size to the calculated value from printer.pagewidth/printer.activeprinter.activedpi.x if you want to take care of printers that do not support A4.
The other point to note is that the default page sizes in the TPageSetupDialog component are wrong. Set the units to mm and use width 210000 and height 297000 (note 10 times bigger than the default values) for A4 size that most printers should support.
We have a very old program that we print from where you are unable to change the left print margin in the program. I need to get it printing further from the left edge, ideally about 1 inch for binding. No issue with text going over the right edge as it doesn't get near that side of the page.
My idea was to use a custom separator page https://support.microsoft.com/en-us/kb/131714 to issue a PCL command to increase the left margin.
We are using HP printers and I have tried using the standard windows example C:\Windows\System32\pcl.sep which works exactly as expected.
This is my attempt at a .sep file (am saving in the system32 folder)
\
\H1B\L%-12345X
\H1B\LE
\H1B\L&l4000U
\H1B\L&a+3000H
\
I've tried a couple of variations, but it does absolutely nothing, my document just prints like normal.
Any help much appreciated.
My guess is that the application is explicitly setting the margins,
thus undoing anything you are trying in the .sep file. I am not familiar with the .sep file at all.
In the PCL context, if you are printing in duplex you want the extra binding on the left for the front side and on the right for the backside. The PCL command to end up with a 1 inch binding margin would be something like &l540U The 540U shifts the image 3/4 inch which when added to the existing minimum 1/4 inch margin gives you a 1 inch total.
Can you direct your output to a file to see what is actually being sent to the printer?
(Powerbuilder 11.5.1 build 5097)
I have found that the text size setting (Windows7 Control Panel -> Appearance and Personalization -> Display "Change Text Size") alters printed reports coming from powerbuilder.
When set to smaller - 100% (default), the report works as designed
When set to Medium - %125, 33 rows of data take up nearly one full extra printed line and get cut off.
When set to Large - %150, the report works as designed again.
All my testing is being done with the same computer using the same printer changing just this one widnows preference. The report contains a fixed-size box which takes up most of the right half of the page. When I print using "medium fonts" the bottom of the data gets cut off. Folding over the page and comparing it to a "smaller font" print shows that the report block is exactly the same size but the data within it is drifting downwards.
Call me old fashioned but I firmly believe that the display settings of my monitor should not affect prints. Anyone have any information on how to make powerbuilder behave correctly?
What was the original historical use of the vertical tab character (\v in the C language, ASCII 11)?
Did it ever have a key on a keyboard? How did someone generate it?
Is there any language or system still in use today where the vertical tab character does something interesting and useful?
Vertical tab was used to speed up printer vertical movement. Some printers used special tab belts with various tab spots. This helped align content on forms. VT to header space, fill in header, VT to body area, fill in lines, VT to form footer. Generally it was coded in the program as a character constant. From the keyboard, it would be CTRL-K.
I don't believe anyone would have a reason to use it any more. Most forms are generated in a printer control language like postscript.
#Talvi Wilson noted it used in python '\v'.
print("hello\vworld")
Output:
hello
world
The above output appears to result in the default vertical size being one line. I have tested with perl "\013" and the same output occurs. This could be used to do line feed without a carriage return on devices with convert linefeed to carriage-return + linefeed.
Microsoft Word uses VT as a line separator in order to distinguish it from the normal new line function, which is used as a paragraph separator.
In the medical industry, VT is used as the start of frame character in the MLLP/LLP/HLLP protocols that are used to frame HL-7 data, which has been a standard for medical exchange since the late 80s and is still in wide use.
It was used during the typewriter era to move down a page to the next vertical stop, typically spaced 6 lines apart (much the same way horizontal tabs move along a line by 8 characters).
In modern day settings, the vt is of very little, if any, significance.
The ASCII vertical tab (\x0B)is still used in some databases and file formats as a new line WITHIN a field. For example:
In the .mer file format to allow new lines within a data field,
FileMaker databases can use vertical tabs as a linefeed (see https://support.microsoft.com/en-gb/kb/59096).
I have found that the VT char is used in pptx text boxes at the end of each line shown in the box in oder to adjust the text to the size of the box.
It seems to be automatically generated by powerpoint (not introduced by the user) in order to move the text to the next line and fix the complete text block to the text box. In the example below, in the position of §:
"This is a text §
inside a text box"
A vertical tab was the opposite of a line feed i.e. it went upwards by one line. It had nothing to do with tab positions. If you want to prove this, try it on an RS232 terminal.
similar to R0byn's experience, i was experimenting with a Powerpoint slide presentation and dumped out the main body of text on the slide, finding that all the places where one would typically find carriage return (ASCII 13/0x0d/^M) or line feed/new line (ASCII 10/0x0a/^J) characters, it uses vertical tab (ASCII 11/0x0b/^K) instead, presumably for the exact reason that dan04 described above for Word: to serve as a "newline" while staying within the same paragraph. good question though as i totally thought this character would be as useless as a teletype terminal today.
I believe it's still being used, not sure exactly. There might be even a key combination of it.
As English is written Left to Right, Arabic Right to Left, there are languages in world that are also written top to bottom. In that case a vertical tab might be useful same as the horizontal tab is used for English text.
I tried searching, but couldn't find anything useful yet.
How can I fully justify a block of text (like MS Word does, not only on the right and not only on the left but on both sides)?
I want to justify some texts (mainly arabic text) adjusted to certain screen size (some handheld device screen actually, and its text viewer doesn't have this function) and save this text as justified. So I can reload and reuse it again elsewhere.
(The problem with MS word is, that if you copy the justified text from MS Word and paste it to another editor it'll copy it un-justified).
Update : for now I'm thinking of doing it like this:
get-a-word
get-word-width
add-word-to-total-Word and add-Word-width-to-total-word-width
check if total-Word-width = myscreen-width then continue
else if total-Word-width is between myscree-wdith and (myscreen-width -3) then
add-spaces-To-total-word until it = myscreen-width
This is what I'm thinking now, but I put this question up and hope to see if there is a better solution, or somebody else already implemented it.
PS: I hope I have made my question clear and I'm sorry for bad expression if there is.
edit1 : changed the title to make it more clear.
If you want to justify plain text, you can only add extra spaces to the lines to get them align on the left and right. Unfortunately the character widths differ in fonts; so doing it this way will only work for a certain font, unless you limit yourself to monospaced fonts where all characters have the same size.
If you want a result like in Word, adding spaces won't cut it. Word will not add spaces, but stretch and shrink the existing spaces. This information is lost when you copy and paste it into another app.
Either way, justifying is an optimization problem. If you are interested in a good solution and its implementation: have a look a TeX. For an implementation that works on plain text with monospaced fonts have a look at par
There are some API calls that may help:
ExtTextOut and GetCharacterPlacement
Look at the GCP_JUSTIFY flag for GetCharacterPlacement
ExtTextOut is used by Canvas.TextRect
The problem you are going to face is always going to be differences in the rendering of the font. Word handles full justification by adjusting kerning as well as adjusting the number of pixels between words by a few (either way). The end result is lined up both margins. This pixel adjustment is done BOTH ways, and as evenly as possible.
To properly handle this in your portable device you will have to also perform the same algorithm for the display of the text there.
If this is not possible, then the ONLY way you can even get somewhat close would be to add whitespace between words.
As has been pointed out in other answers Word does full justification by stretching the existing spaces often by very small amounts. This is only possible if you have full control over how your text is drawn on the screen (which word - or any other windows program has).
You only real option in this regard would be to implement your own text viewer on the platform you are targeting. Eg you would need to draw the text on the screen yourself (any platform that allows games should allow you to draw on the screen). However this seems like an awful lot of trouble to get justified text.
Sorry couldn't be of more help.