cancel
Showing results for 
Search instead for 
Did you mean: 

Input stream to pdf file generation in WDJ

Former Member
0 Kudos

Hi Experts,

I want to create a pdf file from some inputstream or string content in Webdynpro Java code.

Can anyone please provide me some code snippet related to this.

I tried below code:

-


public class test {

public static void main(String[] args) {

String strFilePath = "C://demo.pdf";

try {

FileOutputStream fos = new FileOutputStream(strFilePath);

String strContent =

"Write File using Java FileOutputStream example !";

fos.write(strContent.getBytes());

fos.close();

} catch (FileNotFoundException ex) {

System.out.println("FileNotFoundException : " + ex);

} catch (IOException ioe) {

System.out.println("IOException : " + ioe);

}

-


It is creating a pdf file in my local system but while opening the file it is saying "Corrupted file".-

Any kind of help will be highly appreciated.

Regards,

Sambarn

Accepted Solutions (0)

Answers (2)

Answers (2)

junwu
Active Contributor
0 Kudos

i think you need some open souce lib to generate pdf file. like itext.

Former Member
0 Kudos

Hi Sambara,

you can use IWDCachedWebResource class to conver bytes[] Object to obtain an url. After you have to open a external window and that willl open a pdf file.

regards,

Fernando

Former Member
0 Kudos

Thanks to all.

The actual issue was not in the code; it was due to ADS User account expiration we were getting corrupted pdf file.

Regards,

Sambaran

Former Member
0 Kudos

You have to use WDResource and related classes for reading/writing the files on portal app server.

For getting some Idea, look at this wiki.

http://www.sdn.sap.com/irj/scn/go/portal/prtroot/docs/library/uuid/00062266-3aa9-2910-d485-f1088c3a4...

-Yugandhar Reddy