2

I am using TuesPechkIn to convert my html to PDF. I am setting the configuration as follows:

My question is, can I remove the top margin from the first page of the PDF only? (Basically its the cover page which includes a banner image). Is there any way to implement this.

        var document = new HtmlToPdfDocument
        {
            GlobalSettings =
            {
                DocumentTitle = "My Report",
                PaperSize = PaperKind.A4, 
                Margins =
                {
                    Top = 1.25, //Need to make it as 0 for the first page
                    Left = 0.00,
                    Right = 0.00,
                    Bottom = 1.25,
                    Unit = TuesPechkin.Unit.Centimeters
                },
                PageOffset = 2
            },
            Objects =
            {
                new ObjectSettings
                {
                    HtmlText = htmlText,
                    FooterSettings = footerSettings
                }
            }
        };

        return converter.Convert(document);

1 Answers1

0

A work around would be to remove that image in JavaScript. I was having the same issue on an element in the last bottom page an basically what I did was:

var element = document.getElementById("someID");
    element.parentNode.removeChild(element);

put that code when the window loads and add it to your htmlText, it will remove the element for you before it generates the PDF. To do this you need to enable js by simply adding to your Objects :

WebSettings =
                    {
                        EnableJavascript = true
                    }

Hope it helps you :)

Elis
  • 91
  • 1
  • 4