Search in sources :

Example 1 with PrintScreenResponse

use of com.twinsoft.convertigo.engine.parsers.PrintScreenResponse in project convertigo by convertigo.

the class XMLPrintScreen method apply.

@Override
public boolean apply(Document xmlDom, Context context) {
    try {
        HtmlConnector htmlConnector = (HtmlConnector) context.getConnector();
        PrintScreenResponse printScreenResponse = htmlConnector.getHtmlParser().makePrintScreen(context, new PrintScreenRequest(height, width, top, left, scale, getImageFormat(), true, minDelay));
        if (printScreenResponse != null) {
            Document doc = context.outputDocument;
            Element root = doc.getDocumentElement();
            Element elt = doc.createElement((tagName.equals("") ? getName() : tagName));
            elt.setAttribute("height", Integer.toString(printScreenResponse.height));
            elt.setAttribute("width", Integer.toString(printScreenResponse.width));
            elt.setAttribute("scale", Float.toString(printScreenResponse.scale));
            elt.setAttribute("imageFormat", printScreenResponse.imageFormat.name());
            if (includeDataUrl) {
                elt.setTextContent(printScreenResponse.dataUrlPrefix + printScreenResponse.dataBase64);
            } else {
                elt.setTextContent(printScreenResponse.dataBase64);
            }
            root.appendChild(elt);
        }
        return true;
    } catch (Exception ex) {
    }
    return false;
}
Also used : HtmlConnector(com.twinsoft.convertigo.beans.connectors.HtmlConnector) Element(org.w3c.dom.Element) PrintScreenRequest(com.twinsoft.convertigo.engine.parsers.PrintScreenRequest) Document(org.w3c.dom.Document) PrintScreenResponse(com.twinsoft.convertigo.engine.parsers.PrintScreenResponse)

Aggregations

HtmlConnector (com.twinsoft.convertigo.beans.connectors.HtmlConnector)1 PrintScreenRequest (com.twinsoft.convertigo.engine.parsers.PrintScreenRequest)1 PrintScreenResponse (com.twinsoft.convertigo.engine.parsers.PrintScreenResponse)1 Document (org.w3c.dom.Document)1 Element (org.w3c.dom.Element)1