cancel
Showing results for 
Search instead for 
Did you mean: 

How to SAVE pdf doc in hard disk programatically

Former Member
0 Kudos

Folks,

How to save pdf doc to harddisk programatically in webdynpro application.

Thanks,

Manish

Accepted Solutions (0)

Answers (1)

Answers (1)

Sharathmg
Active Contributor
0 Kudos

Hi Manish,

You can save the PDF in your local hard disk by adding the below mentioned piece of code under the action of any particular button,outside the PDF.

// Coding in the view side.

IPrivate<ViewControllerName>.IContextElement currentContext = wdContext.currentContextElement();

// to obtain the context -

byte[] bytes = currentContext.getPdfSource();

// The context attribute mapped to the pdfSource must be used to retrieve the path

try{

String filepath = "Provide your local path

(Ex: C:
PDF
SAVE
sample.pdf)";

File file = new File(filepath);

FileOutputStream Output = new FileOutputStream(file);

Output.write(bytes);

Output.close();

}

catch(Exception e)

{

e.printStackTrace();

}

This code should be run on the click of the button.

Kindly award points, if the solution/code provided achieve your requirement.

Regards,

Sharath