Hello,
Thanks for your response.
For your first question, when using our Spire.Doc, you can create a textbox and then add the RTF text to the textbox. Below is the corresponding code for your reference.
- Code: Select all
Document doc = new Document();
Section section = doc.AddSection();
Paragraph paragraph = section.AddParagraph();
TextBox tb = paragraph.AppendTextBox(220, 220);
//Set the position of the textbox
tb.Format.HorizontalOrigin = HorizontalOrigin.Page;
tb.Format.HorizontalPosition = 50;
tb.Format.VerticalOrigin = VerticalOrigin.Page;
tb.Format.VerticalPosition = 50;
tb.Body.AddParagraph().AppendRTF("your rtf text");
//set shape fit to text
//tb.Format.IsFitShapeToText = true;
doc.SaveToFile("result.pdf", FileFormat.PDF);
For your second question, do you mean to get the location of the rtf text in the PDF document? If so, our Spire.PDF supports finding the text and getting its location information, like the following code.
- Code: Select all
PdfDocument pdf = new PdfDocument();
pdf.LoadFromFile(@"input.pdf");
PdfTextFind[] result = null;
foreach (PdfPageBase page in pdf.Pages)
{
//Find text
result = page.FindText("keyword", TextFindParameter.None).Finds;
foreach (PdfTextFind find in result)
{
//Get its bouds
RectangleF bounds = find.Bounds;
}
}
If there are any misunderstandings, please provide more detailed information to help us investigate further, such as your RTF text and your desired output.
Sincerely,
Rachel
E-iceblue support team