Font issue in postscript after printing on linux

Dear Aspose Team,


we are using Aspose.Words 15.7.0 for Java to print a docx document on linux.

To achieve that, we use the AsposeWordsPrintDocument together with an Aspose Document to hand it over into a java printjob.

In the resulting Postscript file, we observed the behavior, that for some Microsoft font types, the special characters are not displayed correctly. Of course we installed the related fonts as described in the Aspose documentation.

After serveral tests, it looks like there is a postscript file sent to the printer which already has the issue.
Therefore we assume, that the output of the AsposeWordsPrintDocument is also a postscript.

When we directly convert the document to Postscript, using Aspose.Words save functionality, the issue is not appearing. Also conversions into PDF and PNG are looking perfectly fine. These are done in the same application and the same system, using Aspose.Words save functionality.

So our conclusion is, that the AsposeWordsPrintDocument is related to the observed issues.

Also we converted the problematic resulting Postscript file to PDF using a ps2pdf tool.
On looking at the PDF, we found out, that the fonts, which do not have an issue, are included as images, whereas the fonts, which bring the issue, are embedded as fonts.
On Windows, all fonts are embedded in a correct way, if we convert the printed postscript to PDF.

We are suspecting the font encoding to produce the issues, but do not know, how to influence it.

Further observations:
- If we directly print other postscripts using the same printer, these are not having issues.
- If we setup a raw printer without a specific ppd file, which simply prints out the input data, we see, that it prints out the problematic postscript as well.

Please find attached a zip file, which contains the following:

- a Readme file, which explains how our printer setup is conducted on the Linux system (Suse Enterprise)
- the custom printer backend, that we use for our printer
- the ppd file for the printer we use
- a console java application, which wraps our used printing functionality with Aspose.Words
- input.docx, which is the input document
- result.ps which represents the resulting postscript file with the issue visible


Any information on how AsposeWordsPrintDocument is handling the Docx file for printing is much appreciated as well as any hint or workaround you can provide to solve the issue.

Also it would be very helpful to know, what causes the differences between the output on windows and linux, if we use the same coding.

Thank you very much in advance
Wolfgang




Hi Wolfgang,

Thanks for your inquiry. We are working over your query and will update you asap.

Hello Tahir,


Please also answer Wolfgang’s questions below.


Can you provide some detailed information about the AsposeWordsPrintDocument class. We assume that at least under Linux the output is already a Postscript. Can you (your developer team) confirm that? What is the difference of processing the documents using that class on Windows vs. on Linux. It seems that the output is different.
Is there an option to get in contact with the developer / architect directly?


Hi Wolfgang,

Thanks for your patience. AsposeWordsPrintDocument provides a default implementation for printing of a Document within the Java printing framework.

AsposeWordsPrintDocument overrides both java.awt.print.Printable and java.awt.print.Pageable.

A single Aspose.Words document can consist of multiple sections that specify pages with different sizes, orientation and paper trays. AsposeWordsPrintDocument should be used as java.awt.print.Pageable to properly print each of the different paper size, orientation, etc.

I have tested the scenario at Ubuntu with a shared printer (print files to PS) using latest version of Aspose.Words for Java 15.8.0 and have not found the shared issue. Please use Aspose.Words for Java 15.8.0. I have attached the output PS file with this post for your kind reference.

Chrons:

Can you provide some detailed information about the AsposeWordsPrintDocument class. We assume that at least under Linux the output is already a Postscript. Can you (your developer team) confirm that? What is the difference of processing the documents using that class on Windows vs. on Linux. It seems that the output is different.
Is there an option to get in contact with the developer / architect directly?

I am in communication about this query with our product team. We will update you asap.

Hi Tahir,


thanks for all the feedback.

We were now able to update the version of Aspose.Words to 15.8.0.

Still we are experiencing the same issue as described. Not sure, if the different linux version is doing it’s part.

Please let me know for anything else we should / can check in regards to the issue.



Thanks and kind regards
Wolfgang

Hi Wolfgang,

Thanks for your inquiry. Could you please use the following code example to generate the PS file and share it here for our reference?

