cancel
Showing results for 
Search instead for 
Did you mean: 

PDF Rending in Web Dynpro Unknown.pdf

Former Member
0 Kudos

I am getting a pdf document from R/3. I get the byte[] from the context node.

The num bytes returned is >0 however when I render the pdf as follows I get a black pdf document displayed and I notice that unknown.pdf the generated url.

BTW, I don't see any way to set the filename. I don't want unknown.pdf in the url.

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();

}

Accepted Solutions (0)

Answers (1)

Answers (1)

Sigiswald
Contributor
0 Kudos

Hi Bob,

In NW2004s we use the following. getPdf() returns a byte[], the filename is "document-<username>.pdf" and source is the attribute of an IFrame UI element.


private void initPdf() {
  IWDResource resource =
    WDResourceFactory.createResource(
      getPdf(),
      "document-"
        + WDClientUser.getLoggedInClientUser().getSAPUser().getUniqueName(),
      WDWebResourceType.PDF);
  String source =
    resource.getUrl(WDFileDownloadBehaviour.OPEN_INPLACE.ordinal());
  wdContext.currentContextElement().setSource(source);
}

On NW2004 we use a FileDownload UI element (with target=_self) and we call initFileBinaryType method in the wdDoInit method. Of course you still need to set the binary PdfData context attribute with the actual content of the PDF file.


private void initFileBinaryType() {
  IWDModifiableBinaryType pdf =
    initFileBinaryType(IPrivateTestAppView.IContextElement.PDF_DATA);
  pdf.setFileName("document-"
    + WDClientUser.getLoggedInClientUser().getSAPUser().getUniqueName());
  pdf.setMimeType(WDWebResourceType.PDF);
}

private IWDModifiableBinaryType initFileBinaryType(String attribute) {
  return (IWDModifiableBinaryType) wdContext
    .getNodeInfo()
    .getAttribute(attribute)
    .getModifiableSimpleType();
}

Kind regards,

Sigiswald

Former Member
0 Kudos

Thanks. I am using NW2004s. Can you confirm that printing is possible when from using IFrameUI element. In my scenario the PDF must be rendered and then printed within a portal.

Sigiswald
Contributor
0 Kudos

Hi Bob,

If you mean by printing that the Adobe Reader toolbar containing the print button is visible, the answer is yes. That allows you to print the PDF itself.

On the other hand, if you like to print the screen of the Web Dynpro application itself (including the rendered PDF and any other rendered Web Dynpro UI elements), the answer is also yes, but it's slightly more complicated. Please check .

Kind regards,

Sigiswald