I'm making a PDF in iText for dotnet using pdf2Html. I convert the HTML to elements, add the element to a document, and after that I add footer, header, left side text and right side text for each page. I have a working version of the solution, but for the left side. I've tried to make it work on the right side by rotating the text in the opposite, and adjusting the canvas, but with no luck. This is what I have for the left side text:
public class LeftSideText
{
float angle = (float)(-3 * Math.PI / 2);
public void PrintLeftSideText(ref Document pdfDocument, ref PdfPage oCurrentPage, int iCurrentPage, int iTotalPages, int iLeftMargin, int iRightMargin, int iFooterHeight, string sHtml, string sHtmlElement, ConverterProperties oConverterProperties)
{
Canvas canvas = new Canvas(new PdfCanvas(oCurrentPage), oCurrentPage.GetPageSize());
sFooterHtml = "<div>" + sHtml + "</div>";
Div oDiv = (Div) HtmlConverter.ConvertToElements(sHtmlElement + sHtml, oConverterProperties).First();
_ = canvas.Add(
oDiv.SetMarginLeft(0)
.SetRotationAngle(angle)
.SetHeight(50)
.SetWidth(oCurrentPage.GetPageSize().GetHeight())
);
canvas.Close();
}
}
Thanks!
I've used float angle = (float)(3 * Math.PI / 2); in the rotation and changed the position of canvas from the previous example.