Hello,

At first, this module is very poorly documented.

Having said that, I have some issues with rendering/showing my uploaded documents.

I want to show .pdf files on a standard page. All configurations went well. All different display options for the file field work also. Only for the 'embed fileviwer' I get no results. The predefined area where the file should show is visually marked, only no content appears.

Anybody ? Some help or advise would be appreciated. Cfr attachement.

Thx,
Koen.

Ps: How does Poppler gets installed and configured ?

CommentFileSizeAuthor
#18 the_best_I-could_get.jpg26.83 KBscuis
Screenshot.png19.6 KB8tropos
Support from Acquia helps fund testing for Drupal Acquia logo

Comments

miprof’s picture

the same for me - anything display.

Thanks for help

eatstickyrice’s picture

First, thanks for developing this module! Next, I am having what sounds like the same problem. When I go into manage my "content types" within the structure and then click on "manage display" I have tried both the "fileviewer" and "embedded file viewer" options. On the page the pdf file is supposed to display it simply shows me a gray box.

santam’s picture

Hi I am having the same issue and I think it is because I dont know where to install poppler utils. Actually the frame containing the viewer appears very nicely on the page but no PDF content displays. Reading the module file I can assume its because the pdf is not getting converted to png. However I am not sure as to how to get this conversion process to run on each upload. Any updates on this critical issue Shen?

shenzhuxi’s picture

In Ubuntu, sudo apt-get install poppler-utils
In CentOS, sudo yum install poppler-utils
It should be similar in other distro.

In console, try the command "pdftoppm". If it works, the module should work correctly.

santam’s picture

Thanks for the reply Shen,
I am hosting my website in Webenabled. I will try to see if I can install Poppler in there and get back to you.

santam’s picture

Hi Shen,
Got the thing working in localhost but unable to get it done in webenabled. That is ofcourse a problem with the server end not your module so I guess we can mark this issue closed. However the documentation needs to mention this explicitly. Would you mind if I send you a small text to add the information in?

eloiguell’s picture

Hi Shen,
thanks for this module. I was having some problems with poopler-utils, command pdftoppm -png was not working for me. But I has fixed this changing it to 'convert' command. It works for me.

Here is the code.

function fileviewer_pdftopng($filepath, $destination) {
//$cmd = 'pdftoppm -png "' . $filepath . '" "' . $destination . 'page"';
$cmd = 'convert -density 300 "' . $filepath . '" "' . $destination . 'page.png"';

shell_exec($cmd);
}

Note that adding .png after $destination . 'page it's necessary. It will create page1.png, page2.png.. etc if you have multiple pages in a pdf file.

Eloi

david3000’s picture

david3000’s picture

hello santam, it's great that the module works in localhost, but how did you install poppler in your localhost server? I can't see any tuto to do that. I am in mowes portable. Thanks and greetings.

santam’s picture

HI David,
I use Linux (ubuntu) on my local host so its a matter of simply giving the command sudo apt-get poppler-utils in a terminal (command window) and the rest of the stuff is automatic. As far as getting it to work in Windows I would not know.

david3000’s picture

Thanks Santam, In ubuntu seems easy. I am still searching the "windows installation", will see. I don't wanna create a virtual machine on ubuntu just to try this jeje. greetins!

shenzhuxi’s picture

It's said that poppler can be compiled in windows and you can also use other tool for converting. You just need to modify the command in the codes in windows.

motoecks’s picture

I'm having issues installing the poppler onto my hosting services... would the view work if I have the files were already in png format?

xlsoul’s picture

Reply to #7

I am using Centos 5 and I have tried many times to install poppler-utils and faild. No matter How I write ' yum install poppler-utils'. The command pdftoppm isn't appear.

I even try to install xpdf which provide this command and failed. I try to install poppler by 'make install' and failed again. I don't know what's wrong with my Centos 5.

So, I installed imagemagick and add your code which use command 'convert', It's also work for me.

There is a little episode: Use command 'convert' I get a png from number 0 like 'page-0.png','page-1.png', not from number 1.

So I change some code in bookreader.js(function addZero in line 101)

function addZero(s,n){
  s = s - 1;
  while(s.length < n){
    s ='0' + s;
  }
  return(s);
}

Now,everything is work for me.

As you see, I am not good at English, so I provide a Chinese version of this comment for Shen:

您好,我就是给你发信的中国学生。

