Caused by: java.lang.IllegalStateException: java.nio.charset.UnsupportedCharsetException: UTF-7

Hi

I am suing hte Asposer.words jar(latest one) and i have following code.

if (request.getParameter("type").equalsIgnoreCase("pdf")) {

response.setContentType("application-x/msword");

response.setHeader("Content-Disposition", "attachment;filename="

+ "ReportIssuance" + ".pdf");

}

InputStream in = new ByteArrayInputStream(

report != null ? report.getReportData() : new byte[2000]);

ServletOutputStream outStream = response.getOutputStream();

Document doc = new Document(in);

if (request.getParameter("type").equalsIgnoreCase("word"))

doc.save(outStream, SaveFormat.DOC);

if (request.getParameter("type").equalsIgnoreCase("pdf"))

doc.saveToPdf(0, doc.getPageCount(), outStream, null);

if (request.getParameter("type").equalsIgnoreCase("html"))

doc.save(outStream, SaveFormat.HTML);

outStream.flush();

outStream.close();

this reads pdf file, which was stored from UI to DB as byte[]. when i try to read back those byte[] as pdf, i get the following exception.

Caused by: java.lang.IllegalStateException: java.nio.charset.UnsupportedCharsetException: UTF-7

Any update on this . This is pretty urgent.

Hi

<?xml:namespace prefix = o ns = "urn:schemas-microsoft-com:office:office" />

Thanks for your inquiry. Do you get this exception upon loading your document or upon saving? Please attach your input document here for testing. Also, please try explicitly specify load format when you open your document from stream. This might help you to resolve the issue.

Best regards,

Thanks for reply.

What should be the load format. Please mention the code for input stream. PFA the pdf doc too

Hi

<?xml:namespace prefix = o ns = "urn:schemas-microsoft-com:office:office" />

Thank you for additional information. Please clarify, are you trying to open PDF document using Aspose.Words? Aspose.Words does not support loading PDF documents.

Best regards,

then in that case how should i open a loaded pDF document. and also, can i open a word document from db as pDF using Aspose.Words

Hi

<?xml:namespace prefix = o ns = "urn:schemas-microsoft-com:office:office" />

Thanks for your request. Using Aspose.Words you can load any word documents and save these documents as PDF. In case of opening PDF documents, you should use Aspose.Pdf.Kit. If you have any question about Aspose.Pdf.Kit please feel free to write to the appropriate forum. My colleagues will answer you shortly.

Best regards,

Okies, i need to download jars for aspose.pdf.Kit ???

Also, can you provide me the code snippte which will read from Binary stream and write as PDF to browser. As i am not sure which methods i need to use in Kit.

<!–[if gte mso 10]> /* Style Definitions */ table.MsoNormalTable {mso-style-name:"Table Normal"; mso-tstyle-rowband-size:0; mso-tstyle-colband-size:0; mso-style-noshow:yes; mso-style-priority:99; mso-style-qformat:yes; mso-style-parent:""; mso-padding-alt:0pt 5.4pt 0pt 5.4pt; mso-para-margin:0pt; mso-para-margin-bottom:.0001pt; mso-pagination:widow-orphan; font-size:11.0pt; font-family:"Calibri","sans-serif"; mso-ascii-font-family:Calibri; mso-ascii-theme-font:minor-latin; mso-fareast-font-family:SimSun; mso-fareast-theme-font:minor-fareast; mso-hansi-font-family:Calibri; mso-hansi-theme-font:minor-latin; mso-bidi-font-family:Arial; mso-bidi-theme-font:minor-bidi;}

<![endif]–>

Hi

Thanks for your inquiry. Actually, it is not quite clear for me, why you need open PDF and then just save to PDF without any processing. Why do not you just send the original PDF to client?

Best regards,

See i have one PDF as byte[] array store in Db.
I can do the necessary change in PDF if required. Though aspose should not be constrained by the fact that i did not change it.

Hope that clears the things

<!–[if gte mso 10]> /* Style Definitions */ table.MsoNormalTable {mso-style-name:"Table Normal"; mso-tstyle-rowband-size:0; mso-tstyle-colband-size:0; mso-style-noshow:yes; mso-style-priority:99; mso-style-qformat:yes; mso-style-parent:""; mso-padding-alt:0pt 5.4pt 0pt 5.4pt; mso-para-margin:0pt; mso-para-margin-bottom:.0001pt; mso-pagination:widow-orphan; font-size:10.0pt; font-family:"Times New Roman","serif";}

<![endif]–>

Hi

Thank you for additional information. Please see Aspose.Pdf.kit documentation to learn how to work with PDFs:

http://www.aspose.com/documentation/java-components/aspose.pdf.kit-for-java/index.html

Hope this helps.

Best regards,

In the documentation i can no where see the code as exampl to read from byte array and display in browser. Please be a bit more elaborate.

<!–[if gte mso 10]> /* Style Definitions */ table.MsoNormalTable {mso-style-name:"Table Normal"; mso-tstyle-rowband-size:0; mso-tstyle-colband-size:0; mso-style-noshow:yes; mso-style-priority:99; mso-style-qformat:yes; mso-style-parent:""; mso-padding-alt:0pt 5.4pt 0pt 5.4pt; mso-para-margin:0pt; mso-para-margin-bottom:.0001pt; mso-pagination:widow-orphan; font-size:11.0pt; font-family:"Calibri","sans-serif"; mso-ascii-font-family:Calibri; mso-ascii-theme-font:minor-latin; mso-fareast-font-family:SimSun; mso-fareast-theme-font:minor-fareast; mso-hansi-font-family:Calibri; mso-hansi-theme-font:minor-latin; mso-bidi-font-family:Arial; mso-bidi-theme-font:minor-bidi;}

<![endif]–>

Hi

Thanks for your inquiry. If you have questions regarding Aspose.Pdf.Kit it is better to ask in the appropriate forum. My colleagues from Aspose.Pdf.Kit team will be glad to help you. If you would like, for your convenience, I can move whole thread into Aspose.Pdf.Kit forum.

Best regards,

Please do the favour.

Anyone taking care of this.

Hi Anmol,

I have read this thread however I’m sorry to inform you that Aspose.Pdf.Kit doesn’t provide any facility to render the PDF file to the browser. I’m afraid, you’ll have to do this using standard Java code; you might search for a related code snippet on the internet.

We’re sorry for the inconvenience. If you find any further questions or concerns, please do let us know.
Regards,