Can FullCalendar be printed to PDF? - pdf-generation

I have tried printing FullCalendar.js rendered calendars to PDF, however none of the generators available seem to work:
Aspose PDF does not allow JavaScript, and straight up just doesn't support absolutely positioned elements
PrinceXML has known issues where it throws TypeError exceptions when processing JavaScript that are not reproducible in IE, Chrome or Firefox.
My minimal repro example for PrinceXML failure is the examples on Adam Shaw's FullCalendar site. Even when I save the generated HTML (via $("body").html()) and pass the generated HTML to PrinceXML, thus bypassing PrinceXML's incorrect JavaScript handling, PrinceXML doesn't lay out the absolutely positioned events correctly.
What are my options?

Your best bet is probably wkhtmltopdf, which uses the WebKit as the rendering engine. This means you can freely use CSS/Javascript. You might need to look into the javascript-delay option.
I have used wkhtmltopdf successfully in Ruby on Rails, but it appears you are using .NET. A quick search reveals some possible wkhtmltopdf wrapper libraries for .NET:
gmanny/Pechkin
codaxy/wkhtmltopdf
You may want to take a look at this answer for some alternative solutions.

My coworker found a simpler solution.
As it turns out, we ran into issues using Pechkin and wkhtmltopdf in test environments. Plus, it required us to set up an additional App Pool just to handle printing to PDF.
Use html2canvas.js library
Convert the canvas to base64. I recommend Fred Palmer's base64.js
Send base64 encoded value to server
Create web service that calls your PDF converter library. We use Aspose, and so all we do is add the image to an Aspose PDF object.
PROFIT!
This solution is incredibly slick, since it uses the user's own rendering engine to generate the PDF. This means WYSIWYG (What You See Is What You Get), so if the calendar looks good when the user uses it, it should print the same exact way! MONEY.

Related

Getting images from qlmanage

qlmanage can produce PNG's. Like this https://superuser.com/a/162221
But using the standard command I only get page 1.
Is it possible to get page 2? I was wondering if I could mimic the quicklook function in Apple Wiki.
qlmanage is really not meant as a tool for any production project. It's a debugging tool. It runs with different privileges as the normal quicklook, does not provide the same level of security. And moreover it's REALLY not meant to be used server side.
That said, to answer your question: no, when qlmanage produces PNGs, it's invoking generators' thumbnailing code which is not meant to page through the document.
The Quick Look function in Apple Wiki is using a specific client that is able to:
request the preview (and not thumbnails) from a limited set of generators
interpret the preview
produces images for each page of the preview when it makes sense
There is no public API to do that yourself, alas.

Automatically filling in web query forms and returning data (for a newbie)

I am whatever comes before 'novice' in programming. I have written macros in VBA for Excel, and used Visual Studio a bit when I was younger, but that's about it.
My problem: To produce the reports I need at work, I have to extract data that is stored behind user-friendly query forms on my company's intranet. I have automated every other part of the report except this. I would like to write a program to access this webpage and fill in query forms for me with preset values, and then return the data that is output. I had a discussion with a computer scientist friend of mine who said this was easy to do with Haskell (his language of choice). However I'm no veteran so I'd like to learn a language a bit nearer to my level... Python seems a good bet.
My question: is it possible to do this type of data extraction with Python? How difficult would it be, and what is a good resource to teach myself about it?
I've done some research and come up with Scrapy, but I can't tell whether it fills in forms. Also, if there are other languages more suited to this, I'd be glad to hear it.
The easiest way is just to use urllib2. Usually, arguments to your forms are transferred to the servers so that you can see them in the URL as ?foo=bar&bla=blah. You can generate arguments to your forms with urllib2.urlencode:
Python and urllib2: how to make a GET request with parameters.
For a newbie, you formulate your thoughts very clear, congrats.
I would start by reading some basic tutorials on HTTP. A form is basically just a visual way to collect data. The meat of the form is the request your browser makes with that form data.
So "filling in forms" is really not necessary (it may be though, hopefully its not because it CAN get complicated). What is necessary is learning what request that form actually makes to the browser and emulating it. A super easy way to do this is with chrome developer tools or a firefox extensions called firebug. Each of these provide you with a way to see all network traffic, including forms.
for example if you have a form where you have to submit a data and a report type the actual web request may look like
?date=2012-09-12&type=overview
so basically you would just have to find a way to make a http request to the url with that data. This is a trivial task and pretty much all languages have a way to do this.
It is very possible to do this with python. There is an abundance of tutorials out there. Python has url libraries built into the standard library that can help
http://docs.python.org/library/urllib.html
Everytime I use urllib2 I usually end up at http://www.voidspace.org.uk/python/articles/urllib2.shtml
Combining loginform and scrapy, you can automate filling forms and crawling web pages.
Here's a tutorial on it. http://blog.scrapinghub.com/2012/10/26/filling-login-forms-automatically/

Pretty print code to PDF

I'm searching for a tool that will take a source directory and produce a single PDF containing the source code, preferably with syntax highlighting.
I would like to read the PDF on my phone, in order to get familiar with a code-base, or just to see what I can learn by reading a lot of code. I will most often be reading Ruby.
I would prefer if the tool ran on Linux. I don't mind paying for a tool if it is particularly good.
Any suggestions?
You could wipe something up yourself with Prawn and Ultraviolet.
PDF is no good for reflowing. You might like a html based solution better.
And in reading existing code, a lineair model is no good. You need to jump from one file to the other. A hypertext model with history would probably work best on the limited screen estate of a phone. It should borrow some features of the smalltalk IDEs (jump to senders, implementors).
For the UI, take a look at clamato
GNU source-highlight supports many languages and can output LaTeX in particular that can be converted to pdf.
The SciTE editor can export the currently edited file (with syntax highlighting) to PDF (and HTML, RTF, LaTeX and XML).
Alas, it doesn't have batch conversion capability, but IIRC somebody made a batch tool out of this code base.
I realize this is very late, but I wanted to do the same thing, except I wanted it for my tablet, which is a Galaxy Note 10.1 with a Wacom digitizer that I can use to annotate code. I found that one good solution is to use Doxygen to generate a PDF which will have hyperlinks and everything you would want in a PDF. For my use case, I would pair it with EzPDF on Android to annotate the code. This was also for the purpose of learning a new codebase. In the end I ended up not using the generated PDF but it was pretty usable.

