Hello,
I am reading text from an XML file to be placed into a dynamically generated PDF document. The XML file has CDATA so that it can include bold and italics. I am struggling with the logic of how to find the link inside the XML and create a link object that is at the x/y coordinates of the link within the text. The text from the XML file is being placed into a FormattedTextArea. Please see code below for an explanation:
XML:
<p link1="www.somewhere.com" url1="http://www.somewhere.com"><![CDATA[If we remove drugs from our formulary, add prior authorization, quantity limits and/or step therapy restrictions on a drug or move a drug to a higher cost-sharing tier, we must notify affected members of the change at least 60 days before the change becomes effective, or at the time the member requests a refill of the drug, at which time the member will receive a 60-day supply of the drug. If the Food and Drug Administration deems a drug on our formulary to be unsafe or the drug’s manufacturer removes the drug from the market, we will immediately remove the drug from our formulary and provide notice to members who take the drug. To get updated information about the drugs covered by us, please visit our website at www.somewhere.com or call Customer Service at (111) 111-1111 or toll free (888) 888-8888, 8AM to 8PM, 7 days a week. Our printed formulary is updated on an annual basis. Some drugs may have been added or removed from the list after this formulary was printed.]]></p>
C# Code:
fta = Common.CreateFormattedTextArea(text, currentX, currentY, m_IntroductionColumnWidth, VerdanaFontFamily, FontSize);
fta.Tag = Common.CreateStructureElement(tagType, SectionStructureElement);
CurrentPage.Elements.Add(fta);
Common Method:
public static FormattedTextArea CreateFormattedTextArea(string text, float x, float y, float width, FontFamily fontFamily, float fontSize)
{
FormattedTextArea fta = new FormattedTextArea(text, x, y, width, 0, fontFamily, fontSize, true);
fta.Height = fta.GetRequiredHeight();
return fta;
}
I have tried to read the text on an OverflowFormattedTextArea but receive an exception, so that approach is out. What I'm wanting to do is to read the text line by line (that fits into the IntroductionColumnWidth) and see if "link1" from the XML node is present. If so, I need to get the X and Y of its location so that I can create a link like so:
link = new Link(fta.X, fta.Y + 2, Verdana.GetTextWidth(((string)elem.Attribute("link1")));, FontSize), FontSize, new UrlAction((string)elem.Attribute("url1")));
link.Tag = Common.CreateStructureElement(tagType, (StructureElement)fta.Tag);
CurrentPage.Elements.Add(link);
The main purpose of this is for Section 508 accessibility so I must be able to tag the appropriate links in their correct locations.
Do you have any ideas or input that could help me out?
Thank you for your time!
Matt L.
FormattedTextArea link question
Re: FormattedTextArea link question
Support · Dec 19, 2011Hello Matt,
It is not possible to get the overflow text from the FormattedTextArea using our DynamicPDF Generator for .NET product. Also it is not possible to read the text line by line from the FormattedTextArea. You will need to build the complete formatted text and pass it as string to the FormattedTextArea class constructor. Also refer the documentation on supported tags by our DynamicPDF API at: http://www.DynamicPDF.com/Support/NET_Help_Library_11_11/Formatted%20Text%20Area%20Formatting.html
.
It is not possible to get the X and Y position of a text within the string which you are passing into the FormattedTextArea class constructor.
Thanks,
ceTe Software Support Team.