Using custom fonts (non-MS Office) for Word VBA - vba

I have installed some custom Asian fonts in the Windows/Fonts folder. I am writing a code that reads some item names (just a plain string, ABC, but in Japanese) from MS-Excel cells, then pastes them in a text box in a new MS-Word document. The problem is that I can't use my custom fonts (these are TTF files) to format the text in MS-Word.
I tried to name the font with .ttf in the end, besides simply referring to its name as it appears in the drop-down menu in MS-Word.
Wrd_Doc.Shapes("shpTwo").TextFrame.TextRange.Font.Name = "ShigotoMemogaki Regular"
It refers to a text box named shpTwo. I pasted some text there and I want it to look like this custom font, named ShigotoMemogaki Regular. This font is saved in my Fonts folder, it works in MS-Word when I use it, but somehow the code does not recognize it, and instead, it uses the default Office Asian font, which is MSMincho.
So the text is clearly copied from MS-Excel, it is in the newly created text box in a new Word document, but it's not in the font I need.

Related

Text changed to graphics, still selectable in PDF?

I have this PDF ebook with selectable text - the handwriting - but there is no such font embedded and the letters are all different, so it's not actually a font. How is this possible?
I've worked with CorelDraw and Adobe Acrobat, but I can't understand how this works.
The left side of the picture shows the document properties, the right side shows a page of the PDF file and I selected the last 3 rows. I can copy and paste that to a text file, no problem. How was this achieved?
There are a few possibilities but the most likely is the text is being converted to outlines/paths or vectors. Some software such as Adobe InDesign and other print design apps allow you to 'flatten' a font based text into vector or paths, meaning the original font isn't required to be embedded or installed on the system. The original text data is however still present and able to be copied into a text field or word processor.

How to bold a text in PDF?

I'm developing a new function to "my" program. This function is able to write PDF files by the simple way, making a simple text file with some codes of PDF standard.
I'm trying to understand how it works yet, but my first problem is about how to apply bold on some line of my document.
I've already downloaded the PDF REFERENCES GUIDE, but I've not found nothing about it.
Any idea?
PDF is not like HTML where you can apply formatting tags for emphasis. As you've read in the PDF reference, all that you do in PDF is to setup a graphics environment (colours used, fonts used, etc) and then put text on the page.
If you want to have something show in bold, use a font that is bold. If you want to have something show in italic, use a font that is italic.
Older software used dirty tricks to create "bold-alike" text, but the good (and easy) way to do it is to make sure you select the correct font before you start drawing text.

How to preserve text formatting in RichTextBox like Bold, Italics, font color, font size, etc?

I have created an application and for that application, I have designed a help file in Microsoft word. The help file is too long. So I decided to use the RichTextBox control in vb.net. I copied all the content from the word file. Now, I need to preserve the text formatting I have done in the actual file (like bold, italics, etc).
How can I preserve the text formatting?
Is there any other way I can display the help file in vb.net with properly formatted text?
RichTextBox supports rtf content, you can't directly paste the Word content in your RichTextBox .
You need to convert the word document into .rtf file. Best way is to
use the save As dialog in Microsoft Word.
Then you could deploy the document with your application and then load rtf content in your RichTextBox using LoadFile method.
RichTextBox1.LoadFile("Help-File.rtf")
Obviously, it supposes that basic formatting like mentioned in title (Bold, Italics, font color, font size, ...) are enough for this purpose, since the rft format does not support all MS Word features.
Otherwise you may have to implement your own parse/interpretation logic.
Here is how I did it:
I converted the word document int rtf format using the save as dialog box in microsoft word. Then copied the file named "help-file.rtf" into the executable folder (the executable is generally present within the debug or Release folder).
Copy the file in rtf format to the application executable folder and then use the following function:
RichTextBox1.LoadFile("Help-File.rtf")
Here, RichTextBox1 is the name of the RichTextBox control. Use the function above to load the file into the RichTextBox control.

Apache POI - Word Files

I have been successfully able to read a word document containing images usiong POI.
I have even be able to extract a section from Word document including the images.
I am writing the extracted portion containg images to a new word document.
My problem is that I have to display this extracted portion (containing text, fonts, colors images) on the screen using any standard Java Swing component.
Please advise how can I do that?
I tried JText, Panel, editor but all would take only text and I loose my formatting and images.
Regards

Programmatically replace text in PDF

I have PDF files with text that should be replaced. More specificly, the text should be translated and replaced with the translated version.
It's important that the rest of the PDF structure stays intact. Note that the text is available in the PDFs and techniques like OCr are not needed. Also, it would be nice if font and other text attributes are kept.
Which libraries would you recommend for extracting the text to an easy to edit format (such as CSV) and put the new text back in again?
Assuming you are replacing text with a different language, you will have to choose a different font in most cases, and the font choice is non-trivial. I've used the Foxit libraries to change text or create PDFs with success.