C# 使用标记在IE 11中未显示的大图像
我有一个cshtml页面,它将图像作为字符串,并将其显示在图像标记中。代码如下:C# 使用标记在IE 11中未显示的大图像,c#,html,asp.net-mvc,image,internet-explorer,C#,Html,Asp.net Mvc,Image,Internet Explorer,我有一个cshtml页面,它将图像作为字符串,并将其显示在图像标记中。代码如下: @model ReadModel @{ ViewBag.Title = "Display"; ViewBag.Project = "IS"; Layout = null; } <body style="max-height:1100px; max-width:850px" > @if (Model.readImages.Count > 0) {
@model ReadModel
@{
ViewBag.Title = "Display";
ViewBag.Project = "IS";
Layout = null;
}
<body style="max-height:1100px; max-width:850px" >
@if (Model.readImages.Count > 0)
{
//only images will hit this code. Other file types are written to the Response header in the controller
string imgSrc = String.Format("data:" + Model.readImages[0].contentType + ";base64,{0}", Model.readImages[0].imageString);
<img src="@imgSrc" style="max-height:1100px; max-width:850px"/>
}
else
{
<p>No Image to display</p>;
}
<p>@Model.error</p>
</body>
上面的C代码也适用于显示图像,即使是非常大的图像,但是我的一个要求是图像必须能够在单个页面上打印,因此使用了“最大高度”和“最大宽度”属性
如果我使用C代码编写图像,大图像将打印到4或5页
因此,我需要的是一种方法,使标签工作的大图像,或有C代码调整图像大小,以适应8.5 x 11页
我知道chrome可以很好地处理这些图像,不幸的是,另一个要求是让它在IE中工作
检查“使用软件渲染而不是GPU渲染”没有帮助
有什么想法吗?我建议您将此CSS代码应用到您的IMG标签上,这可能有助于在IE中以单页显示/打印图像
.pp
{
margin: 0px;
padding: 0px;
width: 670px; /* width: 7in; */
height: 900px; /* or height: 9.5in; */
clear: both;
background-color: gray;
page-break-after: always;
}
例如:
本例中测试的图像大小约为16.2MB
.pp
{
边际:0px;
填充:0px;
宽度:670px;/*宽度:7英寸*/
高度:900px;/*或高度:9.5in*/
明确:两者皆有;
背景颜色:灰色;
分页符后:始终;
}
立方体
{
位置:相对位置;
顶部:1英寸;
左:1in;
宽度:1in;
高度:1英寸;
背景色:白色;
}
.pp
{
margin: 0px;
padding: 0px;
width: 670px; /* width: 7in; */
height: 900px; /* or height: 9.5in; */
clear: both;
background-color: gray;
page-break-after: always;
}