Giter Site home page Giter Site logo

gtk_webkit_pdf's Introduction

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.

gtk_webkit_pdf's People

Stargazers

Mārtiņš Šulcs avatar Henning Sprang avatar Alex avatar

Watchers

Mohanraj Ramanujam avatar James Cloos avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.