Format the string

Hi all,


I have a textbox value that is a very long string. I need to break it down and append on PDF document , with the formatting. I am using ASPOSE PDF for .net application. Please help me out.


Thanks

Hi Vaishali,


Thanks for using our products.

As far as I have understood from your requirement, you need to get the value of TextBox object and place it inside PDF document with formatting information. If so is the case, then please visit the following link for instructions on how to Add Text in an Existing PDF File

In case I have not properly understood your requirement, please share some more details.

Hello,


Thanks for Quick reply , I tried the piece of code. It works but the string in textbox is longer than one line, I have to somehow break it down in list or para. As we know html controls merely look like text in textbox instead of formatting, I am not able to format my text at server side. Is there anyway I can convert this string as paragraph and append on the document. How do you I know the position?


Thanks
Vaishali

vsaral:
I am not able to format my text at server side.

Hi Vaishali,

Thanks for sharing the details.

Do you mean that you are not able to see text formatted inside PDF document or the text is not formatted in TextBox which you are using ?

vsaral:
Is there anyway I can convert this string as paragraph and append on the document.

Please note that when adding text inside PDF document, if the text reaches right border of the page, its automatically wrapped to next line and it presents the look of paragraph. Can you please share some sample Image/document which can help us in understanding this requirement.

vsaral:
How do you I know the position?
Do you mean the location where you need to place the Text ?
Please note that Aspose.Pdf for .NET offers the capability to specify the absolute positioning where the text will be added.

Hi


Thanks for reply. I am trying to replace a word with whole string. It doesn’t change line. I am attaching my pdf file. Please help.

This is my code to replace special words from existing pdf. Textbox values are multiliner.

TextFragmentAbsorber textFragmentAbsorber7 = new TextFragmentAbsorber("-Allergies");
//accept the absorber for all the pages
pdfDocument.Pages.Accept(textFragmentAbsorber7);
//get the extracted text fragments
TextFragmentCollection textFragmentCollection7 = textFragmentAbsorber7.TextFragments;
foreach (TextFragment textFragment7 in textFragmentCollection7)
{
//update text and other properties
textFragment7.Text = TextBox7.Text;
textFragment7.TextState.Font = FontRepository.FindFont("Verdana");

}

Hi,


Did you find out anything? please help me out, need it urgently.

Thanks
Vaishali

Hi Vaishali,<?xml:namespace prefix = o ns = "urn:schemas-microsoft-com:office:office" />

I checked your sample code with your attached PDF file and it works fine. I noticed an extra “-“ in TextFragmentAbsorber("-Allergies") which might be causing the problem. Once I remove "-", the code works fine and the text gets replaced. Please check it and let me know if it works fine for you by making the above correction.

Thank You & Best Regards,

Hi the “-” is not really a problem i have other words without “-”

//TextFragmentAbsorber textFragmentAbsorber5 = new TextFragmentAbsorber(“Medicine”);
////accept the absorber for all the pages
//pdfDocument.Pages.Accept(textFragmentAbsorber5);
////get the extracted text fragments
//TextFragmentCollection textFragmentCollection5 = textFragmentAbsorber5.TextFragments;
//foreach (TextFragment textFragment5 in textFragmentCollection5)
//{
// //update text and other properties
// textFragment5.Text = txtHomeCare.Text;
// textFragment5.Text = TexthTML.Value;
// textFragment5.TextState.Font = FontRepository.FindFont(“Verdana”);
}

Like this one, if you put a very big string at place for txtHomecare.Text . The whole string get terminated after one line. try to replace “Medicine” with this string

“IF YOU NEED HELP FROM A MEMBER OF THE HOSPITALIST TEAM FOLLOWING YOUR DISCHARGE TO CLARIFY YOUR POST-DISCHARGE PLANS, MEDICATIONS OR TREATMENTS, PLEASE CALL MAGGIE NEELY (CASE MANAGER) AT 410-502-5302. IF YOU NEED HELP DURING NON-BUSINESS HOURS, CALL THE HOSPITALIST UNIT FRONT DESK AT 443-287-3127. IF IT IS AN EMERGENCY, CALL 911.PLEASE BE SURE TO TAKE ALL MEDICATIONS AND YOUR BLUE DISCHARGE FOLDER WITH YOU, WHEN YOU GO IN TO SEE YOUR PRIMARY DOCTOR.”

Thanks in advance

Hi Vaishali,<?xml:namespace prefix = o ns = "urn:schemas-microsoft-com:office:office" />

Thank you for the feedback.

I am able to generate your mentioned issue after further testing. Your issue has been registered in our issue tracking system with issue id: PDFNEWNET-33994. We will notify you via this forum thread regarding any update against your issue.

Sorry for the inconvenience,