RichTextBox Field is not rendering the HTML

@Amarsha

You are right. Aspose.PDF follows a coordinating system that starts from bottom-left. Unlike conventional coordinating system (x=0,y=0) means bottom-left in Aspose.PDF API. Therefore, you can implement the values as per the API specifications.

We totally understand your concerns, however, we are afraid that this particular requirement may need investigation and for that we need some sample information of your use case. If you are not comfortable with sharing your original code snippet and PDF, you can please create a sample console application with basic code and sample PDF and share it with us. We will use this application in our environment to replicate the behavior and apply modifications to meet your requirements.

@asad.ali : Thanks for prompt response. So, currently we have calculating like
int TopPosition = Convert.ToInt(Page.URY - RichTextBox.Rect.URY) - Version Aspose.PDF (10.5) - Its working fine.
int TopPosition = Convert.ToInt(Page.URY - RichTextBox.Rect.URY) - Version Aspose.PDF (22.11) - Its not working properly. As you said Bottom-Left means, how would be calculate the topPosition.
Anyway, i will send the sample code snippet and PDF.

Thanks for your Support!!

@asad.ali, Please find the code changes and attached PDF. Here, we are facing the issue is, While replace the RichTextBox to Table, we are facing the Top position issue and even in single line is not fitting to table and will render into next page. I
2) If we have more content, its not chopping or cut the characters based on the Table width and Height. Its rendering the next page or Its throwing the hard error. Version 10.5 → Sometimes, if content have more, its throwing the error without any proper message. So , we couldnt capture exception also. if any API documentation reference site, please let me know.

Sample_Template.pdf (85.8 KB)

Single_line_But_Render_in_New_Page.pdf (381.6 KB)

NextPage_Render_BigContent.pdf (382.1 KB)

Program.zip (1.4 KB)

@asad.ali , @tilal.ahmad : if any calculation to find the RichTextBox top position (replace from RichTextBox to Table), Please let me know. Thanks

@Amarsha

Thanks for sharing the sample requested information. We are checking it and will get back to you shortly.

@asad.ali : Dude, my business is stick with 10.5 or 22.11. Please give us some alternate solutions to fix the issues. Either render the all Html tags in RichtextBox or Replace the RichtextBox and render the table in page in any places (even bottom also) Or Atleast let us know, how to get the proper exception from Aspose.PDF, if any issues

Thanks,
Amar

@Amarsha

Right now, we are testing the scenario in our environment and will be sharing our response shortly.

@Amarsha

We have again tried to achieve your requirements using below code snippet. We tried to add a rectangle on the same position where RichTextBox is present and we got attached results.
New.pdf (86.6 KB)

Document doc = new Document(dataDir + "Sample_Template.pdf");
if (doc != null)
{
    //Aspose.Pdf.Facades.Form frmObj = new(doc);
    Rectangle recRichTxtObj = new Rectangle(0, 0, 0, 0);
    Rectangle recPageObj = doc.Pages[1].GetPageRect(true);
    int txtTop = 0;
    var canvas = new Drawing.Graph((float)doc.Pages[1].GetPageRect(true).Width, (float)doc.Pages[1].GetPageRect(true).Height);
    canvas.Margin = new MarginInfo(0, 0, 0, 0);
    doc.Pages[1].Paragraphs.Add(canvas);
    foreach (Field fldObj in doc.Form)
    {
        RichTextBoxField txtObj = (RichTextBoxField)fldObj;

        if (txtObj != null)
        {
            recRichTxtObj = txtObj.Rect;
            txtTop = Convert.ToInt32(recPageObj.URY - recRichTxtObj.URY);

            HtmlFragment html = new HtmlFragment("<b>Testing PDF is generated by Aspose.PDF. This is nice to working and rendering.</b> <i>test</test>");

            Aspose.Pdf.Drawing.Rectangle rect = new Aspose.Pdf.Drawing.Rectangle((float)recRichTxtObj.LLX - (float)doc.Pages[1].PageInfo.Margin.Left, (float)txtTop - (float)doc.Pages[1].PageInfo.Margin.Top, (float)recRichTxtObj.Width, (float)recRichTxtObj.Height);

            var c = ColorTranslator.FromHtml("#FFFF00");
            rect.Text = new TextFragment("test address , test address esttest address , test address testtest address , test address test");
            rect.GraphInfo.Color = Aspose.Pdf.Color.FromRgb(c);
            canvas.Shapes.Add(rect);
        }
    }
    doc.Save(dataDir + "New.pdf");
}

We were unable to notice any exception though. Please note that we tested the scenario using 23.10 version of the API. Therefore, a ticket has been logged accordingly in our issue tracking system as PDFNET-55801 to further test whether and how this requirement can be achieved. We will investigate it and let you know as soon as the ticket is resolved. We apologize for the inconvenience.

@asad.ali , @tilal.ahmad : Thanks for example code snippet. But, you have used the textFragment instead of HtmlFragment. I hope you know, Drwaing.Rectangle will not accept the HtmlFragment.

If you give the more content, it will not chopping the text like textbox. It will render into Next page. Where i can get the example code snippet, i dont know. Even your people will not give the proper code snippets. Anyway, Thanks.

@Amarsha

We did not provide you above code snippet as a solution. We shared our attempt with you that we did just to put an object over the same location where Rich Textbox is present already. If it was succeeded, we could change the object with some other type of annotation that can support HTML as well as keep the content withing boundary.

Regretfully, it is quite dicey to come up with a solution to the scenario that you are actually presenting. Therefore, the investigation ticket was logged to further analyze this scenario in depth and try to come up with some work around. We apologize for the inconvenience caused.