Browse Source

WU

research/11.0
kerry 6 years ago
parent
commit
f694b38c20
  1. 12
      fine-itext/src/com/fr/Container.java
  2. 10
      fine-itext/src/com/fr/third/v2/lowagie/text/pdf/ColumnText.java
  3. 12
      fine-itext/src/com/fr/third/v2/lowagie/text/pdf/PdfBlock.java
  4. 2
      fine-itext/src/com/fr/third/v2/lowagie/text/pdf/PdfChunk.java
  5. 2
      fine-itext/src/com/fr/third/v2/lowagie/text/pdf/PdfDocument.java
  6. 8
      fine-itext/src/com/fr/third/v2/lowagie/text/pdf/PdfLine.java
  7. 11
      fine-itext/src/com/fr/third/v2/lowagie/text/pdf/PdfPCell.java
  8. 17
      fine-itext/src/com/fr/third/v2/lowagie/text/pdf/PdfPRow.java
  9. 40
      fine-itext/src/com/fr/third/v2/lowagie/text/pdf/PdfPTable.java

12
fine-itext/src/com/fr/Container.java

@ -0,0 +1,12 @@
package com.fr;
/**
* @author kerry
* @date 2018/8/20
*/
public interface Container {
String getHtmlContent(double lineStartY, double lineEndY);
float getHeight();
}

10
fine-itext/src/com/fr/third/v2/lowagie/text/pdf/ColumnText.java

@ -242,7 +242,15 @@ public class ColumnText {
protected ColumnText compositeColumn;
protected LinkedList compositeElements;
public LinkedList getCompositeElements() {
return compositeElements;
}
public void setCompositeElements(LinkedList compositeElements) {
this.compositeElements = compositeElements;
}
protected int listIdx = 0;
private boolean splittedRow;

12
fine-itext/src/com/fr/third/v2/lowagie/text/pdf/PdfBlock.java

@ -0,0 +1,12 @@
package com.fr.third.v2.lowagie.text.pdf;
/**
* @author kerry
* @date 2018/8/10
*/
public interface PdfBlock {
float getHeight();
void calculateHeight();
String toHtmlString(double startY, double endY);
}

2
fine-itext/src/com/fr/third/v2/lowagie/text/pdf/PdfChunk.java

@ -298,7 +298,7 @@ public class PdfChunk {
* @return the Unicode equivalent
*/
public int getUnicodeEquivalent(int c) {
return 0;
return c;
}
protected int getWord(String text, int start) {

2
fine-itext/src/com/fr/third/v2/lowagie/text/pdf/PdfDocument.java

@ -1357,7 +1357,7 @@ public class PdfDocument extends Document {
* @param ratio
* @throws DocumentException on error
*/
void writeLineToContent(PdfLine line, PdfContentByte text, PdfContentByte graphics, Object currentValues[], float ratio) throws DocumentException {
public void writeLineToContent(PdfLine line, PdfContentByte text, PdfContentByte graphics, Object currentValues[], float ratio) throws DocumentException {
PdfFont currentFont = (PdfFont)(currentValues[0]);
float lastBaseFactor = ((Float)(currentValues[1])).floatValue();
PdfChunk chunk;

8
fine-itext/src/com/fr/third/v2/lowagie/text/pdf/PdfLine.java

@ -255,7 +255,7 @@ public class PdfLine {
* @return a value
*/
float indentLeft() {
public float indentLeft() {
if (isRTL) {
switch (alignment) {
case Element.ALIGN_LEFT:
@ -312,7 +312,7 @@ public class PdfLine {
* @return a value
*/
float widthLeft() {
public float widthLeft() {
return width;
}
@ -460,7 +460,7 @@ public class PdfLine {
* @return an extra leading for images
* @since 2.1.5
*/
float[] getMaxSize() {
public float[] getMaxSize() {
float normal_leading = 0;
float image_leading = -10000;
PdfChunk chunk;
@ -476,7 +476,7 @@ public class PdfLine {
return new float[]{normal_leading, image_leading};
}
boolean isRTL() {
public boolean isRTL() {
return isRTL;
}

11
fine-itext/src/com/fr/third/v2/lowagie/text/pdf/PdfPCell.java

@ -51,6 +51,7 @@ package com.fr.third.v2.lowagie.text.pdf;
import java.util.List;
import com.fr.Container;
import com.fr.third.v2.lowagie.text.Chunk;
import com.fr.third.v2.lowagie.text.DocumentException;
import com.fr.third.v2.lowagie.text.Element;
@ -1010,4 +1011,14 @@ public class PdfPCell extends Rectangle {
height = getMinimumHeight();
return height;
}
private Container container;
public Container getContainer() {
return container;
}
public void addContent(Container container){
this.container = container;
}
}

17
fine-itext/src/com/fr/third/v2/lowagie/text/pdf/PdfPRow.java

@ -195,6 +195,23 @@ public class PdfPRow {
return maxHeight;
}
public float getMaxHeight2(){
float aMaxHeight = 0.0f;
for (int k = 0; k < cells.length; ++k) {
PdfPCell cell = cells[k];
float height = 0;
if (cell == null) {
continue;
}
else {
height = cell.getContainer().getHeight();
if ((height > aMaxHeight) && (cell.getRowspan() == 1))
aMaxHeight = height;
}
}
return aMaxHeight;
}
/**
* Writes the border and background of one cell in the row.
*

40
fine-itext/src/com/fr/third/v2/lowagie/text/pdf/PdfPTable.java

@ -71,7 +71,7 @@ import com.fr.third.v2.lowagie.text.pdf.events.PdfPTableEventForwarder;
* @author Paulo Soares (psoares@consiste.pt)
*/
public class PdfPTable implements LargeElement {
public class PdfPTable implements LargeElement, PdfBlock {
/**
* The index of the original <CODE>PdfcontentByte</CODE>.
@ -1559,4 +1559,42 @@ public class PdfPTable implements LargeElement {
public void setComplete(boolean complete) {
this.complete = complete;
}
@Override
public float getHeight() {
return getTotalHeight();
}
@Override
public void calculateHeight() {
}
@Override
public String toHtmlString(double startY, double endY) {
StringBuffer a = new StringBuffer();
float currentHeight = 0.0f;
a.append("<table>");
for(Object r : rows){
PdfPRow row = (PdfPRow) r;
if(currentHeight>=startY && currentHeight+ row.getMaxHeights() <= endY){
a.append("<tr>");
for(PdfPCell cell : row.getCells()){
a.append(cell.getContainer().getHtmlContent(0, cell.getHeight()));
}
a.append("</tr>");
}
currentHeight+=row.getMaxHeights();
//
// if(currentHeight <= y && currentHeight + row.getMaxHeights() >x){
//
// }else{
// break;
// }
}
a.append("</table>");
return a.toString();
}
}
Loading…
Cancel
Save