using RadFixedDocument to export HTML view

1 Answer 550 Views
PdfProcessing
Nguyen
Top achievements
Rank 1
Nguyen asked on 02 Jun 2021, 08:25 AM

Hi team Telerik

Now, I using RadFixedDocument to export PDF include html,

sample

            row1TableCell.Borders = new TelerikEditting.Tables.TableCellBorders(tableBorder, tableBorder, tableBorder, tableBorder);
            Block row1TableCellBlock = row1TableCell.Blocks.AddBlock();
            row1TableCellBlock.InsertText("<a href="google.com" taget="_blank"> Click</a>");

Block can insert only text,

How can I insert html,
Please help me,
Thanks

 

1 Answer, 1 is accepted

Sort by
0
Dimitar
Telerik team
answered on 03 Jun 2021, 11:51 AM

Hi Nguyen,

I am afraid that it is not possible to add HTML in such a manner. The pdf format is completely different from the HTML and you cannot directly add elements in this way. You will need to manually match any HTML element to the PDF ones

For this case, you can add an UriAction and specify the rectangle in the file where the link will be active (you will need to draw the text as well):

var doc = new RadFixedDocument();
var page = doc.Pages.AddPage();
var editor = new FixedContentEditor(page);


editor.GraphicProperties.FillColor = new RgbColor(0, 0, 255);
editor.Position.Translate(50, 30);
editor.DrawText("Telerik");

UriAction uriAction = new UriAction();
uriAction.Uri = new Uri(@"http://www.telerik.com");

var uriLink = page.Annotations.AddLink(uriAction);
uriLink.Rect = new Rect(50, 30, 50, 30);

var provider = new PdfFormatProvider();
File.WriteAllBytes(@"..\..\resul.pdf", provider.Export(doc));

More information is available here: Annotations and Destinations.

I hope this helps. Should you have any other questions do not hesitate to ask.

Regards,
Dimitar
Progress Telerik

Virtual Classroom, the free self-paced technical training that gets you up to speed with Telerik and Kendo UI products quickly just got a fresh new look + new and improved content including a brand new Blazor course! Check it out at https://learn.telerik.com/.

Tags
PdfProcessing
Asked by
Nguyen
Top achievements
Rank 1
Answers by
Dimitar
Telerik team
Share this question
or