world I used XMLWorker (5.5.6) to convert XHTML pages containing arabic characters to PDF. All works fine but "page-break-before" doesn't work ! Here is my html page :
<!DOCTYPE html>
<html>
<head>
<title>Déclaration</title>
<style type="text/css" >
table {
page-break-before: always;
}
</style>
</head>
<body style="font-family: Noto Naskh Arabic">
<p style="page-break-before: always;text-align: center; font-size: 24px; font-family: Noto Naskh Arabic">الجمهورية</p>
<div style="page-break-before: always;text-align: center; font-size: 18px; font-family: Verdana" >REPUBLIQUE </div>
<div dir="rtl" style="page-break-before: always;text-align: center; font-size: 24px; font-family: Noto Naskh Arabic" >تصريــــح بالممتلكـــــات</div>
<p style="font-family: Verdana">DECLARATION </p>
<table width="100%" style="page-break-before: always" >
<tr><td>Code Willaya </td><td></td><td>رمز الولاية</td></tr>
<tr><td>Code de la commune </td><td></td><td>رمز البلدية</td></tr>
</table>
And there's the Java code used http://developers.itextpdf.com/2078
page-break-before
style attributes are only supported if the elements generated by the XML worker are directly added to the Document
, not if they are added to a table cell as in your example. Unfortunately RTL is only supported inside table cells.
As the example adds the elements itself, though, one can improve it to also interpret the page break marker properly, simply enhance the original loop
PdfPTable table = new PdfPTable(1);
PdfPCell cell = new PdfPCell();
cell.setRunDirection(PdfWriter.RUN_DIRECTION_RTL);
for (Element e : elements) {
cell.addElement(e);
}
table.addCell(cell);
document.add(table);
like this:
PdfPTable table = new PdfPTable(1);
PdfPCell cell = new PdfPCell();
cell.setRunDirection(PdfWriter.RUN_DIRECTION_RTL);
for (Element e : elements) {
if (e == Chunk.NEXTPAGE)
{
table.addCell(cell);
document.add(table);
document.newPage();
table = new PdfPTable(1);
cell = new PdfPCell();
}
else
{
cell.addElement(e);
}
}
table.addCell(cell);
document.add(table);
(You should probably add some checks to prevent empty tables to be added here.)
By the way, to make this example process your example at all, I had to comment out your title element. But this might be a difference between your XMLWorker version 5.5.6 and the version 5.5.11-SNAPSHOT I used here.