Your achievements

Level 1

0% to

Level 2

Tip /
Sign in

Sign in to Community

to gain points, level up, and earn exciting badges like the new
BedrockMission!

Learn More

View all

Sign in to view all badges

AEM Forms API (com.adobe.fd) - Creating a servlet that flattens a pdf

Avatar

Avatar
Validate 1
Level 2
Mahen_Govender
Level 2

Likes

3 likes

Total Posts

11 posts

Correct Reply

1 solution
Top badges earned
Validate 1
Boost 3
Boost 1
Applaud 5
Affirm 1
View profile

Avatar
Validate 1
Level 2
Mahen_Govender
Level 2

Likes

3 likes

Total Posts

11 posts

Correct Reply

1 solution
Top badges earned
Validate 1
Boost 3
Boost 1
Applaud 5
Affirm 1
View profile
Mahen_Govender
Level 2

02-11-2016

Hi All

 

I am having trouble flattening a pdf. 

Using LiveCycle it would be done using the OutputService.generatePDFOutput operation

However the generatePDFOutput method available on com.adobe.fd.output.api.OutputService does not have a TransformationFormat that can be specified to a flat pdf, and its options object also does not seem to have anything that will help with this.

So my question is, using the com.adobe.fd library, how would you take a pdf Document that has fields etc, and flatten it?

 

Thanks!

Mahendran 

Accepted Solutions (1)

Accepted Solutions (1)

Avatar

Avatar
Boost 5
Level 2
GregFullard
Level 2

Likes

5 likes

Total Posts

13 posts

Correct Reply

1 solution
Top badges earned
Boost 5
Boost 3
Boost 1
Affirm 1
View profile

Avatar
Boost 5
Level 2
GregFullard
Level 2

Likes

5 likes

Total Posts

13 posts

Correct Reply

1 solution
Top badges earned
Boost 5
Boost 3
Boost 1
Affirm 1
View profile
GregFullard
Level 2

03-11-2016

OK, I've put together a quick sample that seems to work. Key point is that you use the generatePDFOutput method, but pass in null as the XML data.

 

Here's a snippet:

    
    ... flattenXfaForm(File inXfa, String outputFolder)    { 

            ....
            Document doc=null;
            String xfaName = inXfa.getName().toString();
            PDFOutputOptions options = new PDFOutputOptions();   
            options.setContentRoot(inXfa.getParentFile().toString());
            doc=outputService.generatePDFOutput(xfaName, null, options);    

            ....

}    

Answers (4)

Answers (4)

Avatar

Avatar
Validate 1
Level 2
Mahen_Govender
Level 2

Likes

3 likes

Total Posts

11 posts

Correct Reply

1 solution
Top badges earned
Validate 1
Boost 3
Boost 1
Applaud 5
Affirm 1
View profile

Avatar
Validate 1
Level 2
Mahen_Govender
Level 2

Likes

3 likes

Total Posts

11 posts

Correct Reply

1 solution
Top badges earned
Validate 1
Boost 3
Boost 1
Applaud 5
Affirm 1
View profile
Mahen_Govender
Level 2

03-11-2016

GregFullard wrote...

OK, I've put together a quick sample that seems to work. Key point is that you use the generatePDFOutput method, but pass in null as the XML data.

 

Here's a snippet:

    
    ... flattenXfaForm(File inXfa, String outputFolder)    { 

            ....
            Document doc=null;
            String xfaName = inXfa.getName().toString();
            PDFOutputOptions options = new PDFOutputOptions();   
            options.setContentRoot(inXfa.getParentFile().toString());
            doc=outputService.generatePDFOutput(xfaName, null, options);    

            ....

}    

 

This works brilliantly, but the process seems to make any barcodes on the form illegible. 

Any idea how to flatten a pdf, and maintain its barcodes? 

Avatar

Avatar
Boost 5
Level 2
GregFullard
Level 2

Likes

5 likes

Total Posts

13 posts

Correct Reply

1 solution
Top badges earned
Boost 5
Boost 3
Boost 1
Affirm 1
View profile

Avatar
Boost 5
Level 2
GregFullard
Level 2

Likes

5 likes

Total Posts

13 posts

Correct Reply

1 solution
Top badges earned
Boost 5
Boost 3
Boost 1
Affirm 1
View profile
GregFullard
Level 2

03-11-2016

Hi Mahendran

After checking the docs, it seems that flattening is available in the OSGi Assembler service. Check out https://helpx.adobe.com/aem-forms/6-2/assembler-service.html

But there's a caveat: "The Assembler service uses the Output service to flatten dynamic XFA forms. If the Assembler service processes a DDX that requires it to flatten an XFA dynamic form and the Output service is unavailable, an exception is thrown. The Assembler service can flatten an Acrobat form or a static XFA form without using the Output service."

Greg

Avatar

Avatar
Boost 1
Level 2
nitinn18425437
Level 2

Like

1 like

Total Posts

16 posts

Correct Reply

7 solutions
Top badges earned
Boost 1
Affirm 5
Affirm 3
Affirm 1
View profile

Avatar
Boost 1
Level 2
nitinn18425437
Level 2

Like

1 like

Total Posts

16 posts

Correct Reply

7 solutions
Top badges earned
Boost 1
Affirm 5
Affirm 3
Affirm 1
View profile
nitinn18425437
Level 2

03-11-2016

Hi Mahen,

 

com.adobe.fd.output.api.OutputService  does not take TransformationFormat as input. It assumes that TransformationFormat is PDF and thus always generates a flat PDF from input PDF which has fields etc. Sample usage of this service can be found at https://helpx.adobe.com/aem-forms/6-2/aem-document-services-programmatically.html#generatePDFOutput

Thanks

Nitin

Avatar

Avatar
Validate 1
Level 2
Mahen_Govender
Level 2

Likes

3 likes

Total Posts

11 posts

Correct Reply

1 solution
Top badges earned
Validate 1
Boost 3
Boost 1
Applaud 5
Affirm 1
View profile

Avatar
Validate 1
Level 2
Mahen_Govender
Level 2

Likes

3 likes

Total Posts

11 posts

Correct Reply

1 solution
Top badges earned
Validate 1
Boost 3
Boost 1
Applaud 5
Affirm 1
View profile
Mahen_Govender
Level 2

03-11-2016

Mahen Govender wrote...

Hi All

 

I am having trouble flattening a pdf. 

Using LiveCycle it would be done using the OutputService.generatePDFOutput operation

However the generatePDFOutput method available on com.adobe.fd.output.api.OutputService does not have a TransformationFormat that can be specified to a flat pdf, and its options object also does not seem to have anything that will help with this.

So my question is, using the com.adobe.fd library, how would you take a pdf Document that has fields etc, and flatten it?

 

Thanks!

Mahendran 

 

Any ideas on this? It Must be possible to flatten a pdf surely.... 😕

M