IronPdf, как разрешить запуск тела X-margintop при создании новой страницы из-за переполнения элемента?C#

Место общения программистов C#
Ответить Пред. темаСлед. тема
Anonymous
 IronPdf, как разрешить запуск тела X-margintop при создании новой страницы из-за переполнения элемента?

Сообщение Anonymous »


so. Im trying to generate a pdf file, with a permanent header and footer ( though the footer is dynamic, means xxxx page 1 , xxxx page 2 and so on ).

I have the following code:

static string defaultPageCss = // $"body {{ direction: rtl; margin-top: 50px;}} \r\n" + $"body {{ direction: rtl;}} \r\n" + $"div {{ font-size: 100%; }} \r\n" + $"#specialDiv {{ font-size: 100%; color: red; }} \r\n" + $"table {{ border-collapse: collapse; }} \r\n" + $"table, th, td {{ border: 0px solid; }} \r\n" + $"p {{ white-space : break-spaces; }} \r\n"; public IronPdfUtil() : this(defaultPageCss) { } public IronPdfUtil(string pageCss = "") { // XElement head = new XElement("head"); if (pageCss != "") { // ... head.Add(new XElement("style", pageCss)); } // htmlPage = new XElement("html", head, new XElement("body", "") ); } public void AddPageElement(string name, string content, string id = "", string css = "") { XElement element = new XElement(name, content); if (id != "") { element.SetAttributeValue("id", id); } if (css != "") { element.SetAttributeValue("style", css); } insertElementAtTheEnd(element); } public void InsertElementAtTheEnd(XElement element) { XElement? searchResult = htmlPage.Descendants() .FirstOrDefault(el => el.Name == "body"); if (searchResult != null) { // add element as the last child of the body element searchResult.Add(element); } } here the method, and invokation:

private void BuildTitle(IronPdfUtil pdfUtil, Font font) { string hesberimTitle = MaagarTviotApi.Properties.Resources.hesberim_title; // Creates a paragraph element for the title XElement titleP = new XElement("p", hesberimTitle); // Inserts the title div into the PDF document pdfUtil.InsertElementAtTheEnd(titleP); } and here lets imagine a main method that will loop 20times that method to create element: BuildTitle(pdfUtil, fontUnderLine); Now, lets say I have a method using "AddPageElementAtTheEnd" and I invoke it 20times. Eventually, it will cause my page to have too many elements to keep up at the same page, and will create a new page.

Now, why did I mention the header? Because, I have a problem that these added elements dont really recognize the header( starting from the 2nd page ). So, if page a new page is automatically created. I want the next element added to be added below it the header.. Which I cant seem to make it work.


Источник: https://stackoverflow.com/questions/780 ... e-to-eleme
Реклама
Ответить Пред. темаСлед. тема

Быстрый ответ

Изменение регистра текста: 
Смайлики
:) :( :oops: :roll: :wink: :muza: :clever: :sorry: :angel: :read: *x)
Ещё смайлики…
   
К этому ответу прикреплено по крайней мере одно вложение.

Если вы не хотите добавлять вложения, оставьте поля пустыми.

Максимально разрешённый размер вложения: 15 МБ.

  • Похожие темы
    Ответы
    Просмотры
    Последнее сообщение

Вернуться в «C#»