How can I convert excel to PDF by Libreoffice and keep all format from excel file? - pdf

Currently, I can covert from excel to pdf by command line, but I have problem about front after convert. In excel file I used Times new roman font, but after convert to pdf I found the font in PDF file is different with it. Please help me how can I fix this problem.
P/s: My excel file in Japanese language, and I'm using Libreoffice 5.0 and centos 7

As said in the comments already "Times New Roman" font has not any Japanese glyphs. So Excel will using glyphs from supplement fonts "Yu Gothic" or "Meiryo" or "Arial Unicode MS" depending of the Windows System. So you possibly will see "Times New Roman" as font in Excel's GUI but the glyphs cannot be from that font.
First of all the system which shall create a PDF from the Excel file must have a font containing appropriate Japanese glyphs. The system is in your case the CentOS Linux Distribution. So at first do # yum groupinstall "Japanese Support" as described in How to Install Asian Fonts on Red Hat & CentOS Linux Distributions.
And while converting using Libreoffice the supplement font used for Japanese characters will also be dependent on Libreoffice option settings. As far as I know there is not a directly possibility to set the font used. But dependent on the settings in
Tools - Options - Language Settings - Language - Default Language for Documents - [x] Asian: ...
different supplement fonts will be used.
For me for example, using Libreoffice 5.1.4.2 on Ubuntu Linux,
while "Chinese (simplified)" is set the font "Noto Sans CJK SC Regular" will be used,
but while "Japanese" is set the font "TakaoPGothic" will be used.
This settings also are influencing the command line
axel#arichter:~$ soffice --headless --convert-to pdf JapaneseExcel.xlsx
if not set "[ ] For the current document only".
So you could try different settings there.
To set the above options without GUI you must edit the file
/home/<user name>/.config/libreoffice/4/user/registrymodifications.xcu
where <user name> is the name of the user which then will run the soffice command line.
In this file find the line:
<item oor:path="/org.openoffice.Office.Common/I18N/CJK"><prop oor:name="AsianTypography" oor:op="fuse"><value>true</value></prop></item>
There the value must be set true. This will set the check-box [x] Asian.
Now find the line:
<item oor:path="/org.openoffice.Office.Linguistic/General"><prop oor:name="DefaultLocale_CJK" oor:op="fuse"><value>ja-JP</value></prop></item>
The value ja-JP there sets the locale Japanese.
Now save the file /home/<user name>/.config/libreoffice/4/user/registrymodifications.xcu.
Supplement:
As far as I see from your screen-shots, there are only Japanese characters in the whole sheet. So why using "Times New Roman" font at all? Why not using font "Yu Gothic" or "Meiryo" or "MS Mincho" for all cells? If so, this font setting will be stored in Excel's cell style settings and maybe then Libreoffice will using a font which is more similar to those. This I would try next if my first suggestion does not lead to a satisfying result.

Related

There's any font that doesn't change text len

I need a font that have the same len no matter if the line contains all 1111 or 8888.
Now I'm using the default VB.NET 2010 font and two lines with the same amount of characters have different len.
Any monospace font will do: https://en.wikipedia.org/wiki/Monospaced_font
I personally use Consolas because that is also the default font family used by Visual Studio in the code editor: https://en.wikipedia.org/wiki/Consolas
The easiest way to set the font is via the form's designer: https://learn.microsoft.com/en-us/dotnet/api/system.windows.forms.control.font

VBA in Word: CopyAsPicture method ignores text size as well as some font faces

The CopyAsPicture method in VBA in Word (I am using Word 2010 and 2016) is to transform a given piece of text (some string selected in the document) into a picture.
Microsoft provides this sample script in its tutorials:
Sub CopyPasteAsPicture()
'Origin: https://learn.microsoft.com/en-us/office/vba/api/word.selection.copyaspicture
ActiveDocument.Content.Select
With Selection
.CopyAsPicture
.Collapse Direction:=wdCollapseEnd
.PasteSpecial DataType:=wdPasteMetafilePicture
End With
End Sub
For testing the CopyAsPicture method I used however the following script which I found in a related question in this forum:
Sub CopySelPasteAsPicture()
' Take a picture of a selection and paste it at the document end
' Source: https://stackoverflow.com/questions/8888145/convert-text-to-image-in-microsoft-word
With Selection
.CopyAsPicture
End With
ActiveDocument.Content.Select
With Selection
.Collapse Direction:=wdCollapseEnd
.TypeParagraph
.TypeParagraph
.PasteSpecial DataType:=wdPasteMetafilePicture
End With
End Sub
I tested this but I find two problems with it:
1) Text size is ignored. Text sized, say, 28 pt will be rendered in the resulting picture as 12 pt or something like that
2) Not all font faces get recognized. I have some special fonts (both in otf and ttf) that I want to picturize that way. These fonts are ignored, and instead I get a picture of a standard font (Times New Roman or whatever).
I do not find help for these issues in Microsoft's VBA documentation.
Additional information:
1) Why do I want to do this? I use some rare fonts that people do not have usually, and including them into the .docx also does not work reliably. I have to share these documents with colleagues, and they should be able to see also the characters from the special fonts.
2) Picture generation works with cyrillic characters in standard fonts. That's good so far.
3) Picture generation also works with fonts that have cliparts instead of pictures (such special fonts are used e.g. for childrens books or textbooks for people to train reading and writing)
4) The font that in my case does not get picturized (but replaced by pictures of some standard system font) is a font I got as .otf, but I transformed it to .ttf (because I thought I could then include into the documents, but this did not work either). - I did so far not test if it would work with the original otf, but I doubt it because there was so far no problem with ttf versus otf fonts.
Question:
I would like to understand why font size and some font faces are ignored.
Of course, ideas how to solve this are also welcome.
.PasteSpecial DataType:=wdPasteMetafilePicture
A metafile picture is meant to retain font data. So when the document is opened on a device that doesn't have that font Word will follow its font substitution rules. I also vaguely recall that there is a font related bug in the metafile format.
I suggest that you play with the other paste data types and see what works best for you.

