Jsreport using Phantom to insert images into the body of the report

243 views
Skip to first unread message

Clive Biddulph

unread,
Jul 6, 2016, 5:03:40 PM7/6/16
to jsreport
Hi there,
I have been using JSreport for some time and found it great, but have found somthing I cannot see how to do.

Phantom PDF.
I need to insert an image into the doc ( In this case a bar code created using barcodej ), I can insert it using a url  but I would like to use a file if at all possible as the machine I will be running this one will not have a webserver running on it.

so it all works with a url



but in the log file I get this unable to access resource unless a url,jsreport can access the local machine which can be seen here


I have done other testing and from the logfile I have found this it is the jpeg file I want it to include 
2016-07-06T03:04:46.170Z - debug: Converting in dedicated phantomjs 1.9.8 timestamp=Wed Jul 06 2016 13:04:46 GMT+1000 (AEST), requestId=16
2016-07-06T03:04:46.171Z - debug: Request file:///%2Ftmp%2Fjsreport-temp%2F64c55110-4326-11e6-8b2f-abff4619a4afhtml.html timestamp=Wed Jul 06 2016 13:04:46 GMT+1000 (AEST), requestId=16
2016-07-06T03:04:46.171Z - debug: Request file:///%2Ftmp%2Fjsreport-temp%2F1.jpeg timestamp=Wed Jul 06 2016 13:04:46 GMT+1000 (AEST), requestId=16
2016-07-06T03:04:46.171Z - warn: Unable to load resource (#2URL:) timestamp=Wed Jul 06 2016 13:04:46 GMT+1000 (AEST), requestId=16
2016-07-06T03:04:46.171Z - warn: Error code: 301. Description: Protocol "" is unknown timestamp=Wed Jul 06 2016 13:04:46 GMT+1000 (AEST), requestId=16

<td style="width: 8%;"><font size="-1"><img src="file:///%2Ftmp%2Fjsreport-temp%2F1.jpeg" style="width:108px;height:28px;"> </font></td>

tried 

<td style="width: 8%;"><font size="-1"><img src="file:////tmp/jsreport-temp/1.jpeg" style="width:108px;height:28px;"> </font></td>

and 

<td style="width: 8%;"><font size="-1"><img src="file:///localhost/tmp/jsreport-temp/1.jpeg" style="width:108px;height:28px;"> </font></td> 


with one and two / after localhost and tried with the IP address. and it did not work any help would be great.


Clive Biddulph




Jan Blaha

unread,
Jul 10, 2016, 2:19:32 PM7/10/16
to jsreport
You need to enable local file access in the config - http://jsreport.net/learn/phantom-pdf

{
...
phantom: {
  allowLocalFilesAccess: true
}
}

Reply all
Reply to author
Forward
0 new messages