I have a requirement to export a page content including the styling in HTML format so that can be exported to third party.
We are not using GraphQL as we need the styling as well to be exported.
Or, if we can export the page content including styling in JSON format so that the third party can render it on their system.
Solved! Go to Solution.
Views
Replies
Total Likes
Hi ,
if you want to read page html response in Java, Please check this below code.
import org.apache.sling.engine.SlingRequestProcessor;
import com.day.cq.contentsync.handler.util.RequestResponseFactory;
@Reference
private RequestResponseFactory requestResponseFactory;
@Reference
private SlingRequestProcessor requestProcessor;
public String doStuff(){
HttpServletRequest request = requestResponseFactory.createRequest("GET", "/path/to/your/node.html");
request.setAttribute(WCMMode.REQUEST_ATTRIBUTE_NAME, WCMMode.DISABLED);
ByteArrayOutputStream out = new ByteArrayOutputStream();
HttpServletResponse response = requestResponseFactory.createResponse(out);
requestProcessor.processRequest(request, response, resourceResolver);
return out.toString(response.getCharacterEncoding());
}
Thanks
Have look into -
For Exporter as HTML File with css/js files
Thanks
Hi ,
if you want to read page html response in Java, Please check this below code.
import org.apache.sling.engine.SlingRequestProcessor;
import com.day.cq.contentsync.handler.util.RequestResponseFactory;
@Reference
private RequestResponseFactory requestResponseFactory;
@Reference
private SlingRequestProcessor requestProcessor;
public String doStuff(){
HttpServletRequest request = requestResponseFactory.createRequest("GET", "/path/to/your/node.html");
request.setAttribute(WCMMode.REQUEST_ATTRIBUTE_NAME, WCMMode.DISABLED);
ByteArrayOutputStream out = new ByteArrayOutputStream();
HttpServletResponse response = requestResponseFactory.createResponse(out);
requestProcessor.processRequest(request, response, resourceResolver);
return out.toString(response.getCharacterEncoding());
}
Thanks
I suggest using the selector approach here. In your template, implement a selector which will render styled HTML only.
Your 3rd parties can use a page path with selector like www.example.com/path/of/page.content.html