Create image viewer in ajax or flash?

I've been trying to do more Web development work recently (I currently do other tech stuff, but have some experience with Java, C++, VB, Python, and PHP) and I was asked to create a basic Web site with an image viewer. The site is for an artist and she wants the viewer so users can see thumbnails of her paintings and click them to see a large version.
There are a bunch of existing programs out there (for example, simpleviewer)--most seem to be Flash-based. I want to create my own for various reasons, not least of which is to learn about how to do it. Can anyone give me suggestions/opinions as to what technology to use and how to proceed? Not detailed steps, just pointers in the right direction. (For example, are there existing scripts I could find on the net and then tinker with/modify?) I'm already doing research to figure this out, but advice from savvy programmers will save me some time.
I don't know much about Flash or Ajax, but am willing to learn either (and would eventually like to learn both). I won't be shelling out $700 for Flash Pro right now, so I would need to use something like FlashDevelop if I go that route. Thanks in advance!
You'll want jQuery. jQuery.com
Jquery has tons of useful plugins: jquery plugins page
Start searching! Here's a good one i found searching for "image galley"
Enjoy. Jquery is your friend. Of course this post is biased. So, to give credits to others, you can also look into mootools, YUI, prototype, scriptaculous, etc.
If you are going to go down the flash root definitely look at http://slideshowpro.net/ (you don't need the Flash IDE to customise it - all done via XML settings)
An alternative is via JavaScript. A couple of cool scripts to look at are:
http://jquery.com/demo/thickbox/
http://fancy.klade.lv/
You can scan the images, base64 encode them into a database, then use an < img > tag on your site to point to a PHP page that base64 decodes the images. No real way to watermark them though you could do that before the you load them using GIMP or some similar tool.

What is Progressive Enhancement?

Jeff mentioned the concept of 'Progressive Enhancement' when talking about using JQuery to write stackoverflow.
After a quick Google, I found a couple of high-level discussions about it.
Can anyone recommend a good place to start as a programmer.
Specifically, I have been writing web apps in PHP and would like to use YUI to improve the pages I am writing, but a lot of them seem very JavaScript based, with most of the donkey work being done using JavaScript. To me, that seems a bit overkill, since viewing the site without Javascript will probably break most of it.
Anyone have some good places to start using this idea, I don't really care about the language.
Ideally, I would like to see how you start creating the static HTML first, and then adding the YUI (or whatever Ajax framework) to it so that you get the benefits of a richer client?
As you've said
To me, that seems a bit overkill, since viewing the site without Javascript will probably break most of it.
This isn't progressive enhancement. Progressive enhancement is when the site works perfectly without JavaScript or CSS, and then adding (layering) these extra technologies/code to increase the usability and functionality of the website.
The best example I can give is the tag input box on this website. With JavaScript turned off, it would still work allowing you to enter tags separated with a space. With JavaScript turned on, you get a drop down with suggestions of previous entries.
This is progressive enhancement.
See also Unobtrusive JavaScript which is the bedrock progressive enhancement is built.
Going at it from the other direction is sometimes referred to as graceful degradation. This is usually needed when the site is built first with the enhanced functionality afforded by the various technologies then modified to degrade gracefully for browsers with those technologies are not available.
It is also graceful degradation when designing to work with older browsers (ancient in the Internets terminology) such as IE 5.5, Netscape, etc...
In my opinion it is much more work to gracefully degrade the application. Progressively enhancing it tends to be much more efficient; however, sometimes the need to take an existing app and make it accessible in these lacking environments arise.
Basically, if your site still works with JavaScript turned off, then anything you add with JavaScript can be considered progressive enhancement.
Some people may think that this is unnecessary, but plenty of people browse with addons like NoScript (or, with JavaScript simply turned off in their browser settings). In addition, many Mobile web browsers may or may not support JavaScript. So, it's always a good idea to test your site completely with and without JavaScript.
Progressive Enhancement is a development technique that stresses the primacy of the semantic HTML, then testing for browser-capability and conditionally "layering" on JavaScript and/or CSS enhancements for the browsers that can utilize those enhancements.
One of the keys is understanding that we're testing for what the browser can do, as opposed to browser-sniffing. Modernizr is a very popular browser-capability test suite.
Progressive-Enhancement is inherently (section 508) accessible; it provides for meeting the letter of the law and the spirit of the rule.
The Filament Group wrote the excellent "Designing With Progressive Enhancement" book on the subject. (I am not affiliated with Filament Group, though they are so freaking smart I wish I were.)
This is such an important concept and it saddens me that so few web developers understand it.
Basically, start by building a site/framework in Plain Old HTML -- structural elements, links and forms. Then add on some style and then shiny stuff (Ajax or what have you).
It's not very difficult. Like palehorse says, graceful degradation is more work.
Websites should work in any user agent, not look the same (not even look but sound if your vision impaired), just work.
Progressive Enhancement:
The plain HTML/CSS site is awesome (fully working and user-friendly).
Adding JavaScript defines a new level of awesome.

Resources