Professional Documents
Culture Documents
if (pContent.contains(line)){
count=line.split(" ").length - 1;
index=pContent.lastIndexOf(line);
index=index+ line.length() - 1;
}else{
line=lineAux;
if (count>=(words.length-1)/2) {
count = 0;
String[] wordsFound = line.split("\\s+");
getColumns(pContent, wordsFound,
extrartorTable(pContent,getHtml()),index);;
return true;
} else {
count=0;
line="";
}
}
}else {
if (count>5) {
count = 0;
String[] wordsFound = line.split("\\s+");
getColumns(pContent, wordsFound,
extrartorTable(pContent,getHtml()), index);;
return true;
} else {
count=0;
line="";
}
}
}
}
return false;
}
if (table.contains(pContent)) {
String parte1 = pContent.substring(0, index);
parte1+= "</p>";
// Cortar el texto desde el índice específico hasta el final
String parte2 = pContent.substring(index);
parte2=parte2.replaceAll("</p>","");
}
private void modifyColums(String parte1,String parte2,String pContent, String
coincidencia ) throws IOException {
modifiedHtml.setLength(0);
setHtml(getHtml().replaceAll(pContent,parte1));
Pattern trPattern = Pattern.compile("(<p[^>]*>[\\s\\S]*?</p>)");
Matcher trMatcher = trPattern.matcher(getHtml());
int indexStart=0;
int indexEnd=0;
String last="";
while (trMatcher.find()){
last=trMatcher.group(1);
indexStart= trMatcher.start();
indexEnd=trMatcher.end();
}
if (last.contains(parte1)){
if (last.contains("class=\"right\"")){
String[] partes = dividirTextoEnPunto(parte2);
String newContent= last+"</div><div class=\"colum-container
clearfix\"><p class=\"left\">"+partes[0]+"</p><p
class=\"right\">"+partes[1]+"</p>";
modifiedHtml.append(getHtml(), 0, indexEnd)
.append(newContent)
.append(getHtml(), indexEnd,
getHtml().length());
setHtml(modifiedHtml.toString());
try {
// Crear un PDF con el contenido actual
createPdf(getHtml());
} catch (IOException e) {
e.printStackTrace();
}
}
return;
}else {
last.replaceAll("<p class=\"right\">", "");
parte2="<p class=\"right\">"+parte2;
modifiedHtml.append(getHtml(), 0, indexStart)
.append(parte2)
.append(getHtml(), indexStart, getHtml().length());
setHtml(modifiedHtml.toString());
try {
// Crear un PDF con el contenido actual
createPdf(getHtml());
} catch (IOException e) {
e.printStackTrace();
}
String lastLine=
readerLastline(readerPage(getDirectory()+"/Update-"+name));
lastLine=lastLine.replaceAll(coincidencia,"");
searchColumns(lastLine);
}
private static String[] dividirTextoEnPunto(String texto) {
int longitudTotal = texto.length();
int mitadLongitud = longitudTotal / 2;
if (posicionPunto != -1) {
// Si encontramos un punto después de la mitad, dividir el texto
allí
parte1 = texto.substring(0, posicionPunto + 1);
parte2 = texto.substring(posicionPunto + 1);
} else {
// Si no encontramos un punto, dividir el texto por la mitad
parte1 = texto.substring(0, mitadLongitud);
parte2 = texto.substring(mitadLongitud);
}