Aspose.Words JAVA- Unable to download File in Internet Explorer 11

I am not able to download document files in IE 11. All other IE versions seem to work as well as Chrome and Firefox.

Here is a source code snippet…

I pass in ‘openNewWindow’ set to true…

public static void sendToBrowser(Document doc, String demoName, boolean openNewWindow, HttpServletResponse response)
throws Exception
{
// This behavior depends on the browser and the file you are trying to serve.
// With inline, the browser will try to open the file within the browser.
// we will use attachment
if(openNewWindow)
response.setHeader(“content-disposition”,“attachment; filename=” + demoName);
else
response.addHeader(“content-disposition”,“inline; filename=” + demoName);

response.setContentType(“application/msword”);

doc.save(response.getOutputStream(), com.aspose.words.SaveFormat.DOC);
}

Hi John,


Thanks for your inquiry. We are checking this scenario and will get back to you soon.

Best regards,

Hi John,


Thanks for your inquiry. Please try running attached simple web application on your end. It was created using Eclipse IDE. It has a simple JSP page with a button and when you press this button, a document is generated which you can download using IE 11. Hope, this helps.

Best regards,

Thanks - but i do not have Eclipse. Can you send me a war file that I can run on a tomcat server?

Thanks for your help.

Here is another scenario where the file will not download.

If you run IE11 on the web server and use ‘localhost’ as the domain name (http:\localhost\webapp) then IE11 has a problem downloading the file.

Can you try to reproduce that scenario?

Thanks!

Hi John,

Thanks for your inquiry. After deploying the web app on tomcat, I managed to download Aspose.Words generated document using IE 11 via this address on my side:

http://localhost:8484/HelloJSP/

When I click the ‘Process’ button, IE 11 presents me a ‘Do you want to open or save outDocument.docx from localhost?’ message. Please see attached screenshot.

Also, please download this HelloJSP.war file. Hope, this helps.

Best regards,

Sorry - I get an error because the app can’t find…

D:/temp/Aspose.Total.Java.lic


Hi John,


Please see attached another war file. Hope, this helps.

Best regards,

Hi - I have been able to create a scenario where IE 11 can download an Aspose document file and i have also been able to create a scenario where IE 11 cannot download an Aspose docuemnt file.

I have attached three for files for your review. The java file can easy be modified to make IE 11 fail to download. You can simply uncomment line number 509 which is the call to the doc.getMailMerge().executeWithRegions(allRiskData); method. If you do not make that call then IE 11 will download the file with no problem.

I have tried many many different programming techniques to narrow down this problem. If you can try to recreate this i would really appreciate it.

Hi John,


Thanks for your inquiry. I think, problem occurs because of some exception. Please debug your code to see at which point the exception is being thrown (check if relational data is correctly built). Also please try adding “System.out.println(ex.toString());” in catch block to determine nature of the exception and then fix it accordingly. Hope, this helps.

Best regards,

Thanks for your response - the source code works fine in Chrome, Firefox, IE7, IE8, IE9, and IE 10. It fails in IE 11.

I do not see any exception being thrown. I have narrowed down my source code to this pretty bare bones file that I sent you. The line that causes the error is when we call the Aspose execute mail merge method.

I do have the image callback method as well.

I am wondering if you could try to reproduce this in IE11?

Thanks

–John

Hi John,

Thanks for your inquiry. We are working over your query and will get back to you soon.

Best regards,

Have ypu been able to recreate this download issue?

Hi John,


Thanks for being patient. Unfortunately, I am unable to reproduce this issue on my side. IE 11, Chrome and FireFox, they all work the same way. Please upgrade to latest version of Aspose.Words for Java 15.11.0 and see how it goes on your end. Please also remove Tomcat’s cache or any temporary files. Create a fresh simple web application and deploy on Tomcat. Is it only the DOCX format which is causing the problem on IE 11 or other formats such as DOC, PDF, RTF etc also cause the same problem?

Best regards,

Hi - I tried using the latest aspose-words-15.11.0-jdk16.jar file but you have seemed to remove the ‘DataSet’ and ‘DataTable’ objects and my code will not compile.

What gives?

If you incorporate the ActionMakeDocument.java source file that I provided into the web application HelloSP1 that you provided that would be great.

I am getting this error now that I switched from aspose-words-14.11.0-jdk16.jar to aspose.slides-15.3.0-jdk16.jar

com.aspose.words.net.System.Data.InvalidConstraintException: ForeignKeyConstraint 'RiskToRiskDetails' requires the child key values ('VT_9999') to exist in the parent table.
at com.aspose.words.net.System.Data.ConstraintCollection.zzZ(Unknown Source)
at com.aspose.words.net.System.Data.ConstraintCollection.zzZ(Unknown Source)
at com.aspose.words.net.System.Data.zzX.zzZ(Unknown Source)
at com.aspose.words.net.System.Data.DataRowCollection.add(Unknown Source)
at com.asc.riskradar.action.ActionMakeDocument.createReportFile(ActionMakeDocument.java:247)

