gpt4 book ai didi

html - 将 HTML 页面打印为 PDF 时,如何使图像以正确的比例显示?

转载 作者:太空宇宙 更新时间:2023-11-04 08:39:43 25 4
gpt4 key购买 nike

我有一个要打印为 PDF 的网页。在我到达显示图像的页面之前,一切看起来都很棒。由于我不知道的原因,在 PDF 预览中出现的图像宽度看起来不错,但高度太高。

HTML 看起来像这样:

    <table width="100%">
<tr>
<td>
<table class="table table-striped table-bordered">
<tr>
<td width="50%" class="centerText">
<span style="font-size:small;text-align: center;">Top Depth Photo</span>
<img src="@utility.TopDepthImageUri" width="512" height="384" />
</td>
<td width="50%" class="centerText">
<span style="font-size:small;text-align: center;">Bottom Depth Photo</span>
<img src="@utility.BottomDepthUri" width="512" height="384" />
</td>
</tr>
</table>
</td>
</tr>
<tr>
<td>
<table class="table table-striped table-bordered ">
<tr>
<td width="50%" class="centerText">
<span style="font-size:small;text-align: center;">Finish Photo</span>
<img src="@utility.FinishImageUri" width="512" height="384" />
</td>
<td width="50%" class="centerText">
<span style="font-size:small;text-align: center;">Area Photo</span>
<img src="@utility.AreaImageUri" width="512" height="384" />
</td>
</tr>
</table>
</td>
</tr>
</table>

在网页上图像看起来不错,但是当我打印 PDF 预览时看起来像这样:

enter image description here

您可以看到表格中只显示了一行,图像没有按应有的比例缩放。 (第二行在下一页。)

在这种情况下,如何控制图像的确切高度和宽度?

最佳答案

试试这个

  <table width="100%">
<tr>
<td>
<table class="table table-striped table-bordered">
<tr>
<td width="50%" class="centerText">
<span style="font-size:small;text-align: center;">Top Depth Photo</span>
<img src="@utility.TopDepthImageUri" style="max-width: 100%; height: auto;" />
</td>
<td width="50%" class="centerText">
<span style="font-size:small;text-align: center;">Bottom Depth Photo</span>
<img src="@utility.BottomDepthUrig" style="max-width: 100%; height: auto;" />
</td>
</tr>
</table>
</td>
</tr>
<tr>
<td>
<table class="table table-striped table-bordered ">
<tr>
<td width="50%" class="centerText">
<span style="font-size:small;text-align: center;">Finish Photo</span>
<img src="@utility.FinishImageUri" style="max-width: 100%; height: auto;" />
</td>
<td width="50%" class="centerText">
<span style="font-size:small;text-align: center;">Area Photo</span>
<img src="@utility.AreaImageUri" style="max-width: 100%; height: auto;" />
</td>
</tr>
</table>
</td>
</tr>
</table>

关于html - 将 HTML 页面打印为 PDF 时,如何使图像以正确的比例显示?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/44221212/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com