iText7(PdfSweep):关于编辑文本

时间:2018-05-03 13:00:34

标签: java itext7

我正在尝试使用PDFSweep 2.0.0(JAVA)编辑PDF文本。我用了this example

它适用于我拥有的大多数PDF,但在某些PDF文件中,代码会抛出NullPointerException

以下是代码示例:

    CompositeCleanupStrategy strategy = new CompositeCleanupStrategy();
    strategy.add(new CustomLocationExtractionStrategy("Joe"));

    PdfDocument pdf = new PdfDocument(new PdfReader(SRC), new PdfWriter(DEST));

    // sweep
    PdfAutoSweep autoSweep = new PdfAutoSweep(strategy);
    autoSweep.cleanUp(pdf);
    pdf.close();

我使用this PDF作为SRC文件。这是itext7 / pdfsweep的错误吗?

1 个答案:

答案 0 :(得分:1)

更新您的依赖关系 我对 alter trigger tr_trtest_update on trtest for update as begin declare @id int, @oldname varchar(20),@newname varchar(20), @oldsalary int,@newsalary int declare @auditstring varchar(250) select * into #tempinserted from inserted while(exists( select id from #tempinserted)) begin set @auditstring='Emp with ' + cast(@id as nvarchar(5)) select top 1 @id=id,@newname=name,@newsalary=sal from #tempinserted select @oldname=name,@oldsalary=sal from deleted where id=@id if (@oldname<>@newname) set @auditstring=@auditstring+ 'with name ' + @oldname + ' has been updated to ' + @newname if(@oldsalary<>@newsalary) set @auditstring=@auditstring+ 'with salary ' + cast(@oldsalary as nvarchar(20))+ ' has been updated to ' + cast(@newsalary as nvarchar(20)) insert into tr_log(description)values(@auditstring) delete from #tempinserted where id=@id end end 进行了验证,结果非常好。

编辑PDF作为证据 redacted PDF