Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
  • 한국 커뮤니티
0

PDF Services API: Document Generation

Community Beginner ,
Nov 06, 2023 Nov 06, 2023

I am attempting to use PDF Services Document Generation Module via Adobe Fusion. No matter what value I place into the Data for Merge parameter I cannot get the JSON object to work. I have tried as a string, and as a Collection, I have tried as a single param and a mapped param. No combination seems to work. I'm just looking for someone who has gotten this to work before.

 

I can put in hard-coded individual values and get it to work but that is not very useful when I have many documents each with a unique structure, I don't want to have to set up a single module for every file we have. Any guidance would be great, thanks!

TOPICS
Document Generation API , Workfront Fusion
2.3K
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines

correct answers 1 Correct answer

Adobe Employee , Nov 06, 2023 Nov 06, 2023

Hi Graham,
It's possible.  You just need to pre-generate the arguments as an Array[] with each element in the array conforming to the syntax of { "key": "X", "value":"Y", valueType: "Z" }.  Instead of specifying the values individually in the PDF module, you turn the 'map' switch on so you can pass this array.


Here's an arbitrary example that downloads a template from Workfront, makes the aforementioned Array with some hello world values, makes the PDF, and then sends it to myself.

wesadobe_0-1699299276753.pngexpand image

 

Translate
Adobe Employee ,
Nov 06, 2023 Nov 06, 2023

Hi Graham,
It's possible.  You just need to pre-generate the arguments as an Array[] with each element in the array conforming to the syntax of { "key": "X", "value":"Y", valueType: "Z" }.  Instead of specifying the values individually in the PDF module, you turn the 'map' switch on so you can pass this array.


Here's an arbitrary example that downloads a template from Workfront, makes the aforementioned Array with some hello world values, makes the PDF, and then sends it to myself.

wesadobe_0-1699299276753.pngexpand image

 

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Beginner ,
Nov 06, 2023 Nov 06, 2023

Thanks for your reply.  I tried setting mine up in the same way however, I seem to be getting a missing value error coming from the valueType field. Which is odd because I am not exposing it. See the runtime error below.

 

Screenshot 2023-11-06 at 2.52.27 PM.pngexpand image

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Adobe Employee ,
Nov 06, 2023 Nov 06, 2023

Check the contents of json_string.  It should look like this:

 

[

  {

    "key":"Field_1",

    "value":"Field_1_Value"

    "valueType":"value"

  },

    "key":"Field_2",

    "value":"Field_2_Value"

    "valueType":"value"

}

]

 

You'll need to adjust your aggregator after you change the structure to now collect the field,fieldType,valueType instead of field_1,field_2

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Beginner ,
Nov 06, 2023 Nov 06, 2023

Never mind, I see you have the custom JSON structure. I think I can make it work now.  Is this published anywhere? It does not seem to appear anywhere in the Document Generation documentation. I think the only places this appears is in the parameters for the actual API calls and it is not explicitly clear that the JSON should carry information beyond field name and value. Might be worth adding a paragraph to the Workfront-specific docs. I think most people trying to set this up in that env might not have a lot of API experience. Anyhow, Thanks!

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Beginner ,
Nov 06, 2023 Nov 06, 2023

So, I thought I had this sorted out but it still is not working. I am still getting a valueType validation error. I tried removing and re-adding the module and the error persists. Here are all my module settings. Perhaps I have been looking at this for so long that I cannot see a simple misconfiguration. Any ideas are welcome.

 

Doc_Gen_Error.jpgexpand image

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Beginner ,
Nov 06, 2023 Nov 06, 2023

Here's a better screen shot that shows the options selected in the aggregator.

Doc_Gen_Error.jpgexpand image

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Adobe Employee ,
Nov 06, 2023 Nov 06, 2023

It's difficult to tell.  What values are checked off in the Array aggregator?  It looks blank.

