Hi,
Hi Crazkur,
Thanks for your inquiry. I am afraid Aspose.Pdf does not support to insert RTF text in PDF document at the moment, so we have logged a new feature request PDFNET-42241 for same. We will notify you as soon as it is implemented.
However as a workaround, you can accomplish your task with collaboration of Aspose.Words and Aspose.Pdf. In first step convert your RTF text to HTML using Aspose.Words as following and then add HTML text in PDF document using Aspose.Pdf.
string filePath = myDir + “test.rtf”;
Aspose.Words.FileFormatInfo info = Aspose.Words.FileFormatUtil.DetectFileFormat(filePath);
Console.WriteLine(info.LoadFormat);
Aspose.Words.LoadOptions loadOptions = new Aspose.Words.LoadOptions();
loadOptions.LoadFormat = Aspose.Words.LoadFormat.Rtf;
Aspose.Words.Document doc = new Aspose.Words.Document(filePath, loadOptions);
doc.Save(myDir + @"17.2.0.html");
Best Regards,
Hi,
thanks for your answer. Atm I am using a converter to convert my rtf to html. Therefore i dont need Aspose.Words.
Converter conv = new Converter();
byte[] content = Encoding.Default.GetBytes(rtfField.RtfText);
String htmlText = conv.ConvertRtfToHtml(content);
HtmlFragment html = new HtmlFragment(htmlText);
aspose_page.Paragraphs.Add(html);
This is what i am doing now. The Text i want to add is in my PdfDocument, but somehow always on a new page. I debugged it and from start to end my created Document contains only one page (i.e. aspose_page).
I need to be able to place the text wherever I want on the page i am building.
Is there any possible way to do this?
Greetings,
Crazkur
Hi Crazkur,
Thanks for your feedback. If you want to add Html text on some specific postion then you may use FloatingBox as following, hopefully it will help you to accomplish the task. However if the issue persist then please share your sample html text along with sample code, so we will test the scenario at our end and will guide you accordingly.
Aspose.Pdf.Document doc = new Aspose.Pdf.Document();
var page = doc.Pages.Add();
// page.PageInfo.Margin.Left = 0;
// page.PageInfo.Margin.Top = 0;
var floatingBox = new Aspose.Pdf.FloatingBox(200, 250)
{
Left = 0,
Top = 100
};
floatingBox.Paragraphs.Add(new Aspose.Pdf.HtmlFragment(html));
page.Paragraphs.Add(floatingBox);
doc.Save("FloatingBox.pdf");
Best Regards,
Hi,
Hi Crazkur,
Hi Crazkur,
Hi,
Hi Crazkur,
The issues you have found earlier (filed as PDFNET-41905) have been fixed in Aspose.Pdf for .NET 17.3.0.
This message was posted using Notification2Forum from Downloads module by Aspose Notifier.
Hi Crazkur,
Aspose.Pdf.Document
doc = new Aspose.Pdf.Document();<o:p></o:p>
Page page = doc.Pages.Add();
HtmlFragment html = new HtmlFragment("some text");
html.TextState = new TextState();
html.TextState.Font = FontRepository.FindFont("Calibri");
page.Paragraphs.Add(html);
doc.Save(myDir+"test.pdf");