Spanish characters in vb.net desktop application - vb.net

I'm learning Spanish and wrote an application to display a form at random intervals at random places on the screen. Spanish words are taken from random positions in a text file. When the form appears, a Spanish word is presented with a definition below it. When I click anywhere on the form it goes away to appear again later. The form appears at any interval less than ten minutes, or whatever value I enter for that.
Spanish characters with accent marks do not display correctly. A label is being used to render. What is the best way to have it display properly. I haven't done localization or other languages in a desktop application, only web. I only want to change the one label if possible. Thanks

I found the answer at http://www.vbforums.com/showthread.php?655592-RESOLVED-Extended-ASCII-characters-in-Stream-I-O and used the following code:
Private Const ISO_8859_1 As Integer = 28591
Dim encoding As System.Text.Encoding = System.Text.Encoding.GetEncoding(ISO_8859_1)
reader = New IO.StreamReader(file_name, encoding)
It was removing the high order bit when reading the file. Labels render everything in the extended ascii set without issue.

Related

How to detect visible text in a text field in a PDF?

When using PDFBox to populate a text field in a form in a PDF, it is possible that the text overflows the text field and is not visible when opening the PDF in a viewer.
Question: Is it possible to use PDFBox to detect how much text within a text field is visible?
At the risk of falling victim to an XY problem, here is the context in which this came up.
I have a PDF which is provided by the Danish government, and the software I am creating needs to be able to fill out this form programmatically. On pages 5 and 6 of this document, there is a large blank area that needs to be filled out. The way the PDF creators designed it, they just made two text fields (named Text57 and Text58), which a person directly filling out the form would manually need to jump between.
The problem is, I need to be able to populate these fields with text, and if the text is too large to fit in the first text field, then it needs to overflow into the second text field. However, I do not seem to have any way of actually detecting when the text overflows in the first text field.
One workaround which could be acceptable, would be if I could modify the document to remove the second text field, and just have the first text field span multiple pages, but while playing around in Acrobat, this does not seem to be possible.
The PDF in question can be found here: https://www.trafikstyrelsen.dk/~/media/Dokumenter/10%20Bolig/Bolig/Private%20lejeboliger/Lejekontrakt/typeformular-a.pdf
Here is a code snippet which populates the problematic field with 100 lines numbered from 1 to 100.
PDDocument document = PDDocument.load(new File("typeformular-a.pdf"));
PDField text57 = document.getDocumentCatalog().getAcroForm().getField("Text57");
text57.setValue(IntStream.range(1, 101).mapToObj(Integer::toString)
.collect(Collectors.joining(System.lineSeparator())));
document.save("typeformular-a.out.pdf");
After the code is run, we can see that the text gets cut off after line 44. Of course I cannot simply count lines in my text, because under normal circumstances the lines in the text will wrap, which would invalidate that approach.
Auxiliary question: Is there any other approach that could solve this original problem of splitting text across multiple pages?

Missing presentation forms (glyphs) of some arabic characters in Unicode

I am working on a code that generates PDF containing arabic texts. For each character, I am choosing the correct glyph in the presentation forms to display the text correctly. This works fine but Unicode doesn't contain presentation form of all arabic characters.
For example \u067D ARABIC LETTER TEH WITH THREE DOTS ABOVE DOWNWARDS ٽ. There is no presentation form of this character even though the character has medial form, as can be seen in this string: لٽط
What is the reason that presentation forms of this and other characters are missing?
Is the character not used in practice?
Can the simple ARABIC LETTER TEH, which contains only one dot above and has presentation forms, be used instead?
Or is it necessary to somehow build this character (e.g. by using \uFBB6 THREE DOTS ABOVE character)?
The Arabic presentation forms should never be used for writing text. They exist only because they were needed for compatibility with older standards long ago. As such, there aren’t presentation forms for all Arabic letters in Unicode, only those necessary for this specific purpose. Many letters were also added long after the presentation forms ceased being relevant altogether. See the FAQ on Arabic for more information.
Arabic text should always be entered and stored using the regular letters (from the blocks Arabic, Arabic Supplement, and Arabic Extended-A). These letters will then automatically assume the correct shape depending on where they are situated in the word (initial, medial, or final) as can be seen in the example string you provided.
Using the character U+FBB6 ﮶ ARABIC SYMBOL THREE DOTS ABOVE would not be appropriate in this context because it is not a combining mark. It isn’t used to build new characters, but to talk about the symbol itself in isolation. From the code chart for Arabic Presentation Forms-A:
These are spacing symbols representing Arabic letter diacritics
considered in isolation, as for example as in discussions about the
Arabic script.
If the software you are using does not handle Arabic letter joining correctly, then there simply is no Unicode-defined way to enter the medial form of ٽ in your document. You will either have to switch to another framework entirely, or (as a last resort) encode the contextual forms you need as private-use characters in a new font, but I strongly recommend against that solution.

