You can find out more about open at http://www.ruby-doc.org/core/classes/Kernel.
html# M005969.
CHAPTER 8 n CREATING SALES PERFORMANCE REPORTS WITH SUGARCRM 168
After this, the variable pdf_source contains your PDF file. All that??™s left to do is print it:
File.open('report.pdf','wb+') do |pdf_file_handle|
pdf_file_handle.puts pdf_source
end
Of course, you can change the report.pdf string literal to some other file name if you
want to use a different file name for your report.
Summary
SugarCRM is a powerful open source alternative to expensive CRM software, and its
architecture lets you quickly and easily create reports using Ruby and Active Record. In
this chapter, you used html2ps and Ghostscript to extend SugarCRM with reporting for
sales goals, and that combination let you create PDFs without using a special-purpose
language. Plus, you used Erubis to keep the HTML clean and separate from your source
code, even though the script isn??™t a Rails application.
In the next chapter, you??™ll see how to create reports from Apache logs, so you can
generate reports that pull data from the traffic logs of any web site that runs Apache.
Pages:
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245