MPDF can produce report output, but the graph does not appear, only a red X in it's place.

Note that all other document output also is only able to show tables.

MPDF 5.7 complete is correctly installed at sites/all/libraries/mpdf

Running 7.x-4.0-beta4

I can't see anything in Setup guide, install etc Have I missed something?

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

MickC’s picture

Issue summary: View changes
hgkris’s picture

I've have the same setup and svg graphs are outputted in the pdf.

It seems that the svg file is not embedded in the pdf.
Can you check if you can see in admin/config/content/forena/pdf, that MPDF Library is active?
Do you have an example of the frx file?

MickC’s picture

Yes it's active:

"MPDF library
Installation path sites/all/libraries/mpdf"

Frx file attached as a txt for uploading.

Pierre.Vriens’s picture

Mick, you're right there is nothing yet in the setup guide about MPDF. Thanks for bringing that up, I'll remember to add something about that soon. Haven't seen any MPDF specific issues or video stuff before (except a few words in the community docu now), which is probably why we didn't think about documenting it before either, have you?

A few more suggestions that might help further debugging your issue:
- can you confirm that you get the same problem for the graph shown in sample.state_summary ?
- no special messages in admin/reports/dblog related to it?
- no special messages in admin/reports/status about it?

MickC’s picture

Yes - one of the first things I tried - just get the red 'X' instead of the image of the graph.
Wondering is there's some other plugin I should have, or shouldn't have, or version incompatibility...

Pierre.Vriens’s picture

Mick, thanks for confirming you encounter the same issue with the state_summary sample, which should help us further debugging it. I do not have any other inspiration about how to further debug this, let's see what David might come up with to further investigate it.

It won't help you any further right now, but let me add already this quick update I noticed about MPDF support in 7.4-dev (and also in beta4): in the module enable/disable admin page, for "forena_pdf" it says "Currenlty only supports PrinceXML which is a commercial product.". It appears to me that we should ALSO correct that phrasing, since it's obviously missing something about MDPF (I think). And since I don't have that PrinceXML, I never bothered about anything PDF related (though MPDF seems worth exploring ...).

I'd be happy to get that module description corrected in the coding (+ correct the typo), after I learn from David how to best correct/extend that phrasing there. Eventually creating a separated issue for that also (should David prefer me to do so).

I'd be happy to also add MPDF chapter in the setup guide soon, provided somebody can provide me the answers to these kinds of question I ask myself about it (am I the only one?):

  • What would be a good (brief) explanation about MPDF?
  • Why use MPDF (advantages, special things it supports, like charts I assume ...)?
  • How does this compare (hopefully not conflict ...) with eg the PDF features that come with the print module?

FYI: we already have a link in the community docu now about where to download the library.

Pierre.Vriens’s picture

I was able to recreate the same problem (a pdf with the chart replaced by such small icon with a red cross in it). I then visited the permissions page, where I noticed these errors:

    Warning: file_put_contents(sites/all/libraries/mpdf/tmp/_tempSVG1749_0.svg): failed to open stream: Permission denied in mPDF->AdjustHTML() (line 32066 of ...sites/all/libraries/mpdf/mpdf.php).
    Warning: unlink(sites/all/libraries/mpdf/tmp/dummy.txt): Permission denied in mPDF->Output() (line 7505 of 
...sites/all/libraries/mpdf/mpdf.php).

Then I went to check the permissions of this tmp dir (within the mpdf folder). The webuser only had read access to it. After allowing update access for the web user to that tmp dir (only) and retrying the same scenario, my problem was resolved.

So question to David: is this "update access" for the web user to that tmp dir the recommended solution? Also: seems to me that we might consider furhter refining the drupal status report regarding this writeable for the web user (if that is what is the actual solution).

To Mick: can you check in your setup if my resolution is also the solution for your scenario?

metzlerd’s picture

I will do some research to see if there is a programatic way to set the temp directory used by mPDF. If it's possible, I'll roll a patch to have forena make that modification.

Pierre.Vriens’s picture

David, I think that's indeed the recommended approach. Checkout http://mpdf1.com/manual/index.php?tid=445 for more details about what is probably needed somewhere in the forena coding:

define("_MPDF_TEMP_PATH", '../../common/tempfiles/');
include("../mpdf.php");
$mpdf=new mPDF();

Regarding the actual temp dir to be used, it appears to me that the standard drupal temp dir, which is set via admin/config/media/file-system, is a good choice. I don't think the report dir or the custom data blocks should be used for creating such temp subdir.

Note: not sure if it is a side-effect of the auth error, but the filename of the pdf output was always mpdf.pdf. Shouldn't that be something like reportname.pdf? Not sure if it's related, but I also found via http://mpdf1.com/manual/index.php?tid=351 that mpdf.pdf is the default filename that gets created, which you can overwrite via the 'sourcefile' in mPDF's OverWrite function.

metzlerd’s picture

Status: Active » Needs review
FileSize
610 bytes

Here's a patch that uses the correctly configured drupal temp directory.

Pierre.Vriens’s picture

Status: Needs review » Reviewed & tested by the community

After I pulled this commit, it resolved my issue I encountered as described in #7, i.e. I also removed the update access for the webuser again (so that it only has read access as before), and the pdf file was now created with the graph included (no more red cross thing).

