Change the PDF fonts encode

hi,

In the project, we used the Mapping Suite( http://www.mappingsuite.com/en/home/home-0001.html ) to convert the text file to PDF. Mapping Suite was suppored the Chinese, so we choice it. But we have the problem, the pdf font encode is ANSI, we have to use the Identity-H.

Is it possible to implement convert it by using Aspose Pdf?

scenario

Text -> pag(Mapping split file) -> XPS -> PDF

why not

Text -> pag -> PDF

because we use Chinese. In English, it’s ok.

Or do you have other solution? Thanks.

Hi Danny,


Thanks for your interest in our products.

Aspose.Pdf for Java supports the feature to convert Text files to PDF format and it also offers the capabilities to embed the fonts in resultant PDF files. Please visit the following link for required information on


In case you encounter any issues, please share the Text file so that we can test the scenario at our end.

Convert txt to pdf
I tried it, but the result is wrong at Chinese.

My text file encoding is UTF-8
then my code
BufferedReader reader = new BufferedReader(new InputStreamReader(new FileInputStream(dataDir + "1.txt"), "UTF-8"));

Hi Danny,


Thanks for contacting support.

When using Non-English text, you need to use the font which supports Non-English characters i.e. Arial Unicode MS. Please try using the following code snippet to generate the correct output. For your reference, I have also attached the resultant PDF generated with Aspose.Pdf for Java 4.5.0.

[Java]

StringBuffer sb = new
StringBuffer(1024);<o:p></o:p>

BufferedReader reader = new BufferedReader(new FileReader("c:/pdftest/1 (1).txt"));

int ch = -1;

while ((ch = reader.read()) > -1)

{

sb.append((char)ch);

}

reader.close();

// Instantiate Pdf object by calling its empty constructor

Pdf pdf1 = new Pdf();

// Create a new section in the Pdf object

Section sec1 = pdf1.getSections().add();

// Create a new text paragraph and pass the text to its constructor as argument

Text text1 = new Text(sec1, sb.toString());

text1.getTextInfo().setFontName("Arial Unicode MS");

sec1.getParagraphs().add(text1);

pdf1.setUnicode();

pdf1.save(“c:/pdftest/Text_File_to_PDF.pdf”);

i losed the ‘pdf1.setUnicode();’.

But It;s not support full Chinese.

in the attachments, it has three chinese words, but it only has two words in the pdf.

About this, you can look About Big-5E

Hi Danny,

Thanks for sharing the resource fie.

I have tested the scenario and I am able to notice the same problem. For the sake of correction, I have logged this problem as PDFNEWJAVA-33978 in our issue tracking system. We will further look into the details of this problem and will keep you updated on the status of correction. Please be patient and spare us little time. We are sorry for this inconvenience.

Is it possible to change the font encode?

Hi Danny,


We are sorry for the delayed response. We are looking into your requirements and will get back to you soon.

Best Regards,

Hi Danny,


We are sorry for the inconvenience caused. Currently Aspose.Pdf does not support to convert PDF fonts encoding. We have logged a feature request as PDFNEWJAVA-34128 for further investigation and implementation. We will keep you updated about the issue resolution progress.

Best Regards,

Hi Danny,


Thanks for your patience.

We have further investigated the issue PDFNEWJAVA-33978 reported earlier and have observed that the symbols present inside the source TXT file are not found in the Glyph table of standard fonts and also in the MSGothic font. Can you please share the Chinese font that has all the characters so that we can further investigate this problem.

@jiunting

Thank you for being patient.

We have investigated the ticket reported by you PDFJAVA-34128, formerly PDFNEWJAVA-34128, and would like to update you that we do not notice any problem during conversion of input TXT file to PDF document with Aspose.PDF for Java 18.6 in our environment. If you still face the problem with latest available version of the API then please elaborate the issue for our reference.