Expand my Community achievements bar.

SOLVED

I am able to genarte the pdf from the content fragment using a APi, but when Mine pdf is getting generated at the specific location I want o deploy it automatically without manual publish.

Avatar

Level 2

Hi 

I am able to generate the PDF at specific location when I am hitting the api, but after PDF is getting generated I want to deploy it to publisher instance without publishing it manually. 

 

Thank You

 

@AEM @EstebanBustamante 

Topics

Topics help categorize Community content and increase your ability to discover relevant content.

1 Accepted Solution

Avatar

Correct answer by
Level 6

Hi @Dear_AT ,

 

1. Once you generate the PDF post hitting the API, get the path lets say at /content/somelocation/generatedPdf.pdf, save the path/resource using session.save() if you are using Node API or resourceResolver.commit() if you want to use Resource API.

2. Then simply publish the same path using  com.day.cq.replication.Replicator API

 

public void replicateAsset(ResourceResolver resourceResolver, String assetPath) throws ReplicationException {
		replicator.replicate(resourceResolver.adaptTo(Session.class), ReplicationActionType.ACTIVATE, pathToGeneratedPdf);
	}

 

View solution in original post

2 Replies

Avatar

Correct answer by
Level 6

Hi @Dear_AT ,

 

1. Once you generate the PDF post hitting the API, get the path lets say at /content/somelocation/generatedPdf.pdf, save the path/resource using session.save() if you are using Node API or resourceResolver.commit() if you want to use Resource API.

2. Then simply publish the same path using  com.day.cq.replication.Replicator API

 

public void replicateAsset(ResourceResolver resourceResolver, String assetPath) throws ReplicationException {
		replicator.replicate(resourceResolver.adaptTo(Session.class), ReplicationActionType.ACTIVATE, pathToGeneratedPdf);
	}

 

Avatar

Community Advisor

Hi, 
As explained @anupampat you need to use the Replicator API to achieve that. You can try something like below

@Reference
private Replicator replicator;
..
..
replicator.replicate(session, ReplicationActionType.ACTIVATE, assetPath);

 You can learn more here: 

https://dev.to/jerinraj55551/replication-api-in-aem-adobe-experience-manager-405n  

https://developer.adobe.com/experience-manager/reference-materials/6-4/javadoc/com/day/cq/replicatio... 


Hope this helps



Esteban Bustamante