Hi - I have attached a zip file that contains a WAR file and a .java file that was used to create the WAR. If you remove lines 88-484 then the WAR file will run ok. As it is something is wrong with the data sets.

Two things -

1) the datasets works fine before I switched to the latest aspose jar file.

2) once you get that working - then if you use line 483
doc.getMailMerge().executeWithRegions(allRiskData);

then this WAR file will not download a file using IE 11 on a “localhost” system. It will work on a web server if you use the ip address or domain name - but locahost will fail.

Can you help me fix this?

Hi John,


Thanks for your inquiry. While using Aspose.Words for Java 15.11.0, I managed to reproduce following exception on line <riskDetailsDataTable.getRows().add(detailsRow);>

ForeignKeyConstraint ‘RiskToRiskDetails’ requires the child key values (’_9999’) to exist in the parent table.

We are checking this scenario further and will get back to you soon.

Best regards,

Hi John,


Awais:
ForeignKeyConstraint ‘RiskToRiskDetails’ requires the child key values (’_9999’) to exist in the parent table.

We are checking this scenario further and will get back to you soon.
It is to update you that we have logged this issue in our issue tracking system. The ID of this issue is WORDSJAVA-1250. Your thread has also been linked to this issue and you will be notified as soon as it is resolved. Sorry for the inconvenience.

Best regards,

Hi John,

Regarding WORDSJAVA-1250, our product team has completed the work on your issue and has come to a conclusion that this issue and the undesired new behaviour you’re observing is actually not a bug. So, we will close this issue as ‘Not a Bug’.

The problem occurs because of incorrect usage of DataTable and DataRelations. There are three ways to achieve the goal.

  1. Add parent’s row before child’s one. Have a look at the concept

:
The FOREIGN KEY constraint also prevents invalid data from being inserted into the foreign key column, because it has to be one of the values contained in the table it points to.

  1. Use DataTable.setEnforceConstraints(false) before adding a row.

  2. Use DataRelation(String relationName, DataColumn[] parentColumns, DataColumn[] childColumns, boolean createConstraints=false)

As we can see you try to add child’s row before parent’s one. See the following corrected example of fist approach. See the code with comments.

DataRelation riskDetailsRelation = new DataRelation(
                “RiskToRiskDetails”,
                riskDataTable /parent table/,
                riskDetailsDataTable /* child table which depends on parent via 'riskIDString*/,
                new String[]{“riskIDString”}, new String[]{“riskIDString”});
        allRiskData.getRelations().add(riskDetailsRelation);
 
        DataRow row = riskDataTable.newRow(); // At the moment it is detached and needs to be add into collection.
 
        //Risk Data.
        // This is the parent row. All children want to make sure this row exists and riskIDString presented
        row.set(0, “_9999”);
        row.set(1, “”);
        row.set(2, “”);
        row.set(3, “filldata”);
        row.set(4, “”);
        row.set(5, “”);
        row.set(6, “”);
        row.set(7, “”);
        row.set(8, “”);
        row.set(9, “”);
        row.set(10, “”);
        row.set(11, “”);
        row.set(12, “”);
        row.set(13, “”);
        row.set(14, “filldata”);
        row.set(15, “”);
        row.set(16, “”);
        row.set(17, “”);
        row.set(18, “”);
        row.set(19, “”);
        row.set(20, “”);
        row.set(21, “”);
        riskDataTable.getRows().add(row);
 
        DataRow detailsRow = riskDetailsDataTable.newRow(); //child row
        detailsRow.set(0, “_9999”);
        detailsRow.set(1, “”);
        detailsRow.set(2, “5”);
        detailsRow.set(3, “”);
        detailsRow.set(4, “”);
        detailsRow.set(5, “”);
        detailsRow.set(5, “”);
        detailsRow.set(6, “”);
        detailsRow.set(7, “”);
        detailsRow.set(8, “”);
        detailsRow.set(9, “”);
 
        //Because ‘riskDataTable’ and ‘riskDetailsDataTable’ are connected with riskIDString lets make sure ‘riskDataTable’ has a row with ‘riskIDString’ presented
 
        // check riskDataTable
        DataSetWriter.printDataTable(riskDataTable);
 
        //  riskDetailsDataTable.setEnforceConstraints(false); // Another way is to just switch off the constraints before adding
        riskDetailsDataTable.getRows().add(detailsRow);
 
        // check if child’s row has been added correctly.
        DataSetWriter.printDataTable(riskDetailsDataTable);

Hope, this helps.

Best regards,