Problem with importing docx and doc
Problem with importing docx and doc
Hello support,
By TRVOfficeConverter1.ImportRV I import docx and doc files to RichViewEdit. The problem is that when the file name or file path directories name is Arabic word, it doesn't work and gets error. The TRVOfficeConverter1.ErrorCode is -1 .
Is there a way to solve this problem?
By TRVOfficeConverter1.ImportRV I import docx and doc files to RichViewEdit. The problem is that when the file name or file path directories name is Arabic word, it doesn't work and gets error. The TRVOfficeConverter1.ErrorCode is -1 .
Is there a way to solve this problem?
-
- Site Admin
- Posts: 17571
- Joined: Sat Aug 27, 2005 10:28 am
- Contact:
Re: Problem with importing docx and doc
Only by copying this file to a path and under a name that do not contain Arabic characters.
Converters accept paths in OEM (i.e. DOS) encoding. TRVOfficeConverter converts file names to OEM, but some characters cannot be converted.
In older days, probably the problem could be solved by converting paths to a short form, using GetShortPathName WinAPI function. However, when I
try this function on my own computer, it returns the same string as the original path, even if it is long and has Unicode characters.
So converters can load only files having only local characters in the file name.
Converters accept paths in OEM (i.e. DOS) encoding. TRVOfficeConverter converts file names to OEM, but some characters cannot be converted.
In older days, probably the problem could be solved by converting paths to a short form, using GetShortPathName WinAPI function. However, when I
try this function on my own computer, it returns the same string as the original path, even if it is long and has Unicode characters.
So converters can load only files having only local characters in the file name.
Re: Problem with importing docx and doc
Thanks for help.
I found a function that converts long file names to the 8.3 DOS format and it works correctly.
I found a function that converts long file names to the 8.3 DOS format and it works correctly.
Code: Select all
uses
Windows, SysUtils;
function GetShortName(sLongName: string): string;
var
sShortName : string;
nShortNameLen : integer;
begin
SetLength(sShortName, MAX_PATH);
nShortNameLen := GetShortPathName(
PChar(sLongName), PChar(sShortName), MAX_PATH - 1
);
if (0 = nShortNameLen) then
begin
// handle errors...
end;
SetLength(sShortName, nShortNameLen);
Result := sShortName;
end;
-
- Site Admin
- Posts: 17571
- Joined: Sat Aug 27, 2005 10:28 am
- Contact:
Re: Problem with importing docx and doc
Well, probably I should add it to RVOfficeConverter...
However, as I said, it does not help on my computer (Win10, NTFS): it simply returns sLongName.
But at least it does no harm.
However, as I said, it does not help on my computer (Win10, NTFS): it simply returns sLongName.
But at least it does no harm.
Re: Problem with importing docx and doc
Like your computer, My operating system is Win10 and my drives format is NTFS. but in my computer it works correctly. why?Sergey Tkachenko wrote: ↑Mon Sep 11, 2017 1:41 pm However, as I said, it does not help on my computer (Win10, NTFS): it simply returns sLongName.
-
- Site Admin
- Posts: 17571
- Joined: Sat Aug 27, 2005 10:28 am
- Contact:
Re: Problem with importing docx and doc
AFAIK, NTFS always supports short file names, but their creation for new files may be enabled or disabled.
You can check using the system command line utility fsutil:
It displays the value for the specified drive (c:):
0 - short file names are created,
1 - short file names are not created.
So some files may have short version of their names, some not.
I added conversion to short file names in TRVOfficeConverter, in the today's update for registered users.
You can check using the system command line utility fsutil:
Code: Select all
fsutil behavior query disable8dot3 c:
0 - short file names are created,
1 - short file names are not created.
So some files may have short version of their names, some not.
I added conversion to short file names in TRVOfficeConverter, in the today's update for registered users.
Re: Problem with importing docx and doc
2 questions:
1. why converters accept paths in OEM (i.e. DOS) encoding? Is there a convertor that does not use OEM encoding?
2. Some of my docx files are on my server that it's OS is Linux. Is it possible to enable short file name creation on Linux?
1. why converters accept paths in OEM (i.e. DOS) encoding? Is there a convertor that does not use OEM encoding?
2. Some of my docx files are on my server that it's OS is Linux. Is it possible to enable short file name creation on Linux?
-
- Site Admin
- Posts: 17571
- Joined: Sat Aug 27, 2005 10:28 am
- Contact:
Re: Problem with importing docx and doc
1) I do not know why. No, the converters specification states that file names must be in OEM.
2) I recommend not changing file system options, but simply writing a code in your application that copies the specified file to a temporal location under a simple name, loading this copy, deleting this copy.
2) I recommend not changing file system options, but simply writing a code in your application that copies the specified file to a temporal location under a simple name, loading this copy, deleting this copy.
Re: Problem with importing docx and doc
Thanks.Sergey Tkachenko wrote: ↑Thu Sep 14, 2017 10:36 am 1) I do not know why. No, the converters specification states that file names must be in OEM.
2) I recommend not changing file system options, but simply writing a code in your application that copies the specified file to a temporal location under a simple name, loading this copy, deleting this copy.
Importing some doc files (not all) gives an error. it's ErrorCode is 0. what does it mean?
Last edited by saeid2016 on Mon Sep 18, 2017 2:41 pm, edited 1 time in total.
Re: Problem with importing docx and doc
Please see my attached sample. When I import the Doc1.doc it gives error: Division by zero.
- Attachments
-
- TestRichView.rar
- (74.15 KiB) Downloaded 1573 times
-
- Site Admin
- Posts: 17571
- Joined: Sat Aug 27, 2005 10:28 am
- Contact:
Re: Problem with importing docx and doc
I cannot reproduce the problem.
Do you use the newest version of TRichView and ScaleRichView?
Do you use the newest version of TRichView and ScaleRichView?
Re: Problem with importing docx and doc
Importing some doc files (not all) gives an error. it's ErrorCode is 0. what does it mean?