Loosing Original Font while Converting Word to PDF

Hi,
I am Converting a Word file(contains font “Royal Arabic”.) to PDF.
The Output PDF file have different font.
I am using aspose-words-19.4-jdk17.
and using this code

    FileInputStream fstream = new FileInputStream("D:/workspaces/PSD2020/PSD/WEB-INF/" + 
    "Aspose.Total.Product.Family.lic");
	com.aspose.words.License licence=new com.aspose.words.License();
	licence.setLicense(fstream);
	
    com.aspose.words.Document wordDocument 	= new 
   com.aspose.words.Document("C:\\Users\\CTC18\\Desktop\\testDoc.docx");
	
	wordDocument.save("C:\\Users\\CTC18\\Desktop\\outPutPdf2.pdf");

You can check doc file and output PDF file here Samplefiles.zip (46.5 KB)

@mukhan12,

Please try the code from the following article and see how it goes on your end?

Enable OpenType Features

In case the problem still remains, then please also ZIP and attach the following Font file here for further testing:

  • Royal Arabic

In this Enable OpenType Features example I am getting compilation error on this line

doc.getLayoutOptions().setTextShaperFactory(com.aspose.words.shaping.harfbuzz.HarfBuzzTextShaperFactory.getInstance());

No such method “setTextShaperFactory” available there .
And also “com.aspose.words.shaping.harfbuzz” no such package in aspose words.
Please check this.
I am using aspose-words-19.4-jdk17.jar.

Also Royal Arabic font is attached.
Royal Arabic Regular.zip (32.4 KB)

@mukhan12,

You need to upgrade to the latest version of Aspose.Words for Java to be able to use Text Shaping Harfbuzz features. I have installed the font and then used the following simple code to convert ‘testDoc.docx’ to PDF format on my end (see awjava-20.11-after installing font.pdf (17.6 KB)).

Document doc = new Document("C:\\Temp\\SampleFiles\\testDoc.docx");
doc.save("C:\\Temp\\SampleFiles\\awjava-20.11.pdf");

I can spot a problem (see problem.png (17.0 KB)) and logged it in our issue tracking system with ID WORDSNET-21497. We will further look into the details of this problem and will keep you updated on the status of correction. We apologize for your inconvenience.

Can you send me please the sample code that you used and the latest version of Aspose.words that you used.
As I downloaded from here Aspose.Words | Java Library to Process Document Formats
It is still giving me compilation error.
doc.getLayoutOptions().setTextShaperFactory(com.aspose.words.shaping.harfbuzz.HarfBuzzTextShaperFactory.getInstance());

this method “setTextShaperFactory” is available there now .
But “com.aspose.words.shaping.harfbuzz” no such package in aspose words.

@mukhan12,

Please download “aspose-words-20.11-shaping-harfbuzz-plugin.jar” from the following link and add this library in your project.

https://repository.aspose.com/repo/com/aspose/aspose-words/20.11/

Getting this result
outPutPdf2.pdf (45.8 KB)

May be I don’t have latest license, can you give me trail version license Please.

@mukhan12,

The issue still remains even when using the licensed latest version of Aspose.Words. To address this problem of square boxes in PDF, we have logged a separate issue with ID WORDSNET-21515. (see 20.11-HarfBuzz.pdf (11.1 KB))

If you want to test ‘Aspose.Words for Java’ without the evaluation version limitations, then you can also request a 30-day Temporary License. Please refer to How to get a Temporary License?

But How it is working for you in the sample you sent me before? while I am getting the square boxes.

And can you please give me any idea that how much time it will take to get response from developers team on logged issues?
WORDSNET-21497
WORDSNET-21515

@mukhan12,

WORDSNET-21497 and WORDSNET-21515 are currently pending for analysis and are in the queue. We will inform you via this forum thread as soon as these issues will get resolved in future. We apologize for any inconvenience.

Dear Support Team,

We are waiting for your reply on this ticket.

And also we need to add an other Font ‘Fanan Font’ Fanan.zip (30.6 KB)

Same issue, we are facing with this font also.
Please see the out put pdf file. outPutPdf2.pdf (47.1 KB)

I used this code

                       FileInputStream fstream = new 
               FileInputStream("C:/Users/muk/Desktop/Aspose/AsposeTempLicense22-12-2020/" + 
		    "Aspose.Total.Java.lic");
			com.aspose.words.License licence=new com.aspose.words.License();
			licence.setLicense(fstream);
			
		    com.aspose.words.Document doc 	= new 
		   
   com.aspose.words.Document("C:/Users/muk/Desktop/Aspose/Fananfont/fananFontDoc.docx");
    doc.getLayoutOptions().setTextShaperFactory(com.aspose.words.
    shaping.harfbuzz.HarfBuzzTextShaperFactory.getInstance());
	    // Render the document to PDF format
	  doc.save("C:/Users/muk/Desktop/Aspose/Fananfont/outPutPdf2.pdf");

@mukhan12,

I am afraid, your issues are pending for analysis and are in the queue. We will inform you via this forum thread as soon as linked issues will get resolved in future. We apologize for any inconvenience.

Please also ZIP and upload corresponding Word document here for further testing.

Hi Awais,

Please find the attachment. FananFont-TestFiles.zip (39.3 KB)
It contains both word and pdf file.

@mukhan12,

Aspose.Words currently inserts garbage square boxes in PDF when using the following line:

doc.getLayoutOptions().setTextShaperFactory(com.aspose.words.shaping.harfbuzz.HarfBuzzTextShaperFactory.getInstance());

To address problem related to this particular document (fananFontDoc.docx) and font (Fanan), we have logged a separate ticket with ID WORDSNET-21586.

Sorry for any inconvenience.

The issues you have found earlier (filed as WORDSNET-21515) have been fixed in this Aspose.Words for .NET 21.5 update and this Aspose.Words for Java 21.5 update.

The issues you have found earlier (filed as WORDSNET-21586) have been fixed in this Aspose.Words for .NET 21.5 update and this Aspose.Words for Java 21.5 update.

A post was split to a new topic: Font is chnaged while Converting Word to PDF