Skip to Content
avatar image
Former Member

PDF in browser rendered as Text

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
>>

Add comment
10|10000 characters needed characters exceeded

  • Get RSS Feed

2 Answers

  • avatar image
    Former Member
    Jun 12, 2007 at 09:54 PM

    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

    Add comment
    10|10000 characters needed characters exceeded

  • avatar image
    Former Member
    Jun 12, 2007 at 09:56 PM

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

    Thanks,

    Greg

    Add comment
    10|10000 characters needed characters exceeded