However, with this fix enabled, it still created a pdf file named mpdf.pdf, as I mentioned in my note in #9. So that does not seem to be related to the auth issue from before. For more details, and per David's request below, refer to #2362365: Use reportname in PDFs created with mPDF.

metzlerd’s picture

Status: Reviewed & tested by the community » Fixed

Please file other requests for changes under a different issue.

metzlerd’s picture

Created #2362365: Use reportname in PDFs created with mPDF to talk about remaining work.

MickC’s picture

FileSize
45.38 KB

Hi guys - in response to #7 I enabled read/write access for all users to sites/all/libraries/mpdf/tmp

Now I have a PDF output for the graph, but it is all black except for the legend - see attached.

Note however that I could successfully produce output in html format - all other formats produce no graph at all.

MickC’s picture

FileSize
46.07 KB

UPDATE - I updated MPDF to 5.72 and now have graph output in the PDF - attached.

Will apply the patch soo and advise if any issues.

Thanks a lot - great to get this result!

Pierre.Vriens’s picture

Mick, your progress in#16 seems great, please let us now how your remaining qa-testing turns out. About your #15: what was the release of mPDF before you upgraded to 5.72? And about your last phrase in it: could you be a bit more specific about which "other formats" (apart from PDF and HTML) you expect to see a graph included in it. I'm assuming that for DOC one would expect to also have it included, but (eg) not in a CSV, right? Maybe David can add some details about for which formats the graph is supposed to be produced (which we might then qa-test in both your and mine environment ... and if needed create another issue for similar issues to comply with David's #13 request).

By the way, starting from which forena release was this mPDF support introduced in forena? Extra mPDF question: #2363115: Pros/cons of mPDF vs PDF in module PRINT?

metzlerd’s picture

For future reference, MPDF requires incremental upgrades from 5.7 so you have to apply specific upgrades. The black graphs were only happening for specific graph types. You can see this by enabling PDF on the graph demo report.

Lets take the discussion about PRINT module's use off to another issue related to documentation since that seems to be the reason for it.

Pierre.Vriens’s picture

FYI: I'm using mPDF version 5.7 (contained in the MPDF57.zip I downloaded), and I did NOT "upgrade" it yet to 5.7.2 (using MPDF572UPGRADE.zip) or 5.7.3 (MPDF573UPGRADE572.zip). And without any of these updates, I did not encounter anything like those black graphs.

Any reason why it is recommended to perform such upgrade anyhow (if it ain't broken, don't upgrade it ...)? And if so, am I right that "upgrading" itself is a matter of "copy the newer versions over the previous versions" (can't find an answer to that question on the mPDF site ...)?

Extra question related to the "graph demo report" in #18: do you mean state_summary or svg_demo, or maybe either one?

metzlerd’s picture

Yes I meant svg_demo. I was having the issue for line graphs and radar graphs but not pie charts and bar graphs.

Pierre.Vriens’s picture

That's what I was assuming, but I just wanted to be sure. So this is a first case where svg_demo has helped to also "test" all sorts of SVG Graph variations, and the combination of it with mPDF.

From Mick's #3 and #15/16 I understand that those are also about Line graphs. And by re-digesting #18 I now get the impression that Nick's version 5.72 in #16 somehow did not include the "full version" (or whatever we call that) that I used for my testing, i.e. version 5.7. Which might explain the black charts. Hopefully Nick will somehow confirm so, or otherwise further correct / complete my guessing here ...

MickC’s picture

I started off with 5.7.3 then realised you need a full version first - 5.7.
Then I got the 'black' issue for a line graph (multi) - didn't try other graph styles.
Then did incremental updates 5.7.1, 5.7.2 by which the issue was resolved - proceeded to 5.7.3 anyway afterwards.
The README in the updates explains that you just simply overwrite which ever files are contained within.

I think most people would be happy with PDF, although DOC and XLS would be useful.
I can produce the graph in PDF, HTML, SVG, WEB; not DOC, XLS, CSV (which I wouldn't expect) .

EMAIL just displays "Array". I also notice the error message "No mail merge information in report. Displaying report instead."
You may have another ticket on this - I haven't checked yet but will investigate.

XML produces an error:
"XML Parsing Error: XML or text declaration not at start of entity
Location: http://forena.audienceware.com/reports/sample.state_summary_ie8.xml
Line Number 2, Column 3: <?xml version="1.0"?>
--^"

All this was tested on reports/sample.state_summary_ie8

Hope that helps.

metzlerd’s picture

Just saw the broken email functionality myself and created: #2363295: EMAIL functionality broken

Regarding DOC and XLS I am limited by what these documents support. They do not currenlty support inline SVG, so I'm not sure that's feasible. Thanks for documenting your steps.

MickC’s picture

Fine, I expected as much. This ticket is resolved as far as the original issue is concerned.

Pierre.Vriens’s picture

Waw,, what started as an apparent minor issue about some PDF stuff, has evolved in something what I think is a great sample of some forena fans making forena even better! Expect a lot of this PDF related info to be included in the tutorials soon, probably including the current "known limitation about graphs in DOC/XLS". Thanks David, and thanks Nick!

Pierre.Vriens’s picture

Component: Miscellaneous » Report

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.