cancel
Showing results for 
Search instead for 
Did you mean: 

PDF in new Window works only once?

Former Member
0 Kudos

Hello,

I have a problem showing a PDF in a new window. I get my PDF created from a BAPI as a byte[] - works fine. To show the PDF I use the follwong code in an action of a button:

byte[] pdfContent = wdContext.currentContextElement().getPdfDokument();

try {
  IWDWebResource pdfResource = WDWebResource.getWebResource
    (pdfContent, WDWebResourceType.PDF);
  wdComponentAPI.getWindowManager().createExternalWindow(
    pdfResource.getURL(),"Title",
    false).open();
} catch (WDURLException e) {
  e.printStackTrace();
}

It works fine - but just the <b>first time</b> I press the button. Window is opened and inside Acrobat Reader openes with my PDF.

I close that and press button again. Window openes but no PDF anymore?! Any hints?

Best regards,

Frank

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

Hi Frank,

try the following Tutorial:

https://www.sdn.sap.com/irj/servlet/prt/portal/prtroot/com.sap.km.cm.docs/library/webas/webdynpro/tu... on excel export using the web dynpro binary cache - 34.htm

The class used there is IWDCachedWebresource instead of IWDWebResourced.

I adapt it to use a PDF as a byte [] (build from an InputStream) and it works fine for me.

regards,

Christian

Answers (4)

Answers (4)

Former Member
0 Kudos

hi..

Will you pls send me that complete coding to display PDF in the window.

i am having same problem like you have.. But i am new comer..so i am not getting what u did?

it's urgent...pls reply ASAP..

with regards,

Gobinath.R

Former Member
0 Kudos

store the context (for pdf storage) in component controller and test it.

or worst case, create the pdf in KM repository (some temp dir) and show the pdf. Clean up when exit from application.

Message was edited by:

Anant

Message was edited by:

Armin Reichert

Former Member
0 Kudos

Hi Frank,

sorry i can't help you with this problem.

But can you tell me, how you create a PDF-file via a BAPI in the backend system and send it in a byte-stream to a Web Dynpro?

Kind regards,

Tobi

Former Member
0 Kudos

I have the same problem than Jesus.

In:

IWDWebResource pdfResource = WDWebResource.getWebResource

(pdfContent, WDWebResourceType.PDF);

wdComponentAPI.getWindowManager().createExternalWindow(

pdfResource.getURL(),"Title",true).open();

the program does not recognize the pdfResource variable.

any suggestion ?

thanks in advance.

Leandro

Former Member
0 Kudos

Hi,

I have a problem. I'm trying to display a smartform from a webdynpro application, but when I try to write:

IWDWebResource pdfResource = WDWebResource.getWebResource

(pdfContent, WDWebResourceType.PDF);

wdComponentAPI.getWindowManager().createExternalWindow(

pdfResource.getURL(),"Title",true).open();

the program does not recognize the pdfResource variable. It says that it cannot resolve it.

Any hints?

Thanks.

Jesus

Former Member
0 Kudos

Hello,

that does not help... I tried both and result is always the same.

It works fine if I use the way of the tutorial to open a small Dialogbox with a FileDownload Element. But this I don't want, I want to open the window directly after pressing the button.

Frank