Can you look at the input bundle? (it's the little download button above your error message)

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Beginner ,
Nov 06, 2023 Nov 06, 2023

I put up a new screenshot showing the items checked in the aggregator. Yes, the input bundle is showing empty. I think it always shows empty on a validation error.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Adobe Employee ,
Nov 06, 2023 Nov 06, 2023

Something is strange, that looks correct.  What does the output of the aggregator indicate?

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Beginner ,
Nov 07, 2023 Nov 07, 2023

Looks like this which looks correct to me.

 

Screenshot 2023-11-07 at 9.23.06 AM.pngexpand imageScreenshot 2023-11-07 at 9.23.14 AM.pngexpand image

 

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Adobe Employee ,
Nov 07, 2023 Nov 07, 2023

That looks correct to me also.

Try deleting the PDF operation and putting a new one in its place.  It shouldn't make a difference but I'm at a loss as to what the issue is.  Your array contents from the image above are the exact same structure as mine.

wesadobe_0-1699368598101.pngexpand image

 

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Beginner ,
Nov 07, 2023 Nov 07, 2023

Same error. I will try re-creating the scenario from scratch.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Beginner ,
Nov 08, 2023 Nov 08, 2023

I re-created the scenario from scratch and I still get the same error. THis is the only thing I can think of that would be different at this point: What does the json you use to feed the Document Generation plugin to create the fields look like?

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Adobe Employee ,
Nov 08, 2023 Nov 08, 2023

wesadobe_0-1699457265263.pngexpand image

This is the input bundle from the PDF Generation module.

 

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Beginner ,
Nov 08, 2023 Nov 08, 2023

I mean what does the json look like that was used to set up the fields in the actual word doc using the Document Generation Plugin?

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Adobe Employee ,
Nov 08, 2023 Nov 08, 2023

I didn't use the dogen plugin, but the fields look like this in the document:

 

{{firstName}} {{lastName}}

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Beginner ,
Nov 08, 2023 Nov 08, 2023

I tried a new Word file with simple tags and I am still getting the same error.

 

What version of PDF Services are you using?

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Adobe Employee ,
Nov 08, 2023 Nov 08, 2023

I've tried this with both version 1 and version 2 of the module.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Beginner ,
Nov 13, 2023 Nov 13, 2023

So I got this to work by changing the tags to {{<field_name>.value}}. Now I want to place all of these fields in a repeating section. Not sure what the JSON would need to look like to handle multiple iterations.  Can you give me a hint on that?

 

Would it be like this?

 

{"products":[

{"1":{ "key":"field1", "valueType":"array", "value":"test1"}},

{"2":{ "key":"field2", "valueType":"array", "value":"test2"}},

]}

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Adobe Employee ,
Nov 13, 2023 Nov 13, 2023

I sure can.

 

The 'tasks' item is a three column table containing a name, status, and duration.

Note that it's valueType is array.  There are no valueTypes on the rows themselves - just straight JSON object.

It would be precisely like this:

{
"jsonDataForMerge": [
{
"key": "ProjectName",
"value": "CSC Demo 28th Altura Tech",
"valueType": "vаlue"
},
{
"key": "tasks",
"value": [
{
"name": "Create Text Replacement Spreadsheet",
"status": "NEW",
"duration": 1
},
{
"name": "Apply Text to Template Variation PSDs with Automation (*)",
"status": "CPL",
"duration": 1
},
{
"name": "Create Template Variation PSDs by Automation (*)",
"status": "CPL",
"duration": 1
},
{
"name": "Create Initial Concept",
"status": "NEW",
"duration": 1
},
{
"name": "Send individual images to AEM Assets",
"status": "NEW",
"duration": 1
},
{
"name": "Create Primary Multi-Artboard PSD Template",
"status": "NEW",
"duration": 1
},
{
"name": "Separate individual images from Final PSDs with Automation (*)",
"status": "CPL",
"duration": 1
}
],
"valueType": "array"
},
{
"key": "ProjectDescription",
"valueType": "vаlue"
},
{
"key": "ChangeName",
"value": "test cr",
"valueType": "vаlue"
},
{
"key": "DescriptionOfChange",
"value": "asdad",
"valueType": "vаlue"
},
{
"key": "ReasonForChange",
"value": "asda",
"valueType": "vаlue"
},
{
"key": "Impact",
"value": "Medium",
"valueType": "vаlue"
}

 

]
}

 

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Beginner ,
Nov 15, 2023 Nov 15, 2023

This was a huge help, thanks!

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Adobe Employee ,
Nov 15, 2023 Nov 15, 2023
LATEST

You're most welcome!

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Resources