SugarCRM: Pdf generation - pdf-generation

I'm a newbie to SugarCRM development. In my project, I have to generate a pdf for one entity details(say Account details). On details page, I have added "Print PDF" button, upon clicking this button I have one independent script (I mean to say that it was not implemented as per Sugar framework). In this script we are querying database for the required details and building one html string. Using html2pdf library, converting this html string to pdf.
I dont know whether it is an efficient implementation or not, but everything is working fine as per the requirement. But we have one problem when the original string contains some special characters like currency symbols of different countries. We are getting the html fine, but in pdf getting question marks (?) for those special characters.
While trying to fix this issue, when I looked into SugarCRM code, I found some pdf classed inside includes/ directory that creating an impression that Sugar itself has some built-in library to generate pdf's. Is it true?
If that is true, will it solve my problem, i.e. displaying different countries currency symbols in pdf.
Can anybody please help me to in resolving this. Thanks in advance.
-Venkat Nehatha

Venkat, SugarCRM does indeed have its own pdf generation ability. We use it to generate customer orders, quotes, invoices, and statements.
Though I've done some work on the pdf generation myself, I don't think I'm really experienced enough to be able to guide someone else in detail in the use of Sugar's pdf capabilities. I can tell you that we use pdf generation only in our own custom modules, so the files are found in [sugarRoot]/modules/[customModule]/. (You may know that unless you know exactly what you're doing, NEVER modify the main SugarCRM files in the [root]/modules/ folder!) In the previously mentioned custom module folder are two sub-folders, "sugarpdf", which has the code that accesses the modules/database to get the information to write to the pdf, and a "tpls" folder that holds the layout information for the header, body, and footer of the pdf, in HTML format, using the information from the sugarpdf folder's file.
I strongly recommend you visit the SugarCRM developer forums where you will be in touch with many developers much more experienced than me in Sugar.
I hope this helps in some way.

Related

Building a Character Generator

I'm looking to build a character generator for 5th edition dungeons and dragons, just as a side project. However what i don't know is which language to use. so far Ive narrowed down that i need a language that can successfully export out to a PDF, so that variables submitted to the program get passed and the character sheet can be print. any suggestions?
many languages should be able to handle this for you. the first question i would ask yourself is what language are you most fluent in?
for me that would be php so i would end up doing this project in a combination of html/js/php.
i have used fpdf for generating pdf that either output to the browser, save to the server, or trigger a download. ( http://www.fpdf.org/ )
fpdf was pretty easy to pick up following the examples.

Identifying elements in OpenXML Presentations

I have an interesting problem that I would like to throw out to you all - see if anyone can think of anything I haven't.
What I need to be able to do here is to somehow assign / determine identifers for all the paragraphs in a Presentation. I then need to be able, at some point in the future, to open / manipulate that presentation using OpenXML, and the identifiers have to be available for use at this point.
In short then, I need some form of persistent identifier.
I've tried looking at the OpenXMLFormat itself, and cannot see anything there that I can use that's already built in. If anyone knows of anything, any element that's already in the schema I might use, any attribute etc, then please shout up...
Trying to solve this problem myself, I have written code using XLinq and SharpZipLib to open up the various xml files and add a custom attribute to every element - the attribute basically containing a Guid. The code does what it is supposed to - but both Powerpoint and OpenXML 2.5 will then no longer talk to the file - presumably because I have introduced attributes that are not in the schema... I could live without Powerpoint being able to access the file at this point, but OpenXML is a bit of a blocker because the file will be undergoing some processing later on that has a definite dependency on the OpenXml library.
Anyone got any ideas?

Integrating LATEX in my codeIgniter project

I am exhausted searching for the way to integrate LATEX in my codeigniter project. But i cant find any way. In my website I need to insert and show mathematical terms and figures in HTML.
how can i easily do i don't know.If LATEX is the only way what is the easy way to do that.
would you please suggest me a way.
I suggest you save the latex code in the server-side and when you are showing on the website in HTML you can perform the conversion using Pandoc (a universal markup languages conversor).
But I'm not sure if this would work for mathematical symbols. Maybe you need to use another program (eg ImageMagick).

Generate a business letter for 100+ leads using wkhtmltopdf

We need to print Business Letter for a given list with mail merge facilities.
My client is not willing to spend $$ on a paid ASP.NET control to make PDF. So I opted in for WKHTMLtoPDF and it works fine for us until one day the client tried to get a PDF of 100+ leads, resulting in complete failure of PDF generation. It works just fine with a 10-20 page PDF, but not for 100.
Are there any tips & tricks to improve performance? We are using Cloud-hosted IIS 7 with ASP.NET 4 if that matters.
PDFSharp library is really a nice one!
I have used it for quite a while now, and I find it flexible enough to fulfill your needs.
However there are some aspects of using it as a "standalone library" - e.g creating tables is a headache and there aren't much text formatting options. It is much better to mix it together with MigraDoc (an extension library for PDFSharp).
If you're looking for a really free (as in "free of worries") library, choose iTextPDF versions prior to version 4.1.7, as they state in the ByteScout blog.
From the ByteScout blog:
iTextSharp 4.1.6 DLL only: itextsharp-4.1.6-dll.zip
iTextSharp 4.1.6 Source Code (C#): itextsharp-4.1.6.zip
I'm not sure I understand your problem but couldn't you generate docx documents and get the same results?
For all, I use http://wkhtmltopdf.org/ to create HTML to PDF, my ASP.NET code generate the HtML file then I create HTML to PDF and it is done, much easier than using itextpdf's Table and td structure to get things in better space. I found it easy and fast once you get your stuff aligned properly.
library has improved since original question asked and it performs better now.
here is good tutorial http://www.codeproject.com/Articles/20640/Creating-PDF-Documents-in-ASP-NET

Saving PDF files with Chickenfoot

I'm writing a web-crawler using Chickenfoot and need to save PDF files. I can either click the link on the page or grab the PDF's URL and use
go("http://www.whatever.com/file.pdf")
and I get the firefox "Opening file.pdf" dialog box, but can't click the "OK" button to actually save the file.
I've tried using other means to download the files (wget, python's urllib2, twill), but the PDF files are gated so none of those will work.
Any help is appreciated.
This example of how to save a target in the Mozilla developer documents looks like it should do exactly what you want. I've tested a Chickenfoot example that is very similar that gets the temp environment variable, and that worked well for me in Chickenfoot.
https://developer.mozilla.org/en/XPCOM_Interface_Reference/nsIWebBrowserPersist#Example
You might have to play with the application associations in Tools, Options, Applications to make sure the action is set to Save File, but those settings might not apply to these functions.
End Answer, begin related grumblings...
I sure wish someone would fix the many bugs in Chickenfoot, and write a nice Cookbook programming guide. I've been using it for years, and there are still many basic things I've not been able to figure out how to do. I finally broke down and subscribed to the mailing list, as the archives have some decent script examples. It takes a lot of searching through the pdf references, blogs, etc. as the web API reference is very sparse.
I love how simple Chickenfoot can make automating some tasks, but it takes me days of searching javascript, DOM, and Firefox documents to find ways to do some of the things it can't, since I'm not really a web programmer. The goal of Chickenfoot seems to be that I shouldn't have to be, but unfortunately few are refining the proof of concept, as MIT has dropped the project.
I tried to do this several ways using only Chickenfoot commands and confirmed they don't work with the latest Firefox 3 and Chickenfoot 1.0.7.
I hope this helps! Good luck. Sorry I only ran across your question yesterday, but found it too interesting to leave alone.
You won't be able to click on Firefox dialogs for the sake of security.
The best way to download the content of a URL is to read then write the content of the URL.
// Chickenfoot 1.0.7 Javascript Code to download the content of a url.
include( "fileio.js" ); // enables the write function.
var url = "http://google.com",
saveFileTo = "c://chickenfoot-google.com";
write( saveFileTo, read( url ) );
You might find it helpful to use jquery with chickenfoot.
http://groups.csail.mit.edu/uid/chickenfoot/scripts/index.php?title=Using_jQuery,_jQuery_UI_and_similar_libraries
This has worked for me to save Excel files from NCES portal.
http://muaz-khan.blogspot.com/2012/10/save-files-on-disk-using-javascript-or.html
I was using Firefox 3.0 and the "old syntax" version of the code. I also stripped code intended for IE and "(window.URL || window.webkitURL).revokeObjectURL(save.href);" which generated an error.

Resources