我正在使用 ABCPDF 并為某個報告使用 MSHTML 引擎。它可以很好地加載 .PNG 檔案,以及我們的無擴展名處理程式影像,但是當涉及到 .jpg 時,它會顯示一個 X。純 HTML 加載得很好,但是將 html 轉換為 PDF 時它不會加載。
螢屏截圖中的其他影像是 PNG 或無擴展名。Chrome 引擎也會加載影像。
我什至用完全相同的影像進行了測驗,只是發送到瀏覽器的方式不同。第一個是影像處理程式,它回傳一個 JPG,第二個是直接從檔案系統讀取檔案。處理程式有效,但帶有擴展名的處理程式無效。
關于為什么 MSHTML 引擎會發生這種情況的任何線索?
/assets/files/210057 <-- Loads
/assets/files/210057.jpg <-- DOESNT

string theDir = Directory.GetParent(Directory.GetCurrentDirectory()).Parent.FullName @"\files\";
string theURL = "file://" theDir "source.html";
using (Doc doc = new Doc())
{
doc.MediaBox.String = "Letter";
// Convert HTML
doc.Pos.Y = 0;
doc.Rect.Inset(0, 0);
doc.HtmlOptions.Engine = EngineType.MSHtml;
doc.Rect.String = doc.MediaBox.String;
var w = doc.MediaBox.Width;
var h = doc.MediaBox.Height;
var l = doc.MediaBox.Left;
var b = doc.MediaBox.Bottom;
doc.Transform.Rotate(90, l, b);
doc.Transform.Translate(w, 0);
doc.Rect.Width = h;
doc.Rect.Height = w;
int theID = doc.AddImageUrl(theURL, true, 800, true);
doc.SetInfo(doc.GetInfoInt(doc.Root, "Pages"), "/Rotate", "90");
while (true)
{
if (!doc.Chainable(theID)) break;
doc.Page = doc.AddPage();
theID = doc.AddImageToChain(theID);
}
for (int i = 1; i <= doc.PageCount; i )
{
doc.PageNumber = i;
doc.Flatten();
}
string outFile = Path.Combine(theDir, $"out{XSettings.Version}{doc.HtmlOptions.Engine}.pdf");
doc.Save(outFile);
doc.Clear();
}
uj5u.com熱心網友回復:
原來是這個在 Web.Config 中添加的 customHeader。我現在要么切換到 ABCChrome,要么嘗試在帶有 url 重寫規則的影像上忽略它。
<add name="X-Content-Type-Options" value="nosniff" />
轉載請註明出處,本文鏈接:https://www.uj5u.com/qiye/512597.html
標籤:htmlIE浏览器mshtmlabcpdf微软.mshtml
上一篇:對std::is_standard_layout型別特征感到困惑
下一篇:被破壞的物體還在嗎?
