Sign In  Sign Up Live-Chat

Aspose.Word for Java

Last post 09-23-2008, 11:28 AM by swaga. 5 replies.
Sort Posts: Previous Next
  •  08-29-2008, 6:31 PM 141823

    Aspose.Word for Java

    Is there a way to convert a Document to 'html' format for streaming to a browser without saving it as a file first?
    Thanks.

    Steve Waga

    This message was posted using Page2Forum from Aspose products - Documentation
     
  •  08-30-2008, 5:12 AM 141840 in reply to 141823

    Re: Aspose.Word for Java

    Hi

     

    Thanks for your inquiry. I think that you can try save output document into the stream and send it into Response.

     

    //Open a document

    Document doc = new Document("in.doc");

    //Create output stream

    java.io.ByteArrayOutputStream htmlStream = new java.io.ByteArrayOutputStream();

    //Save document into the stream in HTML format

    doc.save(htmlStream, SaveFormat.HTML);

    //Get string from stream

    String html = htmlStream.toString("UTF-8");

    //Now you can send HTML into your Response.

     

    Hope this helps.

     

    Best regards.


    Alexey Noskov
    Developer/Technical Support
    Aspose Auckland Team
     
  •  09-02-2008, 10:40 AM 142041 in reply to 141840

    Re: Aspose.Word for Java

    Thanks Alexey.  I believe that it will work just fine.
    Much appreciated.

    Regards.
    Steve Waga
     
  •  09-22-2008, 4:40 PM 145041 in reply to 142041

    Re: Aspose.Word for Java

    Alexey,

    Follow-up question ...
    Should the following code snippet work to return the generated document as a Word file attachment? I ask because Word does not seem to like the format of the returned attachment.

    response.setContentType("application/msword");
    response.setHeader("Content-Disposition", "attachment; filename=MyFile.doc");
    document.save(response.getOutputStream(), SaveFormat.DOC);

    Thanks.

    Steve
     
  •  09-23-2008, 2:15 AM 145094 in reply to 145041

    Re: Aspose.Word for Java

    Hi

     

    Thanks for your request. Please try using the following code:

     

    //Add Response header

    response.setHeader("content-disposition", "attachment; filename=myFile.doc");

    //Set Response content type

    response.setContentType("application/msword");

    //Finally save generated document to Response Out.

    doc.save(response.getOutputStream(), SaveFormat.DOC);

    response.flushBuffer();

     

    I hope this could help.

     

    Best regards.


    Alexey Noskov
    Developer/Technical Support
    Aspose Auckland Team
     
  •  09-23-2008, 11:28 AM 145180 in reply to 145094

    Re: Aspose.Word for Java

    Alexey,

    That worked, thanks!

    I want to thank you for your quick responses to these issues.
    We will be purchasing a license and look forward to working with you again .. should the need arise ;)

    Steve Waga

    EHE International
     
View as RSS news feed in XML