打印包含 JBIG2 图像的 PDF [英] Print PDF that contains JBIG2 images

查看:45
本文介绍了打印包含 JBIG2 图像的 PDF的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

请给我推荐一些可以帮助我打印包含 JBIG2 编码图像的 PDF 文件的库.PDFRendererPDFBox 帮不了我.这些库可以打印简单的 PDF,但不能打印包含 JBIG2 图像的 PDF.PDFRenderer 尝试修复它(根据 PDFRedndrer 的错误跟踪器上的错误问题),但仍有一些页面(尤其是存在条形码的地方)不想打印.

Please, suggest me some libraries that will help me print PDF files that contain JBIG2 encoded images. PDFRenderer, PDFBox don't help me. These libs can print simple PDF, but not PDF containing JBIG2 images. PDFRenderer tries to fix it (according to bug issue on PDFRedndrer's bug tracker), but some pages still (especially where barcodes exist) don't want to print.

附言我在小程序中使用 javax.print API

P.S. I use javax.print API within applet

谢谢!

UPDATE:也试过ICEPdf,太不想工作了.

UPDATE: also tried ICEPdf, is too don't want to work.

我得出的结论是所有这些库(PDFRenderer、ICEPdf、PDFBox)都使用 JPedals jbig2 解码器.错误(某些页面未打印)来自此解码器库.这个解码器的开源版本(在PDFRenderer、ICEPdf、PDFBox中使用)不再支持,但是JPedal有一个新的项目商业分支,他们写道,这个bug已经修复在新的商业版本中,成本为 9000 美元.

I came to the conclusion that all these libraries(PDFRenderer, ICEPdf, PDFBox) use JPedals jbig2 decoder. Bug (some pages didn't print) come from this decoder library. The open source version of this decoder (which is used in PDFRenderer, ICEPdf, PDFBox) is no longer supported, but JPedal has a new commercial branch of the project, and they wrote that the bug has been fixed in new commercial release, which costs $9k.

有什么想法吗?

更新 2:昨天我尝试替换 JPedal 的免费图书馆与其他开源 jbig2-imageio 库.但是我没有得到任何成功的结果,所以我在他们的项目页面上创建了一个新主题(google-code 的论坛 - 此处).将不胜感激任何帮助.

UPDATE 2: yesterday I tried to replace JPedal's free library with other open-source jbig2-imageio libraries. But yet I don't get any successful results, so I created a new topic on their project's page (google-code's forum - here ). Would be grateful for any help.

我还发现了一些关于 Apache PDFBox 错误跟踪器的有用讨论:此处此处.

I also found some helpfull discussions on Apache PDFBox bug-tracker: here and here.

推荐答案

Borisvl 的 JPedal 库的一个分支位于

There is a fork of the JPedal library by Borisvl located at

https://github.com/Borisvl/JBIG2-Image-Decoder#readme

其中包含速度改进,我相信它也应该修复您的错误.

which contains speed improvements and I believe it should also fix your bug.

该错误与简单的范围检查有关.基本上,您需要防止 GetPixel 访问位图范围之外的 x,y 值.

EDIT : The bug is related to simple range checking. Basically you need to prevent GetPixel from accessing x,y values outside of the bitmap extents.

在调用getPixel前需要确保满足以下条件

You need to make sure the following conditions are met before calling getPixel

col >= 0 并且 col <位图宽度行 >= 0 和行 <位图高度

col >= 0 and col < bitmap.width row >= 0 and row < bitmap.height

这是一些带有小范围检查的 Delphi 代码.我无法自己测试 Java 代码,但您需要对 src/org/jpedal/jbig2/image/JBIG2Bitmap.java 进行更改

Here is some Delphi code with a couple of small range checks. I cannot test the Java code myself but you need to make changes to src/org/jpedal/jbig2/image/JBIG2Bitmap.java

procedure TJBIG2Bitmap.combine(bitmap: TJBIG2Bitmap; x, y: Integer; combOp: Int64);
...
...
var
begin
  srcWidth := bitmap.width;
  srcHeight := bitmap.height;
  srcRow := 0;
  srcCol := 0;

  if (x < 0) then x := 0;
  if (y < 0) then y := 0;

  for row := y to Min(y + srcHeight - 1, Self.height - 1) do   // <<<<<<<<  HERE
  begin
    for col := x to x + srcWidth - 1 do
    begin
      srcPixel := bitmap.getPixel(srcCol, srcRow);

安德鲁.

这篇关于打印包含 JBIG2 图像的 PDF的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