Welcome Guest Search | Active Topics | Sign In | Register

MVC convert to pdf bootstrap.css styles not applied Options
dm
Posted: Wednesday, July 6, 2016 3:16:47 PM
Rank: Newbie
Groups: Member

Joined: 8/9/2013
Posts: 6
I am using bootstrap.css and using its grid css to style the layout. However, when I convert to pdf the grid styles are lost. Anything I should be doing differently?

Below is my code:

_layout.cshtml
Code: HTML/ASPX
<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>@ViewBag.Title</title>
    <link href="~/Content/bootstrap.min.css?rev=1" rel="stylesheet" type="text/css" />
    <link href="~/Content/bootstrap-theme.min.css" rel="stylesheet" />
    <script src="~/Scripts/modernizr-2.6.2.js"></script>
</head>
<body>
    <div class="navbar navbar-inverse navbar-static-top">
        <div class="container">
            <div class="navbar-header">
                <span class="navbar-brand"></span>
            </div>
            <div class="navbar-collapse collapse">
                <ul class="nav navbar-nav">
                </ul>
            </div>
        </div>
    </div>

    <div class="container body-content">
        @RenderBody()    
    </div>
    <script src="~/Scripts/jquery-1.10.2.min.js"></script>
    <script src="~/Scripts/bootstrap.min.js"></script>
</body>
</html>


Controller.cs

Code: C#
[HttpPost]
        [RenderAsPDF(AutoConvert = false)]
        public ActionResult TimeSheet(TimeSheetViewModel model)
        {
            // convert to pdf
            MVCToPDF.SendToClient = false;
            HtmlToPdf.Options.OutputArea = new RectangleF(0.5f, 0.5f, 7.5f, 10f);
            MVCToPDF.RenderAsPDF();

            return View("TimeSheet", model);
        }


        protected override void OnResultExecuted(ResultExecutedContext filterContext)
        {
            base.OnResultExecuted(filterContext);

            HtmlToPdfResult result = MVCToPDF.Result;
            if (result != null)
            {
                string pdfFileName = "c:\\test.pdf"; 
                result.PdfDocument.Save(pdfFileName);
            }
        }
eo_support
Posted: Thursday, July 7, 2016 11:13:08 AM
Rank: Administration
Groups: Administration

Joined: 5/27/2007
Posts: 24,275
Hi,

What version of EO.Pdf are you using?

Thanks!
dm
Posted: Thursday, July 7, 2016 11:33:28 AM
Rank: Newbie
Groups: Member

Joined: 8/9/2013
Posts: 6
EO.2016
MVC4
dm
Posted: Thursday, July 7, 2016 4:12:14 PM
Rank: Newbie
Groups: Member

Joined: 8/9/2013
Posts: 6
The issue I'm having has nothing to do with EO. The issue is related to the css classes I applied for the bootstrap grid layout. I changed it from col-md-1 to col-sm-1 and this solved the layout issue in the pdf.
eo_support
Posted: Thursday, July 7, 2016 5:17:09 PM
Rank: Administration
Groups: Administration

Joined: 5/27/2007
Posts: 24,275
Great. Glad to hear that you found out the root of the problem.

Thanks!


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.