If I insert 2 lines of HTML into a FormattedTextArea object that could support 20, how do I find the X,Y position of the last insert rather than the total size of the FormattedTextArea.
Get Last FormattedTextArea Coordinate
Re: Get Last FormattedTextArea Coordinate
Support · Jul 26, 2012Hello,
You can get the X and Y positions using X and Y properties of the FormattedTextArea class. It is not possible to get the X and Y positions of the particular text within the FormattedTextArea using our DynamicPDF Generator for .NET product.
If the above suggestions do not meet your requirements then please give more details about your requirements and also mention what you are trying to achieve using our DynamicPDF products. You can also contact our [^a|mailto:support@cete.com|opennewwindow|Support^] team by sending your requirements.
Thanks,
ceTe Software Support Team.
Re: Get Last FormattedTextArea Coordinate
Forum member · Jul 26, 2012Hi - if I'm placing variable HTML content into a FormattedTextArea that may be 1 line or 20 ideally I'd like to find out the position where the last text was positioned to avoid a large block of whitespace between the end of the short contents in the larger FormattedTextArea and the next object inserted in the document.
Is that possible? If not do you have an alternate best practice - eg., should I use a collection of shorter FormattedTextAreas using the overflow mechanism iteratively across page boundaries until I exhaust the HTML content so that I have a smaller amount of whitespace at the end of the last FormattedTextArea?
It would be great if there was an x,y position property in the FormattedTextArea object that could be read after an insert to retrieve the last pixel added.
Hope this use case makes more sense and thanks for your prompt reply!
Re: Get Last FormattedTextArea Coordinate
Support · Jul 26, 2012Hello,
You can add page elements one below the other by dynamically calulating the height required to fit the contents and adding the other page element below by setting the claulated X and Y position coordinates. Below is the sample code for it. The sample code shows adding two FormattedTextAreas to the page with different contents one below another.
Document document = new Document();
Page page = new Page();
FormattedTextAreaStyle style = new FormattedTextAreaStyle(FontFamily.Helvetica, 16F, true);
string text = "This is to test FormattedTextArea";
FormattedTextArea formattedTextArea1 = new FormattedTextArea(text, 0, 0, 100, 100,style);
//Setting the height as required height so that it can fit the contents.
formattedTextArea1.Height = formattedTextArea1.GetRequiredHeight();
page.Elements.Add(formattedTextArea1);
float x = formattedTextArea1.X;
float y = formattedTextArea1.Y + formattedTextArea1.Height + 10;
string newText = "New contents added using another FormattedTextArea page element below the first FormattedTextArea";
//Setting claulated X,X positions to other FormattedTextArea.
FormattedTextArea formattedTextArea2 = new FormattedTextArea(newText, x, y, 100, 100, style);
//Setting the height for the required height so that it can fit the contents.
formattedTextArea2.Height = formattedTextArea2.GetRequiredHeight();
page.Elements.Add(formattedTextArea2);
document.Pages.Add(page);
document.Draw(@"C:\Test.pdf");
Thanks,
ceTe Software Support Team.
Re: Get Last FormattedTextArea Coordinate
Forum member · Jul 28, 2012Got it - GetRequiredHeight() was the method I failed to find. Thanks very much for your prompt support!