(单位)测试生成PDF [英] (Unit)test pdf generation

查看:140
本文介绍了(单位)测试生成PDF的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我们实现了一个Magento的模块 https://github.com/firegento/firegento-pdf/,我打算写的模块测试。

We implemented a magento module https://github.com/firegento/firegento-pdf/ and I plan to write tests for the module.

问题是:扩展生成PDF文件

The problem is: The extension generates pdfs.

是否有任何框架,或任何测试PDF文件?这将是完全的罚款,如果我能为您在PDF中的文本。我不想检查正确的位置。

Is there any framework, or whatever to test pdfs? It would be totally fine if I can check for text in the pdf. I don't want to check the correct placement.

安迪的想法?

这看起来很有希望,但感觉过大。 http://webcheatsheet.com/php/reading_clean_text_from_pdf.php

This looks promising but feels oversized. http://webcheatsheet.com/php/reading_clean_text_from_pdf.php

推荐答案

我用PDFBOX一个类似的模块,一个基于Java的命令行工具,从PDF提取文本,并选择将其转换为HTML: http://pdfbox.apache.org/commandline/#extractText

I use PdfBox for a similar module, a Java based command line utility that extracts text from a PDF and optionally converts it to HTML: http://pdfbox.apache.org/commandline/#extractText

要PHPUnit测试中使用它,我写了一个PHP接口相关PDFBOX方法: https://开头github上。 COM / schmengler / PDFBOX

To use it within PHPUnit tests, I wrote a PHP interface for the relevant PdfBox methods: https://github.com/schmengler/PdfBox

use SGH\PdfBox;

//$pdf = GENERATED_PDF;
$converter = new PdfBox;
$converter->setPathToPdfBox('/usr/bin/pdfbox-app-1.7.0.jar');
$text = $converter->textFromPdfStream($pdf);

延伸阅读:<一href=\"http://www.schmengler-se.de/en/2014/03/unit-testen-von-generierten-pdfs-mit-phpunit-und-pdfbox/\"相对=nofollow>单元测试生成的PDF文件使用PHPUnit和PDFBox的

这篇关于(单位)测试生成PDF的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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