Skip to content

Commit

Permalink
Fix PDF native mode (#196)
Browse files Browse the repository at this point in the history
  • Loading branch information
melloware authored May 1, 2024
1 parent 2a68154 commit 611283d
Show file tree
Hide file tree
Showing 3 changed files with 39 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -158,7 +158,7 @@ void registerForReflection(PrimeFacesRecorder recorder, BuildProducer<Reflective
classNames.remove(org.primefaces.component.datatable.export.DataTablePDFExporter.class.getName());
classNames.remove(org.primefaces.component.treetable.export.TreeTablePDFExporter.class.getName());

// remove in MyFaces 4.0.3
// TODO: remove in MyFaces 4.0.3
classNames.add("org.apache.myfaces.view.facelets.component.RepeatStatus");

// method reflection
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,21 +3,36 @@
import org.primefaces.component.datatable.export.DataTablePDFExporter;

import com.lowagie.text.Paragraph;
import com.lowagie.text.pdf.PdfPCell;
import com.lowagie.text.pdf.PdfPTable;
import com.oracle.svm.core.annotate.Substitute;
import com.oracle.svm.core.annotate.TargetClass;

/**
* iText Paragraph.add(object) is ambiguous and is confusing the native parser with the error:
* "Discovered unresolved method during parsing: com.lowagie.text.Paragraph.add(com.lowagie.text.Element)".
* This fix makes a more specific addParagraph(Paragraph) that does not confuse the native compiler.
* See notes above each method
*/
@TargetClass(DataTablePDFExporter.class)
public final class SubstituteDataTablePdfExporter {

/**
* iText Paragraph.add(object) is ambiguous and is confusing the native parser with the error:
* "Discovered unresolved method during parsing: com.lowagie.text.Paragraph.add(com.lowagie.text.Element)".
* This fix makes a more specific addParagraph(Paragraph) that does not confuse the native compiler.
*/
@Substitute
private void addEmptyLine(Paragraph paragraph, int number) {
for (int i = 0; i < number; i++) {
paragraph.addParagraph(new Paragraph(" "));
}
}
}

/**
* iText PdfPTable.addCell(object) is ambiguous and is confusing the native parser with the error:
* "Discovered unresolved method during parsing: com.lowagie.text.PdfPTable.addCell(com.lowagie.text.pdf.PdfPCell)".
* This fix makes a more specific addCellAsCell(Paragraph) that does not confuse the native compiler.
*/
@Substitute
protected void addCell(PdfPTable table, PdfPCell cell) {
table.addCellAsCell(cell);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -3,21 +3,36 @@
import org.primefaces.component.treetable.export.TreeTablePDFExporter;

import com.lowagie.text.Paragraph;
import com.lowagie.text.pdf.PdfPCell;
import com.lowagie.text.pdf.PdfPTable;
import com.oracle.svm.core.annotate.Substitute;
import com.oracle.svm.core.annotate.TargetClass;

/**
* iText Paragraph.add(object) is ambiguous and is confusing the native parser with the error:
* "Discovered unresolved method during parsing: com.lowagie.text.Paragraph.add(com.lowagie.text.Element)".
* This fix makes a more specific addParagraph(Paragraph) that does not confuse the native compiler.
* See notes above each method
*/
@TargetClass(TreeTablePDFExporter.class)
public final class SubstituteTreeTablePdfExporter {

/**
* iText Paragraph.add(object) is ambiguous and is confusing the native parser with the error:
* "Discovered unresolved method during parsing: com.lowagie.text.Paragraph.add(com.lowagie.text.Element)".
* This fix makes a more specific addParagraph(Paragraph) that does not confuse the native compiler.
*/
@Substitute
private void addEmptyLine(Paragraph paragraph, int number) {
for (int i = 0; i < number; i++) {
paragraph.addParagraph(new Paragraph(" "));
}
}
}

/**
* iText PdfPTable.addCell(object) is ambiguous and is confusing the native parser with the error:
* "Discovered unresolved method during parsing: com.lowagie.text.PdfPTable.addCell(com.lowagie.text.pdf.PdfPCell)".
* This fix makes a more specific addCellAsCell(Paragraph) that does not confuse the native compiler.
*/
@Substitute
protected void addCell(PdfPTable table, PdfPCell cell) {
table.addCellAsCell(cell);
}
}

0 comments on commit 611283d

Please sign in to comment.