Document doc = new Document(getMyDir() + “in.docx”);
AsposeWordsPrintDocument awPrintDoc = new AsposeWordsPrintDocument(doc);

DocFlavor flavor = DocFlavor.INPUT_STREAM.AUTOSENSE;
PrintRequestAttributeSet aset = new HashPrintRequestAttributeSet();
PrintService[] services = PrintServiceLookup.lookupPrintServices(flavor, null);
PrintService printService = null;

for (PrintService service : services) {
if (service.getName().equalsIgnoreCase(“HP Universal Printing PS”)) {
printService = service;
}
}

if (printService != null) {

URI printToFileURI <font color="BLUE" size="+1">=</font> <font color="BLUE" size="+1"><b>(</b></font>Paths<font color="BLUE" size="+1"><b>.</b></font>get<font color="BLUE" size="+1"><b>(</b></font>getMyDir<font color="BLUE" size="+1"><b>(</b></font><font color="BLUE" size="+1"><b>)</b></font> <font color="BLUE" size="+1">+</font> <font color="PURPLE">"awjava-15.8.0.ps"</font><font color="BLUE" size="+1"><b>)</b></font><font color="BLUE" size="+1"><b>.</b></font>toUri<font color="BLUE" size="+1"><b>(</b></font><font color="BLUE" size="+1"><b>)</b></font><font color="BLUE" size="+1"><b>)</b></font><font color="BLUE" size="+1"><b>;</b></font>
Destination ds <font color="BLUE" size="+1">=</font> <font color="RED"><b>new</b></font> Destination<font color="BLUE" size="+1"><b>(</b></font>printToFileURI<font color="BLUE" size="+1"><b>)</b></font><font color="BLUE" size="+1"><b>;</b></font>
aset<font color="BLUE" size="+1"><b>.</b></font>add<font color="BLUE" size="+1"><b>(</b></font>ds<font color="BLUE" size="+1"><b>)</b></font><font color="BLUE" size="+1"><b>;</b></font>

PrinterJob pj <font color="BLUE" size="+1">=</font> PrinterJob<font color="BLUE" size="+1"><b>.</b></font>getPrinterJob<font color="BLUE" size="+1"><b>(</b></font><font color="BLUE" size="+1"><b>)</b></font><font color="BLUE" size="+1"><b>;</b></font>
pj<font color="BLUE" size="+1"><b>.</b></font>setPrintService<font color="BLUE" size="+1"><b>(</b></font>printService<font color="BLUE" size="+1"><b>)</b></font><font color="BLUE" size="+1"><b>;</b></font>
pj<font color="BLUE" size="+1"><b>.</b></font>setPageable<font color="BLUE" size="+1"><b>(</b></font>awPrintDoc<font color="BLUE" size="+1"><b>)</b></font><font color="BLUE" size="+1"><b>;</b></font>

<font color="RED"><b>try</b></font> <font color="BLUE" size="+1"><b>{</b></font>
    pj<font color="BLUE" size="+1"><b>.</b></font>print<font color="BLUE" size="+1"><b>(</b></font>aset<font color="BLUE" size="+1"><b>)</b></font><font color="BLUE" size="+1"><b>;</b></font>
<font color="BLUE" size="+1"><b>}</b></font> <font color="RED"><b>catch</b></font> <font color="BLUE" size="+1"><b>(</b></font>Exception e<font color="BLUE" size="+1"><b>)</b></font> <font color="BLUE" size="+1"><b>{</b></font>
    System<font color="BLUE" size="+1"><b>.</b></font>out<font color="BLUE" size="+1"><b>.</b></font>println<font color="BLUE" size="+1"><b>(</b></font>e<font color="BLUE" size="+1"><b>.</b></font>getMessage<font color="BLUE" size="+1"><b>(</b></font><font color="BLUE" size="+1"><b>)</b></font> <font color="BLUE" size="+1">+</font> <font color="PURPLE">"____"</font> <font color="BLUE" size="+1">+</font> e<font color="BLUE" size="+1"><b>)</b></font><font color="BLUE" size="+1"><b>;</b></font>
<font color="BLUE" size="+1"><b>}</b></font>

}