Forcing screen-reader read alt-text on a text element when creating a PDF in iText7

Is there any way to add alt text to a text element in iText? I have seen there is a way to do it for images. Basically, I would like the screen reader to read something besides the actual text that is being displayed. There are two situations in my document that I would need to do this.
One is when the screen-reader is reading an acronym I would like the alt-text to force the screen reader to read each letter instead of trying to read a word. (ie read DIET as D-I-E-T instead of diet)
The second is when it is reading a phone number I would like it to read outloud "phone" before the number. In the document it is currently just the number which would be a little confusing for disabled users. I am unable to actually change the layout to include the word "phone" for non-technical reasons.
There is a method for that.
new Paragraph("Lorem").getAccessibilityProperties().setActualText("Ipsum")
You can call this method on every class that implements IAccessibleElement.

vb.net, label or textbox right-aligned

OK, here's a problem i have. Searching the net did not help much.
In VB.net, you can right-align the text on a label. The label however has automatic word-wrap capabilities so it seems impossible to display a text in the label (of constant size) and always view the last part of the text.
I'm placing a folder name in the label and i'm always interested in seeing the last part of the text. As is now, if the path name is too large, i keep seeing the i.e. "C:\Documents and Settings" part, which i don't care to see. In VB6 when you right-align the text in a label, it displays the last part and if the text doesn't fit, it just cuts the text at the beginning. In VB.NET if the text is too large to fit in the label, word-wrap kicks in so you end up seeing the first part of the text only.
When using a textbox, even if it's right-aligned, if the text doesn't fit it just shows as much as possible from the START of the text (instead of from the END since it's right-aligned.)
Is there a way to achieve a similar behavior in VB.NET as in VB6's label?

Simulate printing in ZPL

Is it possible to try a Windows Mobile application made with ZPL without an actual printer? Like simulate the printing?
Also, is there any site/videoes/books about Zebra Programming Language for beginners?
I'm learning ZPL from here: it's provided by Zebra Website. I think it's very helpfull.
If you want simulate the printing, you can use labelary.
Have a look at my question and answer on PrintPage PrintPageEventHandler Is Printing Too Many Copies.
My issue was printing from a Windows Form, but you could do the same thing with Windows Mobile.
What you do is create a dummy Form with the same proportions as the document you want to print. Set labels all around with what you want them to say. Some fields will need to be INPUT fields so that your Windows Mobile app can call them and fill in those values.
For example, if you had a customer address you needed to set, the label on your dummy Form would be lblCustomerStreet, lblCustomerCity, lblCustomerState, and lblCustomerZip with public properties:
public string CustomerStreet {
get { return lblCustomerStreet.Text; }
set { lblCustomerStreet.Text = value; }
}
When you need to print, you make a ratio of your Form's size to the PrintDocument's Page Size. You use that ratio to either increase or decrease the size of the label so that the text fits on the page.
It does take some time to do, and there is a lot of trial and error involved.
However, the question and answer I posted up at the top will get you about 80% of the way. You would only be interested in focusing on the Document_Printed section of my code.
My example code included sizing for Panel controls, Label controls, one Image control (company logo), as well as a custom Barcode control that you can delete. The Image is printed first, then the Panels, then Labels, and finally the Barcode - because in my printout, the Barcodes are the most important, and the text on the labels is more important than the box lines made by the Panels. Panels just make your printout look pretty.