Welcome Guest Search | Active Topics | Sign In | Register

Setting Page Orientation - HtML to PDF Lanscape with @page css Options
Levent
Posted: Wednesday, March 18, 2020 1:15:37 PM
Rank: Newbie
Groups: Member

Joined: 3/18/2020
Posts: 1
I want to change the page orientation to landscape for pages with wide tables. Can I use "named pages" to change page orientation?

I would like to change page orientation with @page CSS but it is not working.

The following document mentions that I can change page orientation with @page CSS but it is not in my example. https://www.essentialobjects.com/doc/pdf/htmltopdf/page_size.aspx

Here is my HTML:

Code: HTML/ASPX
<!DOCTYPE html>
<html>
<head>

<style>
h1 {
    color: blue;
}
@media print {
    h1 {
        color: red;
    }
    @page {
        size: landscape;
        margin: 0;
    }
}
</style>
</head>
<body>
<h1>
test
</h1>
</body>
</html>


Here is my converter code
Code: C#
MemoryStream ms = new MemoryStream();
            HtmlToPdf.Options.UsePrintMedia = true;
            
            var conversion = HtmlToPdf.ConvertHtml(htmlString, ms);


            return ms.ToArray();


You cannot post new topics in this forum.
You cannot reply to topics in this forum.
You cannot delete your posts in this forum.
You cannot edit your posts in this forum.
You cannot create polls in this forum.
You cannot vote in polls in this forum.