Insert section into top of every page generated when using html import

1 Answer 148 Views
PdfProcessing
Rick
Top achievements
Rank 1
Veteran
Rick asked on 07 Jan 2022, 03:41 PM

I want to be able to feed a table of data into the html importer, and have it figure out how many pages it needs to generate, but while doing that, have it add a page header to every page that the text from the table must always come under.

Is this possible or am I going to have to determine if the line i want to add for every html row can still fit on the page and if not, create a new page myself?

1 Answer, 1 is accepted

Sort by
0
Dimitar
Telerik team
answered on 11 Jan 2022, 06:55 AM

Hello Rick,

The WordsProcessing library does not have any layout at this point and there is no way to determine the required page count. Usually, the document content is measured when the document is opened in an application like MS Word and it dynamically determines what fits on each page.  

To add repeating content you can use headers and footers which are automatically added to each page. More information is available here: WordsProcessing - Headers and Footers.

Are you converting this to PDF or another format? If using PDF, the converted table should be split automatically. If you want to repeat the header row, you can check the following feature request which contains a project with a workaround for this: WordsProcessing: Add support for the RepeatOnEveryPage property of TableRow in PDF export

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

Regards,
Dimitar
Progress Telerik

Love the Telerik and Kendo UI products and believe more people should try them? Invite a fellow developer to become a Progress customer and each of you can get a $50 Amazon gift voucher.

Rick
Top achievements
Rank 1
Veteran
commented on 11 Jan 2022, 04:13 PM

I didn't specify well enough.

I am importing the html into a pdf doc, not a word doc.

Am I able to add the headers and footers to every pdf page, and the html import will automatically position the rows of data between the objects on each page?

Dimitar
Telerik team
commented on 12 Jan 2022, 07:20 AM

Hi Rick, 

Yes, I have added a small demo that shows how this works.

Let me know if I can assist you further.
Rick
Top achievements
Rank 1
Veteran
commented on 21 Jan 2022, 07:24 PM

Hi Dimitar, this seems to be working, thank you.

An issue has arisen, I have ported the example work into my .net 6 blazor project and can't get past an issue with RadFlowDocument needing presentationcore.

Is RadFlowDocument working with Blazor Wasm .net6?

 

 

Rick
Top achievements
Rank 1
Veteran
commented on 21 Jan 2022, 08:08 PM

Opps, I noticed i had to install different telerik libraries, works fine now.
Dimitar
Telerik team
commented on 24 Jan 2022, 10:26 AM

Yes, you need to use the version for NET Standard. More information about this is available here: PdfProcessing - Cross-Platform Support.

Do not hesitate to contact us if you have other questions.
Rick
Top achievements
Rank 1
Veteran
commented on 24 Jan 2022, 03:01 PM

Hi Dimitar, can I import html into the header as well?

I find i can use html to import to build the content of the document but haven't found yet how you import html to build the header and footers, haven only found how to add blocks of paragraphs or tables, but would like to use html if possible.

Rick
Top achievements
Rank 1
Veteran
commented on 24 Jan 2022, 07:43 PM

To be specific:

I am working with a Blazor Wasm project.

I would like to create the repeating page headers and footers by importing html, like I can when I create the content for the document itself.

Headers will have an image that is in the website directory, I would assume I could link this with an html image tag.

I assume all of this is possible? What command am I not seeing for the header to tell it to import from html?

Thank you!

Dimitar
Telerik team
commented on 25 Jan 2022, 11:03 AM

Hi Rick,

To achieve this you still need to import the HTML to a RadFlowDocuemnt and then use the RadFlowDocumentEditor to insert it. Here is an example of this: 

var headerdoc = htmlProvider.Import(File.ReadAllText(@"..\..\HTMLPage1.html"));
var header = document.Sections.First().Headers.Add();
var editor = new RadFlowDocumentEditor(header.Document);
var par = header.Blocks.AddParagraph();
editor.MoveToParagraphStart(par);
editor.InsertDocument(headerdoc);

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