我的VPS使用的是CENTOS5,在使用yum install poppler-utils命令的时候,安装的poppler-utils版本始终是0.5.4。在安装完这个版本以后,始终没有出现pdftoppm这个命令,这个贴也说明了我类似的情况(http://grokbase.com/t/centos.org/centos/2008/02/centos-poppler-utils-mis...

我注意到了两点:

第一,这个版本是在是太老了,上面的帖子提问时间也是几乎三年前,而poppler官网上的版本号已经到了0.16 (STABLE);

第二,似乎xpdf提供了同样的命令pdftoppm。

关于第一点,因为我无论怎样yum,怎样更新源,都无法安装最新的版本,我还找到了这个页面(http://pkgs.org/search/?keyword=poppler-utils&search_on=smart&distro=0&a...),似乎除了centos5以外,别的系统均有较新版本的poppler可以使用。于是我就从其官网下载了tar.gz自己make install,结果最新版本的poppler的确安装完毕,但是pdftoppm命令似乎无法正常使用(在命令行界面输入pdftoppm,回车后命令行无反应,跟死机类似,我从来没遇到过这样的情况。输入pdftoppm -h之后出现了其支援的参数,也没有找到代码中提及的-png,输入pdftoppm -png 之后,提示没有‘-png’这个文件,可见我安装的最新版本poppler似乎没有这个参数)。

关于第二点,在make install 之前,我还尝试yum install xpdf,之后的确出现了pdftoppm的命令,但是同样没有 -png的参数,我在命令行界面直接尝试pdftoppm -f 1 -l 2 /xxxx/123.pdf /xxxx (xxxx是任意目录,-f -l是在pdftoppm -h 后出现的参数)生成的是一些ppm格式文件——似乎xpdf的pdftoppm命令用法完全不同。

在这两点都遇到阻碍了以后,我只得采用楼上的方法,安装imagemagick,使用它提供的convert命令来进行pdf到png的转换,终于没有问题——但是我不知道这样调用命令对系统的开销究竟大不大,与使用pdftoppm相比,哪个更大一些呢?

有一个小插曲,我使用convert命令生成的的png是从0开始计数的,也就是从page-0.png开始,这样显示的时候PDF就会从第二页开始显示。我无力去修改imagemagick,只能修改您模块中的bookreader.js,在结尾部分最后一个addZero函数,增加了一个s = s-1,就像上面显示的一样,根据我已知的编程知识,应该对“增加零”这个函数效果没有影响。

最后,我的英文水平让我实在没有耐心把我尝试使用poppler失败的过程用英文写出来,所以才使用中文来说明——当然,因为这无关最后的结果,所以英文读者仅看上面的话也能取得同样的信息。

不知道您对这个过程,和这么修改代码有什么看法呢?

您在回复我的时候最好使用英文,一是我能看得懂也能锻炼我的英文,二是也能有利于更多的DRUPAL站长们~!

感谢您的回复!

shenzhuxi’s picture

Poppler's codes mainly comes from xpdf which is not actively maintained. Poppler is the default pdf lib for many Linux distros now. It also provides better non-English support than convert in imagemagick. (Seems faster too)
That's why I added "-png" option to Poppler (also why xpdf doesn't have this option). http://poppler.sourcearchive.com/documentation/0.12.0-2.1/PNGWriter_8cc-...

Poppler can be easily compile in most linux distros. I think you need to use full path to your make install directory like "/usr/local/bin/pdftoppm" otherwise the old version will be used as default.

blazindrop’s picture

I ran into the same problem and used the patch in #7. Just like the OP says, the page number causes a conflict because it's "off by 1" in BookReader. There's a fix - have "convert" set the starting number for pages using the "scene" parameter. Here's my patch that builds on #7:

Index: fileviewer.module
===================================================================
--- fileviewer.module (revision 515)
+++ fileviewer.module (working copy)
@@ -211,7 +211,8 @@
function fileviewer_pdftopng($filepath, $destination) {
$cmd = 'pdftohtml -xml "' . $filepath . '" "' . $destination . '/meta/text.xml"';
shell_exec($cmd);
- $cmd = 'pdftoppm -png "' . $filepath . '" "' . $destination . 'page"';
+
+ $cmd = 'convert -scene 1 -density 300 "' . $filepath . '" "' . $destination . 'page.png"';
shell_exec($cmd);
}

blazindrop’s picture

Hmm, seems my solution works with multi page PDFs just fine. If you have a single page PDF, no numbering is included in the filename (e.g. I get page.png instead of page-1.png).

scuis’s picture

FileSize
26.83 KB

I Installed the module, popper works fine (I successfully executed on terminal the commands to generate xml and png) but nothing is showed up. Even when I manually copy the generated files to the proper directories, the only difference is that shows empty pages with the tiny "not found" icon.

I edited the node, deleted the pdf and reloaded it again and the folders were flushed but no new content generated.

Anyone can help please?

Thanks