cancel
Showing results for 
Search instead for 
Did you mean: 

convert xstring to pdf format

Former Member
0 Kudos

Hi, all,

I want to create a pdf file with xstring(255044462D...) using java. Is there anybody know how to do it? Thanks a lot!

Marea

Accepted Solutions (1)

Accepted Solutions (1)

luciano_leitedasilva
Contributor
0 Kudos

Hi Marea,

I made an Web Dynpro Java application that receive a xstring type from RFC back-end and show a PDF file at the window. That's work very nice and is so easy to implement.

It is the code at the iview:

IWDCachedWebResource resource = WDWebResource.getWebResource(wdContext.currentZ_Pdf_Report_OutputElement().getPdf(), WDWebResourceType.getWebResourceTypeForFileExtension("pdf"));

// xstring type is wdContext.currentZ_Pdf_Report_OutputElement().getPdf()

resource.setResourceName(this.getDescriptionReport());

// Create a External Window with the URL destination

IWDWindow window = wdComponentAPI.getWindowManager().createExternalWindow(resource.getURL(), this.getDescriptionReport(), true);

// Eliminate some features of the window

window.removeWindowFeature(WDWindowFeature.ADDRESS_BAR);

window.removeWindowFeature(WDWindowFeature.MENU_BAR);

window.removeWindowFeature(WDWindowFeature.STATUS_BAR);

window.removeWindowFeature(WDWindowFeature.TOOL_BAR);

window.setWindowSize(780,430);

window.setWindowPosition(20,140);

window.open();

I hope it help you!!!

Regards,

Luciano

Former Member
0 Kudos

Hi, Luciano,

Thanks for the reply. But I never used web Dynpro. When I use your java code, I got a lot of errors says those methods like "IWDCachedWebResource, wdContext.....can not be resolved). I guess those are Web Dynpro method. I use SAP NetWeaver Developer Studio. I don't know how I can use those methods into my program. Would you please give me more clues? Thank you!

Marea

luciano_leitedasilva
Contributor
0 Kudos

Hi Marea,

Try to create the first WD application, its so easy. After the first contact, try to puts that code at the method to hande any action( i.e. button pressed).

This code will just open um Xstring data as PDF. Before that, I guess, you have to execute some RFC to get this data.

This is the way!

Regards,

Luciano

Former Member
0 Kudos

Hi, Luciano,

Thanks for the comment. I am building my XI adapter module. And I have to deploy it to our XI server from NWDS. I even don't know where to get the WD, so I can create my WD application.

Marea

luciano_leitedasilva
Contributor
0 Kudos

Marea,

Well, I made somithing like that using XI. I imported a Web Service model in my WD Application!

Regards,

Luciano

Former Member
0 Kudos

Marea,

i'm not really familiar with XI adapters, but a more basic way to do it (without WD, even if i love it) is:

1. You must have the remote function module available, which delivers the XSTRING data (let's call it Z_GET_PDF).

2. Import the function module (FM) interface using the Enterprise Connector import feature in the NWDS. This gives you the classes/jar to access the FM in a type-safe manner. The import can be done into a plain Java project, which has to reference the aii_proxy related jars and the sapmwjco.jar to resolve the compile time errors.

3. The import always generates xxxInput, xxxOutput classes and a single xxxPorttype class. So for the example, this might result in something like Z_Get_PdfInput, Z_Get_PdfOutput and PdfModulePorttype, if you specify the port type name as "PdfModule" in the EC import wizard.

4. Using is easy. Pseudo-Code:


  // Instantiate the port type
  PdfModulePortType port = new PdfModulePortType();
  // Instantiate the input (IMPORT parameters/tables of FM)
  Z_Get_PdfInput input = new Z_Get_PdfInput();
  // Set the name/ID whatever of the PDF to load...
  input.setPdfID("test_pdf");
  // You must have the JCO client connection available.
  // This is configurable in XI, isn't it? ;)
  // The connection must be set in the port-type.
  // This method might have another, rather similar name (writing this from my internal memory hmpf)
  port.messageSpecifier.setJCOClient(client);  

  // Now execute the FM using the port type and get the result (output)
  // Of course you have to catch the (runtime) exceptions in real life.
  Z_Get_Pdf_Output output = port.executeZ_Get_Pdf(input);

  // In case of XSTRING, you should get a byte[] in Java.
  // This is already the data representing the PDF file.
  byte[] pdfData = output.getXStringData();

  // Do something with pdfData, create file or whatever.

Hope that helps.

Regards,

Stefan

Former Member
0 Kudos

Hi Marea,

U just need to right click on mouse>source>organize import.

-GJ-

Answers (0)