Below is the code snippet:
//Create a FormsServiceClient object
FormsServiceClient formsClient = new FormsServiceClient(myFactory);
//Specify URI values that are required to render a form
URLSpec uriValues = new URLSpec();
// Template location contains the whole rpository path for the form
uriValues.setContentRootURI(templateLocation);
// The base URL where form resources such as images and scripts are located. Whole Image path is passed in BaseUrl in the http format.
String baseLocation = repositoryPath.concat(serviceName).concat(imagesPath);
uriValues.setBaseURL(baseLocation);
// Set run-time options using a PDFFormRenderSpec instance
PDFFormRenderSpec pdfFormRenderSpec = new PDFFormRenderSpec();
pdfFormRenderSpec.setCacheEnabled(new Boolean(true));
pdfFormRenderSpec.setAcrobatVersion(com.adobe.livecycle.formsservice.client.AcrobatVersion.Acrobat_8);
//Invoke the renderPDFForm method and write the
//results to a client web browser
String tempTemplateName =templateName;
FormsResult formOut = formsClient.renderPDFForm(tempTemplateName,
inXMDataTransformed,pdfFormRenderSpec,uriValues,null);
//Create a Document object that stores form data
Document outputDocument = formOut.getOutputContent();
InputStream inputStream = outputDocument.getInputStream();