Skip to Content
0
Former Member
Nov 29, 2006 at 03:21 PM

Tutorial Offline Interactive Form (No. 30)

22 Views

Hi,

I wanted to do the tutorial mentioned above, but as it is developed for NW2004, I am slightly confused with the resource-property of the FileDownload Element of NW2004s. I adapted the code of wdDoInit() in the following way:

    IWDAttributeInfo attInfo = wdContext.currentContextElement().node().getNodeInfo().getAttribute("PdfSource");
    ISimpleTypeModifiable type = attInfo.getModifiableSimpleType();
    IWDModifiableBinaryType binaryType = (IWDModifiableBinaryType) type;
    binaryType.setFileName("TravelRequest.pdf");
    binaryType.setMimeType(WDWebResourceType.PDF);
    
    String fileName = "C:\tmp\TravelRequest.pdf";
    try{
    	File file = new File(fileName);
    	FileInputStream in = new FileInputStream(file);
    	ByteArrayOutputStream out = new ByteArrayOutputStream();
    	int length;
    	byte[] part = new byte[10 * 1024];
    	while ((length = in.read(part)) != -1){
    		out.write(part, 0, length);
    	}
    	in.close();
	IWDResource resource =  WDResourceFactory.createResource(part, fileName, WDWebResourceType.PDF);
    	wdContext.currentContextElement().setResource(resource);
    	out.close();
    }
    catch(Exception e){
    	throw new WDRuntimeException(e);
    }

When I click on the provided link in the application, a new browser window opens and shows text-content. No pdf is displayed.

When deploying the application to NW2004, it works fine.

Any help is appreciated.

Thanks, Ilona

Message was edited by:

Ilona Seifert