1. We assume that at least under Linux the output is already a Postscript. Can you confirm that? Does Aspose.Words first create PS file and then print it?

While printing Aspose.Words doesn’t create any files itself either under Windows or Linux.

AsposeWordsPrintDocument is a wrapper which implements Printable, Pageable interfaces and relies on Java implementation and system drivers


i.e. AsposeWordsPrintDocument works with Java Printing API


PrinterJob pj = PrinterJob.getPrinterJob();

pj.setPrintService(printer);

pj.print(attributes); // attributes contains new Destination(“your_ps_file.ps”)



For more details please have a look at

https://docs.oracle.com/javase/tutorial/2d/printing/set.html

http://docs.oracle.com/javase/8/docs/api/javax/print/attribute/standard/Destination.html


2. What is the difference of processing the documents using that class on Windows vs. on Linux. It seems that the output is different.

As I said before there is no difference between Windows and Unix printing workflow (see Java Printing API). The output is different on different platforms because of Java and system drivers.


> When we directly convert the document to Postscript, using Aspose.Words save functionality, the issue is not appearing


Correct, in this case AW knows how to use fonts substitutions and handle known fonts issues. .

Since AW uses Java API Printing which in turn uses system drivers I can assume that if you installed missed fonts on Linux itself it would help to solve the issue. See e.g. ttf-mscorefonts-installer


Hi again,


thanks for the detailed feedback, also for the insights on the Aspose Printable Class.

So far, we are still not successful in our tests.

We used the coding, which was provided.
Also we recognized, that you suggest an “HP Universal PS Printer”, for what we cannot find a proper ppd file.

Are you able to provide such?

In regards to your question, if we installed the mstt-core-fonts -
yes, we have installed the msttcorefonts package to the linux system:

zypper se msttcorefonts
Loading repository data…
Reading installed packages…

S | Name | Summary | Type
–±--------------±--------------------------------±-------
i | msttcorefonts | TrueType core fonts for the web | package


The issue is only happening, if these fonts are embedded into the Postscript. Not if they are replaced by images.

Thanks and kind regards
Wolfgang

Hi Wolfgang,

Thanks for your feedback. There is a possibility that with Aspose.Words v15.9.0, this issue will not appear. Please wait for next version of Aspose.Words v15.9.0. We will inform you via this forum thread once new version of Aspose.Words will be available. Thanks for your patience.

Hi Tahir,


thanks for your answer!

We will then wait for the release of Aspose.Words 15.9.0,


Kind regards
Wolfgang

Hi again,


we retested the issue with Aspose.Words for Java version 15.9.0 and it still appears in the same way.


Kind regards
Wolfgang

Hi Wolfgang,

Thanks for your feedback. We have logged a task as WORDSJAVA-1168 for investigations. We will inform you via this forum thread once there is any update available on this issue.

Thanks for your patience.

Hi Wolfgang,

Thanks for the detail description of the problem.

We installed SUSE Linux Enterprise 11 (SP 4) from scratch and set up CUPS printing environment.
We run your demo and the output files look correct despite the "mscorefonts" is installed or not.

As I said before AsposeWordsDocument is just a wrapper which implements Pageable and Printable interfaces.
So it doesn't do anything special to create .PS files.

I think there are a few options you should check:

0. Install the latest Aspose.Words for Java version
1. Try to remove the "mscorefonts" package and check the results.
2. Try to install native Windows' fonts.
3. As a workaround you can run Document.save("file.ps") and let Aspose.Words create .PS file for you.

Please let us know if it helps or not.

Hello Vyacheslav Durin,


thanks for your feedback.

I will try the proposed solutions.


Kind regards
Wolfgang

Hi Wolfgang,


Please let us know whether it helped or not.

Thanks.

Hi,


sorry for the delay in my reponse - I was on vacation.

The issue is now solved for us - thanks for all the hints that helped resolving it!


Kind regards
Wolfgang

The issues you have found earlier (filed as WORDSJAVA-1168) have been fixed in this .NET update and this Java update.


This message was posted using Notification2Forum from Downloads module by aspose.notifier.