# dynamic PDF generation

**URL:** <https://techcommunity.softwareag.com/t/dynamic-pdf-generation/78768>\
**Category:** Forum\
**Tags:** Former-Crossvision-Products, Application-Composer\
**Created:** [August 13, 2008, 7:38pm UTC](https://techcommunity.softwareag.com/t/dynamic-pdf-generation/78768 "2008-08-13T19:38:56Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![Martin\_Mayr](https://avatars.discourse-cdn.com/v4/letter/m/b3f665/32.png) [@Martin\_Mayr](https://techcommunity.softwareag.com/u/Martin_Mayr)\
**Post date:** [August 13, 2008, 7:38pm UTC](https://techcommunity.softwareag.com/t/dynamic-pdf-generation/78768/1 "2008-08-13T19:38:56Z")

</div>

is there a way for the FOP API to have dynamic properties as there is for pages/adapters?

for an adapter, the code would look like this:

```auto

private m_sDynamicPropertiesArray;

@Override
public String[] findDynamicAccessProperties()
{
  return m_sDynamicPropertiesArray;
}
  
@Override
public void setDynamicAccessPropertiesFromOutside(String[] dynamicPropertiesArray)
{
  this.m_sDynamicPropertiesArray = sDynamicPropertiesArray;
}
  
@Override
public Object getPropertyValue(String propertyName)
{
  return data.get(propertyName);
}
```

to have access to dynamic valueprops

is there a way to have the same for an PDF data object? (because in the documentation i got, there it’s only possible with a getFoo() method for a \<cisfo:textreplace2 valueprop=“foo”\> element)  
so i only have to write one for several layouts …

edit: i use application designer 2.2

---

<div class="post-metadata">

**Author:** ![Christine\_Zimmermann](https://avatars.discourse-cdn.com/v4/letter/c/839c29/32.png) [@Christine\_Zimmermann](https://techcommunity.softwareag.com/u/Christine_Zimmermann)\
**Post date:** [August 14, 2008, 4:07pm UTC](https://techcommunity.softwareag.com/t/dynamic-pdf-generation/78768/2 "2008-08-14T16:07:57Z")

</div>

Hi Martin,

Not sure if I understand the idea. What do you mean by the method setDynamicAccessPropertiesFromOutside?

Is your question about implementing the IDynamicAccess interface? For a specific object something like:

```auto
public class FOP2InvoiceObject
    implements IFOPDataObject, IDynamicAccess
{
....
}
```

The IDynamicAccess interface does not contain any method with the name setDynamicAccessPropertiesFromOutside.

Best Regards,  
Christine

---

<div class="post-metadata">

**Author:** ![Martin\_Mayr](https://avatars.discourse-cdn.com/v4/letter/m/b3f665/32.png) [@Martin\_Mayr](https://techcommunity.softwareag.com/u/Martin_Mayr)\
**Post date:** [August 14, 2008, 4:28pm UTC](https://techcommunity.softwareag.com/t/dynamic-pdf-generation/78768/3 "2008-08-14T16:28:12Z")

</div>

Hello Christine,

i want to be able to have one PDF Data Objkect for many different layouts.  
therefore i need a dynamic way to let a layout gain access to the needed data.

i don’t know how to describe it, so i will post some examples here:

e.g. i got 2 layouts as xml files:

first xml file:

```auto

<?xml version="1.0" encoding="UTF-8"?>
<cisfo:foppage2 objectclass="PDFDataObject" pageheight="29.7cm" pagewidth="21cm" margintop="3cm" marginbottom="2.5cm" marginleft="2.5cm" marginright="2.5cm">
    <cisfo:body2>
        <cisfo:textreplace2 valueprop="text">
        </cisfo:textreplace2>
    </cisfo:body2>
</cisfo:foppage2>
```

secod xml file:

```auto

<?xml version="1.0" encoding="UTF-8"?>
<cisfo:foppage2 objectclass="PDFDataObject" pageheight="29.7cm" pagewidth="21cm" margintop="3cm" marginbottom="2.5cm" marginleft="2.5cm" marginright="2.5cm">
    <cisfo:body2>
        <cisfo:textreplace2 valueprop="data">
        </cisfo:textreplace2>
    </cisfo:body2>
</cisfo:foppage2>
```

and i want only one pdf data object class, namely PDFDataObject  
but as i don’t know future layouts, i don’t want to use:

```auto

String m_text, m_data;
public String getText() { return m_text; }
public String getData() { return m_data; }
```

but something like in the dynamic page generation:

```auto

String[] dynamicProperties; // they are initializes somewhere else
public String getDynamicProperty(String propertyname)
{
  // return the property based on the given propertyname
}
```

so the pdf generator doesn’t need the getXYZ method for each valueprop … but one for all of them (or at least all i specify in the dynamicProperties String)

---

<div class="post-metadata">

**Author:** ![Christine\_Zimmermann](https://avatars.discourse-cdn.com/v4/letter/c/839c29/32.png) [@Christine\_Zimmermann](https://techcommunity.softwareag.com/u/Christine_Zimmermann)\
**Post date:** [September 3, 2008, 11:24am UTC](https://techcommunity.softwareag.com/t/dynamic-pdf-generation/78768/4 "2008-09-03T11:24:18Z")

</div>

Hi Martin,

It should be possible to use the IDynamicAccess interface also for an FOP Data Object.

```auto

public class MyPdfObject implements IFOPDataObject, IDynamicAccess
{
...
public String[] findDynamicAccessProperties()
{
        return new String[]{"myreplace1", "myreplace2",...};
}
public Object getPropertyValue(String name)
{
   if ( name.equalsIgnoreCase("myreplace1"))
      ...
}
public void setPropertyValue(String name,
                                 Object value)
{
    ...
}
}

```

Your “MyPdfObject” class can also implement additional methods and have additional properties. With this I think you should be able to build generic classes.

Does it work in your example?

Best Regards,  
Christine

---

<div class="post-metadata">

**Author:** ![system](https://global.discourse-cdn.com/techcommunity/original/3X/c/d/cd19967bb605d28a72d77eb83a1cae22f3df2eb8.svg) [@system](https://techcommunity.softwareag.com/u/system)\
**Post date:** [April 2, 2021, 2:50pm UTC](https://techcommunity.softwareag.com/t/dynamic-pdf-generation/78768/5 "2021-04-02T14:50:45Z")

</div>