VBA to change Visio font style by font name instead of font index?

I'm hoping to use VBA to change the font style of the texts in shapes(from Calibri to Verdana). Currently I have (a snippet of the code)
Visio.ActivePage.Shapes(1).Characters.CharProps(visCharacterFont) = 235#
235 is the font index for Verdana in my system. However, the font index is very unstable and can change on different computers. Is there a way to change the font style by font name instead, e.g. ...="Verdana"? It's possible in excel, but I couldn't find similar syntax in Visio. Thanks in advance!
You can check what is ID for Verdana font on current PC
Dim Verdana_ID As Integer
Verdana_ID = ActiveDocument.Fonts.Item("Verdana").ID
And after this step set this ID as character's font
Visio.ActivePage.Shapes(1).Characters.CharProps(visCharacterFont) = Verdana_ID

The arabic letter not displaying correctly using aero report in openerp v7

I'm making a new report in openerp v7, from OpenOffice using aero report.
when i choose pdf as output, the report not displaying arabic letter correctly
if i choose odt they displaying correctly
My problem is , how can i displaying arabic letter correctly, using aero report, Thank in advance!
You issue is font setting. Please correct below settings:
Set NLS_LANG=ARABIC_EGYPT.AR8MSWIN1256 (or AR8ISO8859P6 on UNIX).
Set REPORTS_PATH to the font directory in which the TrueType font exists. For example, C:\WINNT\fonts.
Open the uifont.ali file and edit the [PDF:Subset] section to specify the TrueType font name.
[PDF:Subset]
"Andale Duospace WT J" = "Aduoj.ttf"
"Albany WT J"="AlbanWTJ.ttf"
Also for reference please use the below documentation:
Using PDF in Oracle Reports

Microsoft Word: Change Font of Characters Missing In Default Font

I am trying to use VBA in Microsoft Word to automatize highly repetative operations on large documents.
The situation is this: I have a technical text containing a lot of special characters, e.g. ❨ (U+2768) and ❩ (U+2769). The text is chiefly typeset in Cambria, but some of the special characters are not found in this font. However, I do know for a fact, that all characters used in the document are present in DejaVu Sans Mono. Hence, I would like all characters to be in Cambria except for those that cannot be displayed in this font -- those characters I want displayed in DejaVu Sans Mono.
In Microsoft Word 2007, I could easily achieve this by Ctrl+A, set font to DejaVu Sans Mono, set font to Cambria. The second change of font would only change the font of those characters that can be displayed in Cambria.
However, in Microsoft Word 2010, this apparently does not work. Every single character gets the font Cambria, and instead of displaying the characters not found in Cambria, the boxed question mark symbol is displayed.
To overcome this, I have turned to VBA. It is very easy to change the font of a given character, e.g.
Selection.Find.ClearFormatting
Selection.Find.Replacement.ClearFormatting
Selection.Find.Text = ChrW(10088)
Selection.Find.Replacement.Text = ChrW(10088)
Selection.Find.Replacement.Font.Name = "DejaVu Sans Mono"
Selection.Find.Execute Replace:=wdReplaceAll
However, it is not exceedingly fun to write the above code for each and every character in (C(DejaVu) ∖ C(Cambria)) ∩ C(Doc) where C(DejaVu), C(Cambria), and C(Doc) is the set of all characters in DejaVu Sans Mono, Cambria, and my document, respectively.
Is there any (reasonably simple) way to accomplish this automatically? Surely Microsoft Word knows which characters are found in Cambria and which are not. I want all instances of those characters that are not found in Cambria, to be given the font DejaVu Sans Mono.
I think this answer will help you achieve your goal: Script for changing fonts in a Word document