cancel
Showing results for 
Search instead for 
Did you mean: 

Open PDF in New External Window

Former Member
0 Kudos

Hi

how to open a PDF Report(File) in new IE Window from WebdynproJava

Regards

Dhinakar

Accepted Solutions (0)

Answers (3)

Answers (3)

jnmurthi
Participant
0 Kudos

HI,

please find the following link...it may be of some help

[;

Regards,

Murthy.

Reward points if helpful

vijayakhanna_raman
Active Contributor
0 Kudos

Hi,

If the PDF document is in the server then we can show that in the external window onClick of the button.

Write this code in the onAction button event.

try
		{
byte[] content =this.getByteArrayFromResourcePath("<server path>\Guide.pdf"); 
String stResourcePath = new String("<server path>\Guide.pdf");
IWDCachedWebResource resource = WDWebResource.getWebResource(content, WDWebResourceType.PDF);
	
IWDWindow window = wdComponentAPI.getWindowManager().createNonModalExternalWindow(resource.getAbsoluteURL()," document");
window.removeWindowFeature(WDWindowFeature.TOOL_BAR);
window.removeWindowFeature(WDWindowFeature.ADDRESS_BAR);
window.removeWindowFeature(WDWindowFeature.STATUS_BAR);
		
window.open();
		}
catch(WDURLException ex)
{
}
catch(IOException ex)
{
}

Paste this code here:

//@@begin others

private byte[] getByteArrayFromResourcePath(String resourcePath) throws FileNotFoundException, IOException
		{
	  FileInputStream in = new FileInputStream(new File(resourcePath));
	ByteArrayOutputStream out = new ByteArrayOutputStream();
	int len;
	byte[] part = new byte[10 * 1024];
	while ((len = in.read(part)) != -1)
			{
			out.write(part, 0, len);
			}
			in.close();
	
			return out.toByteArray();
		}
 

//@@end

Regards,

Vijai

Former Member
0 Kudos

Hi Vijay..

I seen ur thread , i have the same requiremnt niw... an i tried ur sample code for opening the pdff.. and in my case the EP7.0 server is on unix and am with NWDS on WINDOWSXP. i tried with ur code sample but it did't show any result ..in my case the pdf is on my desktop.and i given a path like this

byte[] content =this.getByteArrayFromResourcePath("C:
Documents and Settings
96480.ITC
Desktop\text.pdf");

String stResourcePath = new String("C:
Documents and Settings
96480.ITC
Desktop\text.pdf");

IWDCachedWebResource resource = WDWebResource.getWebResource(content, WDWebResourceType.PDF);

kindly suggest me any another solution

Thanks inAdvance

Regards

Rajesh

09903726944

Former Member
0 Kudos

if you have the URL of the PDF you can use the below mentioned code.Generate the URL using the below mentioned code and use the URL in a IFrame...

use the link https://www.sdn.sap.com/irj/servlet/prt/portal/prtroot/com.sap.km.cm.docs/library/webdynpro/dialog%2...

for opening up the new window..

try

{

URL pdfUrl = new URL(wdContext.currentContextElement().getUrlFromAckView());

InputStream in = null;

in = pdfUrl.openStream();

String inputLine;

int chunkSize = 1;

byte[] chunk = new byte[chunkSize];

ByteArrayOutputStream baos = new ByteArrayOutputStream ();

int offset = 0;

int data;

while ( (data=in.read(chunk)) != -1)

{

baos.write(chunk);

}

final IWDCachedWebResource resource = WDWebResource.getWebResource

(

baos.toByteArray(),

WDWebResourceType.PDF

);

resource.setResourceName("Ack_Po_Document.pdf");

resource.setAttachement( false );

resource.setReadOnce( false );

wdContext.currentContextElement().setUrl

(

resource.getAbsoluteURL()

);

}

catch (Exception ex)

{

wdComponentAPI.getMessageManager().reportSuccess(ex.toString());

}