html2pdf 不能识别标签,分页符和Alt标签在Itext7 html2pdf中不起作用(Page Break and Alt Tag not working in Itext7 html2pdf...

在尝试使用Itext7的html2pdf转换时,用户遇到了分页符不生效和Alt标签缺失导致PDF辅助功能检查器报错的问题。经过调查,这些问题在pdfHTML v1.0.1中得到了修复,包括对`page-break-after` CSS属性的支持和修复了Alt标签的缺失。用户需要确保依赖库版本为1.0.1或更高。
摘要由CSDN通过智能技术生成

分页符和Alt标签在Itext7 html2pdf中不起作用(Page Break and Alt Tag not working in Itext7 html2pdf)

我正在尝试示例代码,如文档页面中所述

但是,当我生成pdf时,没有设置alt标签,因此pdf辅助功能检查器会抱怨。 我还发现分页符不适用于给定的示例html页面。 有人可以帮我解决这两个问题吗? 我的POM.xml具有以下依赖项。 我已经创建了确切的文件并复制了上面文章中提到的代码。

com.itextpdf

itext7-core

7.0.2

pom

com.itextpdf

html2pdf

1.0.0

itext

iText Repository - releases

https://repo.itextsupport.com/releases

谢谢

SGK

I am trying the sample code as explained in the documentation page

However, when i generate pdf, The alt tags are not set and hence pdf accessibility checker complains. I also found out that page break does't work from the given sample html page. Can someone help me to solve these two issues? My POM.xml has the following dependencies. I have created the exact files and copied the code as mentioned in the above article.

com.itextpdf

itext7-core

7.0.2

pom

com.itextpdf

html2pdf

1.0.0

itext

iText Repository - releases

https://repo.itextsupport.com/releases

Thanks

SGK

原文:https://stackoverflow.com/questions/45240844

更新时间:2019-11-10 11:13

最满意答案

pdfHTML v1.0.1中添加了对page-break-after CSS属性的支持

没有/ alt标签是v1.0.0中的一个错误,并在v1.0.1中修复

(为了可见性,将其作为答案发布,因为此问题之前已经出现过)。

Support for the page-break-after CSS property has been added in pdfHTML v1.0.1

The absence of the /alt tags was a bug in v1.0.0 and is fixed in v1.0.1

(Posting this as answer for the sake of visibility, since this question has popped up here and there before).

相关问答

pdfHTML v1.0.1中添加了对page-break-after CSS属性的支持 没有/ alt标签是v1.0.0中的一个错误,并在v1.0.1中修复 (为了可见性,将其作为答案发布,因为此问题之前已经出现过)。 Support for the page-break-after CSS property has been added in pdfHTML v1.0.1 The absence of the /alt tags was a bug in v1.0.0 and is fixed

...

iText在自己的验证码中需要做同样的事情。 它在它的SignatureUtil类中这样做。 因此,人们可以简单地从该代码中借用,例如: try ( PdfReader pdfReader = new PdfReader(SOURCE_PDF);

PdfDocument pdfDocument = new PdfDocument(pdfReader);) {

SignatureUtil signatureUtil = new SignatureUtil(pdfDocum

...

提供此行为的方法的名称在iText7中已更改。 要扩展每个页面最后一行中的单元格,请使用 table.setExtendBottomRow(true);

要为除最后一页以外的每个页面执行相同操作,请使用 table.setExtendBottomRowOnSplit(true);

请注意,此API将从7.0.2版本开始提供,不远处。 此功能也已在最新的SNAPSHOT版本中提供 The name of the method providing this behavior has changed

...

在iText 7中, PdfDocumentInfo类不幸地不公开一个方法来检索底层字典中的键。 但是,您可以通过立即从尾部字典中访问该字典来简单地检索Info字典内容。 例如,对于PdfDocument pdfDocument : PdfDictionary infoDictionary = pdfDocument.GetTrailer().GetAsDictionary(PdfName.Info);

foreach (PdfName key in infoDictionary.KeySet()

...

您在此处找到的示例程序已过时。 我在我的电脑上尝试过同样的问题并且遇到了同样的问题。 Plz参考iText为版本7提供的开发人员的内部文档 。 谢谢。 I solved the issue using Eclipse and importing iText7 as External jars, which I didn't want to do, but.... it appears that there is no other way

我只是在遇到同样的问题后才明白这一点。 他们使用DOES的解析器支持page-break-after标签,但是html2pdf不起作用。 我想我通过对html2pdf.class进行以下修改来实现它: 在4174线左右,里面的第一件事: protected function _tag_close_P($param){

应该: if($this->parsingCss->value['page-break-after'] == "always")

$this->_setNew

...

我通过编辑dompdf_config.custom.inc.php解决了这个问题 取消注释 define("DOMPDF_ENABLE_REMOTE", true);

现在图像加载在pdf中。 感谢您的支持。 I solved the issue by editing dompdf_config.custom.inc.php uncommented define("DOMPDF_ENABLE_REMOTE", true);

Now the images are loading inside p

...

我能够使用apache蜡染库来实现这一点。 这是我如何做到的。 Maven依赖

org.apache.xmlgraphics

batik-transcoder

1.9

自定义ITagWorker for SvgImage import com.itextpdf.html2pdf.attach.I

...

我不熟悉这个库,但它可能是PdfCanvas和Canvas对象在被使用后没有被破坏,并且在文档被销毁之前一直存在于内存中。 根据文档,您必须在绘制图表后释放内存。 完成写入画布后,请务必调用PdfCanvas.release()。 资料来源: https : //github.com/itext/itext7-dotnet/blob/dd5c209cff35c137ed451fef6e11a96889a52fe9/itext/itext.kernel/itext/kernel/pdf/canvas

...

你可以做 javafx.scene.image.Image fxImage = chart.snapshot(null, null);

java.awt.Image awtImage = SwingFXUtils.fromFXImage(fxImage);

com.itextpdf.layout.element.Image pdfImage =

new com.itextpdf.layout.element.Image(ImageDataFactory.create(awtImage,

...

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值