on 01-31-2007 6:39 AM
Hi All,
I am using Java web dynpro with interactive form. When I display the contents of the pdfSource of the interactive form into a text file, I see the following which is not a true binary content. Could u please let me know why the content is represented in the form other than binary?
%PDF-1.6
%âãÏÓ
153 0 obj<</First 973/Length 1717/Filter/FlateDecode/N 120/Type/ObjStm>>stream
xÚ´XÉ 7 ý C"î ` p¼ lÇÉ) ¶DË%õ Õxþ>¯¤ä´/9±EV½*¾zÜd gyÍ Â0Á0
....
0000000153 65535 f
0000000154 65535 f
trailer
<</Size 156/Root 1 0 R>>
xref
0 0
trailer
<</Size 156/Prev 32208/XRefStm 2120/Root 1 0 R/Info 3 0 R/ID[<991012CC1DD111B20A00FFBFDB48FD64><991077C51DD111B20A00060100000680>]>>
startxref
35372
%%EOF
Thanks & Regards,
Jyoti
Hi Naidu
I have written the contents of the pdfsource to a file in the server using the below code:
byte b[] = wdContext.currentContextElement().getPdfSource();
File file = new File("C:
Severance.pdf");
long length = file.length();
FileOutputStream os;
try {
os = new FileOutputStream(file);
os.write(b);
os.close();
}
catch (Exception e)
{
// TODO Auto-generated catch block
wdThis.wdGetAPI().getComponent().getMessageManager().reportSuccess("Some Exception "+e);
e.printStackTrace();
}
And i have added a File Download element in the Application and have implemented the below piece of code for it:
IWDAttributeInfo attInfo = wdContext.currentContextElement().node().getNodeInfo().getAttribute("ctx_downloadpdfsrc");
ISimpleTypeModifiable type = attInfo.getModifiableSimpleType();
IWDModifiableBinaryType binaryType = (IWDModifiableBinaryType) type;
binaryType.setMimeType(WDWebResourceType.TXT);
String fileName ="C:
Severance.pdf";
// path to the source file
/* converts the binary file to a byte array and moves it to the text element */
try
{
File file = new File(fileName);
FileInputStream in = new FileInputStream(file);
ByteArrayOutputStream out = new ByteArrayOutputStream();
int length;
byte[] part = new byte [10 * 1024];
while ((length = in.read(part)) != -1)
{
out.write(part, 0, length);
}
in.close();
wdContext.currentContextElement().setCtx_downloadpdfsrc(out.toByteArray());
}
catch(Exception e)
{
wdComponentAPI.getMessageManager().reportSuccess(" !!!!!!!!!!!!! "+e);
throw new WDRuntimeException(e);
}
Other than this, if we simply write this line in the code it will display the entire content of the pdfSource on the screen when deployed:
wdComponentAPI.getMessageManager().reportSuccess(wdContext.currentContextElement().getPdfSource().toString());
Regards,
Jyoti
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
HI Jyoti,
Could you please tell the code that you have written for displaying the contensts of pdf source
With Regards
Naidu
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
81 | |
24 | |
11 | |
9 | |
7 | |
5 | |
5 | |
5 | |
4 | |
4 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.