Expand my Community achievements bar.

Guidelines for the Responsible Use of Generative AI in the Experience Cloud Community.

Image not displayed in pdf generated using Java API for Forms service

Avatar

Former Community Member

Hi,

I am creating a pdf document using Java API for Forms Service.

I am able to generate the pdf but the images are not visible in the generated pdf.

The image relative path is coming in the xml as defined below. The images are stored dynamically in the Livecycle repository each time a request is fired with unique name before the xml is generated.

<imageURI xfa:contentType="image/png" href="../Images/logo.png"></imageURI>

Not sure if I need to specify specify specific URI values that are required to render a form with image.

The same thing is working when I generate pdf document using Java API for Output Service.

As, I need to generate interactive form, I have to use Forms service to generate pdfs.

Any help will be highly appreciated.

Thanks.

2 Replies

Avatar

Employee Advisor

Please share the code snippet for Form Service.

-Wasil

Avatar

Former Community Member

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();