Boostrap minimum scale with rotativa PDF

I have a problem when using rotativa that my loading page is always scaled to the minimum when printed. Is there a way to set the viewport size for my view so that it doesn't scale the bootstrap to the minimum for PDF generation?

Controller implementation

[HttpGet]
public ActionResult DownloadViewPDF()
{
    var vm = new Viewmodel();
    return new Rotativa.ViewAsPdf("SummaryPDF", vm) { FileName = "TestViewAsPdf.pdf", PageSize = Size.A4 };
}

      

And this is my general implementation of the view

<div class="row">
    <div class="col-sm-6">
        <div class="form-group">
            <span class="label">Email</span>
            <span class="form-control-static">test@email.com</span>
        </div>
    </div>
    <div class="col-sm-6">
        <div class="form-group">
            <div class="required-enabled">
                <span class="label">Phone</span>
                <span class="form-control-static">(804) 222-1111</span>
            </div>
        </div>
    </div>
</div>

      

I have tried several things, for example using PageSize, PageHeight, PageWidth of rotativa parameters. Nothings seems to prevent scaling. I also tried using CustomSwitches but could not find a setting that provides the result I wanted.

I have also tried setting the static size of the viewport in the html meta tag and encapsulating my view in a static width div. None of these things seem to scale the PDF to the smallest possible bootstrap display.

+3


source to share


4 answers


As a result, the solution turned all of our responsive designs into tables, thus creating a flexible design for the print section. It seemed that I could not find another way. It would be nice if the function only specified the size of the viewport to print. In the meantime, there is no need to worry about it. ”



0


source


I am using the "--viewport-size" switch



new ViewAsPdf("Edit", model) { PageOrientation = Orientation.Landscape, CustomSwitches = "--viewport-size 1000x1000" };

      

+3


source


The solution is to change everything col-md

and col-sm

on col-xs

. This should do the trick.

0


source


you need to change col-sm-*

tocol-xs-*

-1


source







All Articles