XMLWorker 看不到 img (itextsharp)
XMLWorker doesn't see img (itextsharp)
我使用 XMLWorker 将 HTML 解析为 PDF。而且我对图像有疑问。当单词之间的标签路径中有空格或路径中有西里尔符号时,来自 HTML 的图像不会添加到 PDF 中。为了解决空格问题,我使用了 path.Replase(" ", "%20")
和 path.Replase(" ", "+")
,但没有帮助。
我是否应该将 img 的路径转换为 base64 并在使用像 here 这样的 ImageProvider (AbstractImageProvider) 之后?
如果路径中没有空格或西里尔字符,则 XMLWorker 解析 HMTL 是正确的。
<img src="D:\c#\PdfItextSharp\HTML_to_PDF_book\HTML_to_PDF_book\bin\Debug\Data\Resources\Documentation\IASO\Modules\LearningFrame\Imagesx32-tree_add_subitem.png" class="icon">
但如果路径中有符号,则图像不会添加到 pdf
<img src="D:\c#\PdfItextSharp\HTML to PDF book\HTML to PDF book\bin\Debug\Data\Resources\Documentation\IASO\Modules\LearningFrame\Imagesx32-tree_add_subitem.png" class="icon">
或
\HI-PC\AllUsers\Выгрузка\DebugHtmlToPdf\User manual - Instructor\bin\Data\Data\Screenshots[=12=]e39c7d5-4489-4d8b-ae84-ee85a2e225ee.jpg
我怎么能这样
谢谢。
为了解决这个问题,我使用了下一个代码。感谢 mkl 的帮助。
var uri = new System.Uri(tmpPath);
var convertedURI = uri.AbsoluteUri;
我使用 XMLWorker 将 HTML 解析为 PDF。而且我对图像有疑问。当单词之间的标签路径中有空格或路径中有西里尔符号时,来自 HTML 的图像不会添加到 PDF 中。为了解决空格问题,我使用了 path.Replase(" ", "%20")
和 path.Replase(" ", "+")
,但没有帮助。
我是否应该将 img 的路径转换为 base64 并在使用像 here 这样的 ImageProvider (AbstractImageProvider) 之后?
如果路径中没有空格或西里尔字符,则 XMLWorker 解析 HMTL 是正确的。
<img src="D:\c#\PdfItextSharp\HTML_to_PDF_book\HTML_to_PDF_book\bin\Debug\Data\Resources\Documentation\IASO\Modules\LearningFrame\Imagesx32-tree_add_subitem.png" class="icon">
但如果路径中有符号,则图像不会添加到 pdf
<img src="D:\c#\PdfItextSharp\HTML to PDF book\HTML to PDF book\bin\Debug\Data\Resources\Documentation\IASO\Modules\LearningFrame\Imagesx32-tree_add_subitem.png" class="icon">
或
\HI-PC\AllUsers\Выгрузка\DebugHtmlToPdf\User manual - Instructor\bin\Data\Data\Screenshots[=12=]e39c7d5-4489-4d8b-ae84-ee85a2e225ee.jpg
我怎么能这样
谢谢。
为了解决这个问题,我使用了下一个代码。感谢 mkl 的帮助。
var uri = new System.Uri(tmpPath);
var convertedURI = uri.AbsoluteUri;