Hyphens are Converted to Solid Line after TXT to PDF Conversion using Java

I am using aspose-words java (version 21.5) to convert a text file to pdf. The text file contains some hyphens. When this file is converted to pdf, some lines with hyphens are printed as a horizontal line(instead of hyphens) in the pdf. Also some lines with hyphens are not printed in pdf.

hypen-query.7z (26.1 KB)

I also tried to convert the same text file with the following groupdocs online converter which resulted in same result.

Could you help me resolve this issue.?



We have tested the scenario and have managed to reproduce the same issue at our side. For the sake of correction, we have logged this problem in our issue tracking system as WORDSNET-22230. You will be notified via this forum thread once this issue is resolved.

We apologize for your inconvenience.

1 Like


We have closed the issue WORDSNET-22230 as ‘Not a Bug’. The document has valid Markdown format. It has 2 Headers, 2 List items and 6 Horizontal Rules in its 169 bytes. So, it is recognized as Markdown but not just TXT.

Please use following code example to get the desired output.

Document doc = new Document(MyDir + "hypen-check.txt", new LoadOptions(LoadFormat.Text, null, null));
doc.Save(MyDir + "21.5.pdf");


I have used LoadOptions to load text and convert it to pdf. But some Japanese contents are not converted. I have used warning callback to log any font substitution. But in log I could not find any substitution info. I have used the following code to convert txt to pdf.

Document document = new Document(gZIPInputStream, new com.aspose.words.LoadOptions(com.aspose.words.LoadFormat.TEXT, null, null));
WordsFontWarning warning = new WordsFontWarning(); //<-- my warning callback class
document.save(outputStream, SaveFormat.PDF);

ja-text-issue.7z (91.9 KB)


Please use the value of LoadOptions.Encoding property as UTF8 to get the desired output. Hope this helps you.

LoadOptions options = new LoadOptions();
options.LoadFormat = LoadFormat.Text;
options.Encoding = Encoding.UTF8;
Document doc = new Document(MyDir + "sample-ja-text.txt", options);
doc.Save(MyDir + "21.5.pdf");