23

I need to refactor some reports (generated with Jasper) using MS Reporting Services. Copies of original reports are available in PDF. The requirement is to make the new reports "pixel perfect" which is very cumbersome...

For making life easier I would like to have a tool which overlays the original and generated report PDFs in order to measure if they are pixel perfect or not.

Is such a tool out there?

4

4 に答える 4

26

The most simple, immediately available method to do this: use ImageMagick's compare (which is also available on Windows/Linux/Mac and other).

It can even compare PDF pages (though it uses Ghostscript as its delegate to render the PDF pages to pixel images first):

 compare.exe         ^
    tested.pdf[0]    ^
    reference.pdf[0] ^
   -compose src      ^
    delta.pdf

The resulting delta.pdf will depict each pixel as red which has a different color between the two compared PDF pages. All identical pixels will be purely white. The [0] tell compare to use the first pages of each file for comparison (page count is zero-based).

You can see how this works out with the following example:

 compare.exe                      ^
    http://qtrac.eu/boson1.pdf[1] ^
    http://qtrac.eu/boson2.pdf[1] ^
   -compose src                   ^
    delta.pdf

Here are the respective pages (converted to scaled-down PNGs for web display). The reference page is on the left, the modified page is the middle one, the 'delta-pixel-are-red' image is on the right:

first page second page delta image

A slightly different visual result you can get by skipping the -compose src parameter. Then you'll get the original file's pixels as a gray-shaded background (for context) with the delta pixels in red:

 compare.exe                      ^
    http://qtrac.eu/boson1.pdf[1] ^
    http://qtrac.eu/boson2.pdf[1] ^
    delta.pdf

first page second page delta.pdf

If you don't like the red color for pixel differences, use -highlight-color:

 compare.exe                      ^
    http://qtrac.eu/boson1.pdf[1] ^
    http://qtrac.eu/boson2.pdf[1] ^
   -highlight-color green         ^
    delta.pdf

The default resolution used to render the PDF pages is 72 dpi. Should you need a higher precision, you can switch to 300 dpi using the -density parameter like this:

 compare.exe                      ^
   -density 300                   ^
    http://qtrac.eu/boson1.pdf[1] ^
    http://qtrac.eu/boson2.pdf[1] ^
    delta.pdf

Note, switching to higher densities will slow down the process and create bigger files.

You can even create a *.txt file for the delta image which describes each pixel's coordinates and the respective color values:

 compare                          ^
    http://qtrac.eu/boson1.pdf[1] ^
    http://qtrac.eu/boson2.pdf[1] ^
   -compose src                   ^
   -highlight-color black         ^
    delta.txt

Then simply count the number of total vs. black pixels (sorry, this is Unix/Linux/MacOSX syntax):

 total_pixels=$(( $(cat delta.txt | wc -l) - 1))
 black_pixels=$(( $(grep black delta.txt | wc -l) -1 ))

In the example used for the illustrations above, I get

 total_pixels=500990
 black_pixels=8727

Of course the 'ideal' result would be

 black_pixels=0
于 2012-09-17T20:48:11.960 に答える
4

この質問はすでに受け入れられた答えですが、私は私の2セントを与えたいと思います。シナリオにぴったりのi-netPDFCを作成しました。別のレポートツールで作成されたレポートが、当社のレポートソフトウェアの出力と一致することを確認するために作成されました。しかし、それはさらに強力です。PDFCが行わないことは、画像ベースのピクセルの完全性をチェックすることですが、特定の設定で、ドキュメントがそのコンテンツに基づいて基本的に(そして視覚的に)同じであることをチェックします。純粋なピクセルベースの比較よりもはるかに強力です。

i-net PDFCは、視覚的またはコマンドラインベース(バッチプロセスなど)で動作し、継続的インテグレーションシステムで動作します。ビジュアルコンポーネントを使用すると、2つのPDFファイルを半透明にオーバーレイして、ユーザーにピクセルの完全性を確認させることもできます。

ソフトウェアはベータ版から新鮮です。試してみて、ご意見をお聞かせください。(ええ、私はこれを作った会社で働いています。)

于 2012-09-18T07:54:38.620 に答える
4

diffpdf allows you to compare two PDFs side by side.

于 2012-09-17T21:44:02.893 に答える
2

PDFCreatorを使用してレポートをPNG画像として印刷することをお勧めします。その後、Paint .NETなどのグラフィックプログラムを使用して背景を透明にし、両方のレポートを重ねて表示できます。

一方または両方の画像に色変換を使用すると(たとえば、一方を赤に、もう一方を青に)、違いが非常によくわかるはずです。

PDFCreatorはここhttp://de.pdfforge.org/pdfcreatorにあります。完全に無料で使用できます。

于 2012-09-17T14:39:36.050 に答える