on 03-10-2006 4:40 AM
Hello Everyone,
I have a Webdynpro project and need to create a link on one of the views to display a .PDF document.
1. Where should I store the PDF document within the webdynpro project?
2. How do I open the PDF file?
I've created a link with action on the view and just need to know how to open it.
Thanks in advance for your help.
Mike
Mike,
if your PDF is part of your component (i.e. it should be deployed along with the component) placing the file manually on the server is not very convenient - you may put the file in mimes folder of the WDpro Component.
Then all you need to do:
IWDWebResource resource = WDWebResource.getWebResource( wdComponentAPI.getDeployableObjectPart(), WDWebResourceType.PDF, "Test.pdf");
String externalURL = resource.getAbsoluteURL();
You may associate reference to this externalURL to the LinkToURL element.
The information about parsing "component-local" xml could be applied together with RK's advice to create downloadable PDF indirectly.
Best regards,
Nick
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Mike,
You can try one of the following methods:
Method 1:
-
1. Create a context attribute (say pdfsource) of type binary.
2. Create a file download control
3. Attach this attribute to the data property of file download control.
4. In the init method of the view or in some other method store the content of the pdf in the context attribute. And do the following code
IWDAttributeInfo attInfo = wdContext.currentContextElement().node().getNodeInfo().getAttribute("pdfSource");
ISimpleTypeModifiable type = attInfo.getModifiableSimpleType();
IWDModifiableBinaryType binaryType = (IWDModifiableBinaryType) type;
binaryType.setFileName("Test.pdf");
binaryType.setMimeType(WDWebResourceType.PDF);
5. Now on click of File Download link, it will ask for "Open", "Save", or "Cancel" dialog box. You can choose open to open as a pdf document.
-
Method 2:
-
1. Write an action on click of the button or so.
2. In that action get the contents and store it in an byte array and open the pdf file directly as follows.
byte[] PDFbytes = <source string>.getBytes();
if(PDFbytes!= null) { IWDCachedWebResource pdffile= WDWebResource.getPublicCachedWebResource( PDFbytes , WDWebResourceType.PDF, WDScopeType.CLIENTSESSION_SCOPE, wdThis.wdGetAPI().getComponent().getDeployableObjectPart(),
"Some Title"); wdComponentAPI.getWindowManager().createNonModalExternalWindow(pdffile.getURL(), "Some PDF").open();
-
Thanks and regards
RK
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi,
You have to put it in the server .If you have the document in test folder in c drive
then go to
\usr\sap\<instance name>\JC<instance number>\j2ee\admin\go.bat
open visual admin
go to services->http provider
select the tab alias
give a name say testword and define the path as c:/test/<name of the document>.doc
save properties
write the code below in the action associated with the link
IWDWindow newwindow = wdComponentAPI.getWindowManager().createExternalWindow("http://cgnlpt041:50000/testword","<title of window>",false);
newwindow.open();
deploy the project
it will open in a new window
Regards
Rohit
Hope this helps you
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
83 | |
10 | |
10 | |
9 | |
7 | |
6 | |
5 | |
5 | |
4 | |
3 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.