Error generating preview file with Aspose on Linux server

Hi:

This code works on Windows:

// Save diagram as PNG
val options = ImageSaveOptions(SaveFileFormat.PNG)
options.pageIndex = 0
previewFile.outputStream().use { outputStream ->
document.save(outputStream, options)
}

But on Linux I get this error:

ERROR 2019-01-24 10:15:35,864 [.p6diagram.web.shims.CallableFactoryImpl: 107] | Thread-3 | {} | Error generating diagram
java.lang.IllegalStateException: Cannot find resource {0}.
at com.aspose.diagram.a.c.q.a(Unknown Source)
at com.aspose.diagram.a.d.ba.i(Unknown Source)
at com.aspose.diagram.a.d.ba.g(Unknown Source)
at com.aspose.diagram.a.d.ba.d(Unknown Source)
at com.aspose.diagram.a.d.bc.a(Unknown Source)
at com.aspose.diagram.a.d.bc.a(Unknown Source)
at com.aspose.diagram.a.d.bc.a(Unknown Source)
at com.aspose.diagram.mb.(Unknown Source)
at com.aspose.diagram.fn.a(Unknown Source)
at com.aspose.diagram.fn.b(Unknown Source)
at com.aspose.diagram.fn.a(Unknown Source)
at com.aspose.diagram.fn.a(Unknown Source)
at com.aspose.diagram.om.a(Unknown Source)
at com.aspose.diagram.om.a(Unknown Source)
at com.aspose.diagram.Diagram.a(Unknown Source)
at com.aspose.diagram.Diagram.save(Unknown Source)
at com.emerald_associates.p6diagram.engine.diagram_writer.visio.aspose.AsposeEngine.savePngPreviewFile(AsposeEngine.kt:142)
at com.emerald_associates.p6diagram.engine.diagram_writer.visio.aspose.AsposeEngine.savePngPreviewFile(AsposeEngine.kt:41)
at com.emerald_associates.p6diagram.engine.diagram_writer.visio.engines.gantt.GanttChartDiagramEngine.generateDiagram(GanttChartDiagramEngine.kt:59
)
at com.emerald_associates.p6diagram.engine.DiagramGeneratorShim.generateDiagram(DiagramGeneratorShim.kt:89)
at com.emerald_associates.p6diagram.web.shims.CallableFactoryImpl$CloudApiToVisio.call(CallableFactoryImpl.kt:90)
at com.emerald_associates.p6diagram.web.shims.CallableFactoryImpl$CloudApiToVisio.call(CallableFactoryImpl.kt:71)
at com.emerald_associates.async_tasks.TaskEntry.call(TaskEntry.java:144)
at com.emerald_associates.async_tasks.TaskManagerImpl.runTask(TaskManagerImpl.java:196)
at com.emerald_associates.async_tasks.TaskManagerImpl.access$500(TaskManagerImpl.java:34)
at com.emerald_associates.async_tasks.TaskManagerImpl$ExecutorThread.run(TaskManagerImpl.java:231)

There are two problems:

  • the code is failing
  • the exception message is badly formatted

Can you help me with this issue?

I think this is the resource it is looking for:

Aspose.Diagram.GenBasR.ttf

@raviaw

Thanks for contacting support.

Could you please share your sample VISIO Diagram with us. We will test the scenario in our environment and address it accordingly.

Hi:

This is the sample code:

public static void main( String[] args ) throws Exception
{
    final License license = new License();
    final File licenseFile = new File( "user-data/visio-files/Aspose.Diagram.lic" );
    try( final InputStream is = new FileInputStream( licenseFile ) ) {
        license.setLicense( is );
    }

    final Diagram diagram;
    final File diagramFile = new File( "user-data/aspose-tickets/preview.vsdx" );
    try( final InputStream is = new FileInputStream( diagramFile ) ) {
        diagram = new Diagram( is );
    }

    final File pictureFile = new File( "user-data/aspose-tickets/preview.png" );
    // Save diagram as PNG
    final ImageSaveOptions ops = new ImageSaveOptions( SaveFileFormat.PNG );
    ops.setPageIndex( 0 );
    try( final OutputStream os = new FileOutputStream( pictureFile ) ) {
        diagram.save( os, ops );
    }
}

The preview file is attached.

This is how the tool was executed:

java -classpath "./classes:./lib/*" com.emerald_associates.p6diagram.aspose_tickets.ImagePreviewOnLinux -Dlog4j.configuration=file:conf/log4j.properties -Dlogname=- -Dlogdir=log -Djava.awt.headless=true -Dprimavera.bootstrap.home=./conf -Dcom.emerald_associates.springframework.context.web.home=. -enableassertions

Please remember that this must be executed on a Linux server and that the DISPLAY environment variable must be set to NULL, and that no display should be available. If there is a DISPLAY available I suspect the code will work. The file referenced from the ticket is this: preview.zip (35.1 KB)

@raviaw

Thanks for sharing requested information.

We are testing the scenario in our environment and will share our feedback with you soon.

@raviaw

Thanks for your patience.

We have tested the scenario in Linux environment (Ubuntu 15.04) and were unable to notice the exception which you have shared. Would you kindly share a sample application and detailed steps to reproduce the issue you are experiencing. We will again test the scenario in our environment and address it accordingly.

Did you run it with java.awt.headless=true?

I missed this message before, this is why I am replying only now.

@raviaw

Thanks for sharing the details.

We will again test the scenario and as soon as we have some results, we will share with you. Please spare us little time.

@raviaw

An investigation ticket as DIAGRAMJAVA-50653 has been logged in our issue tracking system for further investigation over this issue. We have associated it with your post so that you will receive notification once significant updates are available regarding its resolution. Please spare us little time.

We are sorry for the inconvenience.

The issues you have found earlier (filed as DIAGRAMJAVA-50653) have been fixed in Aspose.Diagram for Java 19.5.