HTMLBoxWidget: add setRawContent() (#14480)

This commit is contained in:
Frans de Jonge authored and GitHub committed 2025-10-19 19:16:53 +02:00
1 parent 5c20f84545
commit b28a6e5ca9
1 file changed
+20
+20
View File
@@ -268,6 +268,26 @@ function HtmlBoxWidget:setContent(body, css, default_font_size, is_xhtml, no_css
self:clearHighlight()
end
--- Use the raw content as given, without any string manipulation to try to improve MuPDF compatibility or rendering.
--- @string body Content to be rendered in a supported format like (X)HTML or SVG.
--- @string magic Used to detect document type, like a file name or mime-type.
--- @number default_font_size Default font size to use for layout, only for some formats like HTML.
--- @string resource_directory Directory to use for resolving relative resource paths.
function HtmlBoxWidget:setRawContent(body, magic, default_font_size, resource_directory)
local ok
ok, self.document = pcall(Mupdf.openDocumentFromText, body, magic, resource_directory)
if not ok then
logger.warn("Raw content loading error:", self.document)
return nil, self.document
end
self.document:layoutDocument(self.dimen.w, self.dimen.h, default_font_size)
self.page_count = self.document:getPages()
self.page_boxes = nil
self:clearHighlight()
end
function HtmlBoxWidget:_render()
if self.bb then
return