Insert Japanese text into document | Line breaking rule does not work in output PDF using C#

Hello, tried with the latest aspose version, but Japanese line breaking rules are still not working. Please suggest if any way to make this work? Or if any plans to support this in near future?

@samirIntertek

Could you please share some sample code snippet that you are using at your end. We will test the scenario in our environment and address it accordingly.

Hello,

Below is the code snippet, BuilderBodyContent function basically builds the content of the document which has japanese content, also attaching sample japanese content below the code. Also, link to the japanese line breaking rules: https://en.wikipedia.org/wiki/line_breaking_rules_in_east_asian_languages

public void ExportWord(string tempPath, string outPath, string fileName, ASRExportVM vm)
{
    //import license
    LicenseHelper.ImportWordsLincense();

    //load template file
    Document doc = new Document(tempPath);
    doc.CompatibilityOptions.UseAltKinsokuLineBreakRules = true;
    DocumentBuilder builder = new DocumentBuilder(doc);

    try
    {

        try
        {

            asrDataJson = vm.asrDataJson;

            //build document body
            BuilderBodyContent(builder, vm, true);
        }
        catch (Exception ex)
        {
            builder = null;
            throw ex;
        }

        outPath = @"D:\temp";

        if (!Directory.Exists(outPath))
        {
            Directory.CreateDirectory(outPath);
        }
        string path = HttpContext.Current.Server.MapPath("~/Temp/");
        path = Path.Combine(path, fileName);
        doc.Save(path, Aspose.Words.SaveFormat.Pdf);
    }

    catch (Exception ex)
    {
    }

    finally
    {
        builder = null;
        doc = null;
    }
}

Japanese content of the document:
これはすごく素敵。私すごく優しい。みんなとても素敵です。これはすごく素敵。私すごく優しい。みん((な))とても素(((敵)))で((())))。これはすごく素敵。私すごく優しい。みんなとても素敵です。これはすごく素敵。私すごく優しい。みんなとても素敵です。これはすごく素敵。私すごく優しい。みんなとても素敵です。これはすごく素敵。私すごく優しい。みんなとても素敵です。

thanks

@samirIntertek

We need following resources for testing. So, please ZIP and attach them for investigation.

  • Your input Word document.
  • Please attach the output file that shows the undesired behavior.
  • Please attach the expected output file that shows the desired behavior.
  • Please create a standalone console application ( source code without compilation errors ) that helps us to reproduce your problem on our end and attach it here for testing.

Thanks for your cooperation.

https://1drv.ms/u/s!aotx3f-psgqdias

Hello,

Created PoC (download from link above) standalone console application for your reference. Few points:

  1. Once you execute the app, word file named “output.docx” will be created in folder “PoC\bin\Debug"

  2. I have already tried the below compatibility options for Kinsoku Line breaks, but doesn’t work as desired with or without these options.

  3. If you run the attached app, the output file doesn’t follow the Japanese line break rules: https://en.wikipedia.org/wiki/Line_breaking_rules_in_East_Asian_languages
    For ex:

image.jpg (92.1 KB)
image.jpg (92.1 KB)

Thanks

Samir Shah

@samirIntertek

We are investigating this issue and will get back to you soon.

@samirIntertek

We have logged this problem in our issue tracking system as WORDSNET-21148 . You will be notified via this forum thread once this issue is resolved.

We apologize for your inconvenience.

Hi Tahir,
Any ETA on when this can be fixed?

@samirIntertek

We try our best to deal with every customer request in a timely fashion, we unfortunately cannot guarantee a delivery date to every customer issue. We work on issues on a first come, first served basis. We feel this is the fairest and most appropriate way to satisfy the needs of the majority of our customers.

At the moment, your issue is pending for analysis and is in the queue. Once we complete the analysis of your issue, we will then be able to provide you an estimate.

@samirIntertek

We have closed this issue (WORDSNET-21148) as ‘Not a Bug’.

For parenthesis issue, please note that your final output document should be PDF instead of DOCX. For DOCX document, there is no developed mechanism for Line breaking rules in East Asian languages.

Please note that the right parenthesis cannot open a new line. You can use “CompatibilityOptions.OptimizeFor(MsWordVersion.Word2010)” (or higher) to get the desired output.

DocumentBuilder builder = new DocumentBuilder();
builder.Writeln("これはすごく素敵。私すごく優しい。みんなとても素敵です。これはすごく)素))))))敵)。私す)ごく優しい。みん((な))とても素(((敵)))で((())))。これはすごく素敵。私すごく優しい) )。みんなとても素敵です。これはすごく素敵。私すごく優しい。みんなとても素敵で‐‐す。これはすごく素敵。私すごく優しい。みんなとても素敵です。これはすごく素敵? ?。私すごく優しい。みんなとても素敵です。");
builder.Document.CompatibilityOptions.OptimizeFor(MsWordVersion.Word2010); // or higher
builder.Document.Save(@"output.pdf");