locked
Asp.Net MVC 5 Rotativa 2.0.2 RRS feed

  • Question

  • User-859252243 posted

    Update: translated by English. Normally non English posts are not allowed and deleted. As it got already some replies and apparently an answer I decided to use deepl.com to translate it (and change a bit as vin should be fin according to me - XIII):

    Hey, everybody,

    I'm trying to change the orientation of my pdf page generated with Rotativa 2.0.2. All that I see on the net so far doesn't help me, certainly because of my version of Rotativa. So please help me.

    Sincerely

    Original: 

    Salut à tous,

    J'essaie en vin de modifier l'orientation ma page pdf générée avec Rotativa 2.0.2. Tous ce que je vois sur le net jusqu'a présent ne m'aide pas, certainement à cause de ma version de Rotativa. Donc aidez moi svp !!!

    Cordialement,

    Tuesday, June 9, 2020 11:25 AM

All replies

  • User1686398519 posted

    Hi,  Anliou

    According to your needs, I made an example, please refer to it.You need to set "PageOrientation".

    Remarks: This is an English forum. You should submit your question in English so that it can better help you.

    Controller

            public ActionResult ViewAsPDF()
            {
                return View();
            }
            public ActionResult OrientationPortraitPDF()
            {
                var demoViewPortrait = new ViewAsPdf("ViewAsPDF")
                {
                    FileName = "OrientationPortrait.pdf",
                    PageOrientation = Rotativa.Options.Orientation.Portrait,
                };
                return demoViewPortrait;
            }
            public ActionResult OrientationLandscapePDF()
            {
                var demoViewLandscape = new ViewAsPdf("ViewAsPDF")
                {
                    FileName = "OrientationLandscape.pdf",
                    PageOrientation = Rotativa.Options.Orientation.Landscape,
                };
                return demoViewLandscape;
            }

    ViewAsPDF

    @Html.ActionLink("testOrientationPortrait", "OrientationPortraitPDF", "Home")
    <br />
    @Html.ActionLink("testOrientationLandscape", "OrientationLandscapePDF", "Home")
    <table>
        @for (int i = 0; i < 50; i++)
        {
            <tr><td>@i</td></tr>
        }
    </table>

    Here is the result.

    Best Regards,

    YihuiSun

    Wednesday, June 10, 2020 2:28 AM
  • User-859252243 posted
    That you did not working with me. But I already found the solution.
    return new ViewAsPdf()
    {
    RotativaOptions = new Rotativa.Core.DriverOptions()
    {
    PageOrientation = Rotativa.Core.Options.Orientation.Landscape,
    }
    };
    Wednesday, June 10, 2020 8:11 PM
  • User1686398519 posted

    Hi,  Anliou

    I'm glad you have found a solution. My example uses Rotativa, and you use Rotativa.Core, so the writing is a bit different.

    Best Regards,

    YihuiSun

    Friday, June 12, 2020 5:35 AM