String cutHtml(String htmlString, double totalHeight) { htmlString = _getBody(htmlString); List<String htmlList...} else { resultHtml = remainHtml; remainHtml = ''; } if (_checkComplete(resultHtml, labelStack)) { htmlList.add...remainHtml.substring(0, tailPosition + 2); remainHtml = remainHtml.substring(tailPosition + 2); labelStack--; } } htmlList.add...(resultHtml); childNum--; } } } else { htmlList.add(htmlString); } return htmlList; } // true if resultHtml...labelsHead = {'<div', '<img', '<p', '<strong', '<span'}; static final _labelsTail = '</'; 通过以上算法, 拿到了切分好的htmlList
HashMap interfaceProps = Maps.newHashMap(); interfaceProps.put("img_baseurl", ""); List htmlList...= HTMLWorker.parseToList(new StringReader(html), ss, interfaceProps); for (int i = 0; i < htmlList.size...(); i++) { com.lowagie.text.Element e = (com.lowagie.text.Element) htmlList.get(i); context.add(e); }
领取专属 10元无门槛券
手把手带您无忧上云