mrraj-zz / gtk_webkit_pdf Goto Github PK
View Code? Open in Web Editor NEWConvert HTML to PDF using GTK WEBKIT
Convert HTML to PDF using GTK WEBKIT
Creating The PDF from HTML using GTK WEBKIT Tool. MAIN FEATURE OF GTK_WEBKIT_PDF ============================== 1 . This is pure ruby extension based pdf creator using gtk webkit api. FEATURE ADDED WITH THIS NEW VERSION 0.0.2 ========================================= 1 . Supports for RAILS integration. 2 . Create pdf based on the format in the controller with various options. 3 . Supports for rake level pdf creation. EXAMPLE: webkit = GTK::Webkit.new(string_data, format, options) #creates the webkit object where "format" => 1 . 0(zero) - means you are giving the html string to the first parameter(that is string_data). 2 . 1(one) - future usage. 3 . 2(two) - means you are giving the URI to the first parameter(that is string_data). printer = webkit.gtk_printer #which returns the printer object, using this printer object you get the pdf content like below printer.pdf_content #returns pdf contenht as a string, then you can save this pdf content to a file or you can render using "send_data"(in the case of download). You can also export to a file using the following printer.export(base_url, filename) #base_url => base directory(like /home/mohanraj/), filename => name of the file, you want to export CONTROLLER BASED PDF CREATION ============================ In your controller just check the format, and render the pdf like below, class UsersController < ApplicationController def index @users = User.scoped respond_to do |format| format.html format.pdf{ render :pdf => "pdf_name" } end end end available options while rendering pdf, :layout => specify the layout, otherwise layout is false :template => template name to render :file => file to use :disposition => default to "inline" :format => :handler => NOTE: you have to create the view file for pdf like "index.pdf.erb" in the case of pdf render MIDDLEWARE SUPPORT ================== You can enable middleware by adding following line to config/application.rb config.middleware.use GTK::Middleware INSTALLATION ============ 1.You need to install the following development packages, 1 . gtk 2 . libsoup 3 . webkitgtk 4 . atk 5 . gdk-pixbuf 6 . glib 7 . cario 8 . pango 2.And the following the libs 1 . libgtk 2 . libwebkitgtk 3.NOTE: minimum gtk2 and webkitgtk2 is required. 4.Then you can install the gem whether directly or by using bundler. Thanks to GTK WEBKIT community.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.