Page 1 of 1

Problem with importing docx and doc

Posted: Mon Sep 11, 2017 10:47 am
by saeid2016
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?

Re: Problem with importing docx and doc

Posted: Mon Sep 11, 2017 12:32 pm
by Sergey Tkachenko
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.

Re: Problem with importing docx and doc

Posted: Mon Sep 11, 2017 1:03 pm
by saeid2016
Thanks for help.

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;

Re: Problem with importing docx and doc

Posted: Mon Sep 11, 2017 1:41 pm
by Sergey Tkachenko
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.

Re: Problem with importing docx and doc

Posted: Mon Sep 11, 2017 2:05 pm
by saeid2016
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.
Like your computer, My operating system is Win10 and my drives format is NTFS. but in my computer it works correctly. why?

Re: Problem with importing docx and doc

Posted: Mon Sep 11, 2017 4:39 pm
by Sergey Tkachenko
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:

Code: Select all

fsutil behavior query disable8dot3 c:
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.

Re: Problem with importing docx and doc

Posted: Thu Sep 14, 2017 10:02 am
by saeid2016
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?

Re: Problem with importing docx and doc

Posted: Thu Sep 14, 2017 10:36 am
by Sergey Tkachenko
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.

Re: Problem with importing docx and doc

Posted: Mon Sep 18, 2017 10:38 am
by saeid2016
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.
Thanks.

Importing some doc files (not all) gives an error. it's ErrorCode is 0. what does it mean?

Re: Problem with importing docx and doc

Posted: Mon Sep 18, 2017 11:52 am
by saeid2016
Please see my attached sample. When I import the Doc1.doc it gives error: Division by zero.

Re: Problem with importing docx and doc

Posted: Tue Sep 19, 2017 3:27 pm
by Sergey Tkachenko
I cannot reproduce the problem.
Do you use the newest version of TRichView and ScaleRichView?

Re: Problem with importing docx and doc

Posted: Sat Oct 07, 2017 1:48 pm
by saeid2016
Importing some doc files (not all) gives an error. it's ErrorCode is 0. what does it mean?