MVC打印分页功能不起作用,内容被切断

时间:2018-05-28 04:28:07

标签: html css asp.net-mvc asp.net-core

我尝试下面的代码打破页面而打印但是它不起作用,我了解到分页符不能在嵌套的div标签中工作,我不知道如何实现这一点,基本上我试图显示图像,所以连续将有4或更多基于屏幕的显示尺寸但是在打印时它应该连​​续打印4个图像,接下来的4个图像应该在下一页打印,就像现在一样打印,图像和内容被切断,请帮忙

     <div class='row small'>
        @foreach (var item in Model.BuyerList.ImageList)
        {

            <div class="card bg-light mb-3 mr-1 card-text-fixed-width" style='page-break-after:always'>
                <div class="img-control">
                    @if (!string.IsNullOrWhiteSpace(item.ImageUrl))
                    {
                        <img src="@item.ImageUrl" style="height:150px;" class="card-img-top" alt="Card image" />
                    }
                    else
                    {
                        <img src="~/AdTrack Images/NoProductImage.png" style="height:150px;" class="card-img-top" alt="Card image" />
                    }
                      <div class="edit d-print-none">
                            <a data-toggle="modal"
                               data-id='{"id": "@item.Items.Number","ItemId":"@item.Items.ItemId", "AdId":"@item.Header.Id"}'
                               class="open-AddBookDialog btn btn-primary" href="#"><i class="fa fa-pencil fa-lg"></i></a>
                        </div>

                        <div class="delete d-print-none">
                            <a data-toggle="modal" data-id='{"id": "@item.Items.Number","ItemId":"@item.Items.Id", "AdId":"@item.Id"}'
                               class="open-delete btn btn-primary" href="#">
                                <i class="fa fa-trash" style="font-size:15px;color:red" id="delete" name="delete"></i>
                            </a>
                        </div>

                        <div class="edit d-print-none">
                            <a data-toggle="modal"
                               data-id='{"id": "@item.Items.Number","ItemId":"@item.Items.ItemId", "AdId":"@item.Header.Id"}'
                               class="open-AddBookDialog btn btn-primary" href="#"><i class="fa fa-info-circle fa-lg"></i></a>
                        </div>
                    }
                </div>
                <div class="card-header">
                    <div class="font-weight-bold">Page @Html.DisplayFor(modelItem => item.Number)- @Html.DisplayFor(modelItem => item.Business)</div>
                    <div class="row mb-2 font-weight-bold">
                        <div class="col-md-6">Cut: @Html.DisplayFor(modelItem => item.Items.Number)</div>
                        <div class="col-md-6 text-right">9-Box: @Html.DisplayFor(modelItem => item.Items.BoxNumber)</div>
                    </div>
                    <div class="row mb-2 font-weight-bold">
                        <div class="col-md-4">Group @Html.DisplayFor(modelItem => item.Department.Test)</div>
                        @*<div class="col-md-4">Div: @Html.DisplayFor(modelItem => item.Department.Division)</div>*@
                        <div class="col-md-4">Buyer @Html.DisplayFor(modelItem => item.Department.Test)</div>
                        <div class="col-md-4">Dept @Html.DisplayFor(modelItem => item.Items.Department)</div>
                    </div>
                </div>

</div>
        }
        </div>

2 个答案:

答案 0 :(得分:0)

使用TabPane添加换行vbox.getChildren().add(tabPane);

div

答案 1 :(得分:0)

我遇到了类似的问题,但是我使用CSS实现了它。只需添加一个css类,并以百分比形式给出宽度。例如,如果要显示3张图片,则为30%;如果要显示4张图片,则为19%;如果要在图像之间留出空格,还可以相应地设置边距。通过这种方式,无论屏幕尺寸如何,图像都会相应调整大小。

示例:

img {
 width: 30%;
 float: left;
 margin: 1.66%;
}

请参阅此代码笔链接:https://codepen.io/alinaalam/pen/YeLqWm