cancel
Showing results for 
Search instead for 
Did you mean: 

PDF in browser rendered as Text

Former Member
0 Kudos

We're trying to render SMARTFORMS outpur as PDF within our WebDynpro

application. We've found several posts which have been very helpful

and I think we're close. When we try to show the pdf a client browser window

is spawned and the content is rendered as text within the browser (shown below).

It looks like I'm not setting the content-type in the response header correctly.

Below is the code we're using.

Much Thanks,

Greg

/* Code used to launch browser and view PDF */

  String file_prefix = "rfq";

   IWDCachedWebResource pdfResource = WDWebResource.getPublicCachedWebResource(
   			pdfContent, WDWebResourceType.PDF, WDScopeType.CLIENTSESSION_SCOPE,
   			wdThis.wdGetAPI().getComponent().getDeployableObjectPart(),
   			file_prefix );

   wdComponentAPI.getWindowManager().createExternalWindow( pdfResource.getURL(), "RFQ", false).open();

/* First few lines of rendered document */
DF-1.3
%âãÏÓ
2 0 obj
<<
/Type /FontDescriptor
/Ascent 720
/CapHeight 660
/Descent -270
/Flags 34
/FontBBox [-177 -269 1123 6]
/FontName /Times-Roman
/ItalicAngle 0
/StemV 105
>>

Accepted Solutions (0)

Answers (2)

Answers (2)

Former Member
0 Kudos

This was resolved. We truncated some of the formatting/header info during the conversion.

Thanks,

Greg

Former Member
0 Kudos

Hi,

Create a separate view to display PDF.

Create a frame on that view and attach its datasource to url.

Please go through the following code.

The return value URL should be used as source for Frame.

private String convertXstringToUrl( byte[] doc_content, java.lang.String doc_type ) {

// setIFrameUrl()

String url = "";

if (doc_content != null && doc_content.length != 0) {

MessageManager msgMgr;

WDWebResourceType webResType = WDWebResourceType.PDF;

if (doc_type.equals("PDF")) {

webResType = WDWebResourceType.PDF;

} else if (doc_type.equals("HTML")){

webResType = WDWebResourceType.HTML;

} else if (doc_type.equals("XML")) {

webResType = WDWebResourceType.XML;

} else {

try {

fpm.getMessageManager().raiseException(wdThis.wdGetAPI().getComponent(), "WrongDocType", "text", wdThis.wdGetAPI().getTextAccessor().getText("WrongDocType", new String[] { doc_type }));

} catch(FPMRuntimeException ex) {

;

}

}

IWDWebResource webResource = WDWebResource.getWebResource(doc_content, webResType);

// IWDWebResource webResource = WDWebResource.getWebResource(doc_content, webResType, false);

try {

url = webResource.getURL();

}

catch (WDURLException ex) {

try {

fpm.getMessageManager().raiseException(wdThis.wdGetAPI().getComponent(), ex);

} catch(FPMRuntimeException ex2) {

;

}

}

} else {

/** Todo: Error! */

}

return (url);

}

Hope this helps you.

Regards,

Nagaraju Donikena

Former Member
0 Kudos

That is an excellent suggestion...wanted to make sure you got points.

Thanks again,

Greg