Skip to content

Instantly share code, notes, and snippets.

View sahidursuman's full-sized avatar

Sahidur Rahman Suman sahidursuman

View GitHub Profile
require 'prawn'
require 'barby'
require 'barby/barcode/code_128'
require 'barby/outputter/prawn_outputter'
barcode = Barby::Code128B.new('1234567890')
outputter = Barby::PrawnOutputter.new(barcode)
pdf = Prawn::Document.new
pdf.text "bla"
@sahidursuman
sahidursuman / pdf.rb
Created April 23, 2019 09:27 — forked from rcackerman/pdf.rb
prawn
class ReportPdf
include Prawn::View
def initialize(notice)
@notice = notice
noc_header
notice_of_claim
verification_header
verification_body
end
@sahidursuman
sahidursuman / sheet.rb
Created April 23, 2019 09:26
Is my code buggy or does prawn have a bug?
require 'rubygems'
require 'prawn'
require 'prawn/measurement_extensions'
class Sheet
SIZE = "LETTER"
LAYOUT = :portrait
ELEMENTS = {
:header => { :position => [(4.5).in, (10.0).in], :width => 3.in },
@sahidursuman
sahidursuman / prawn_report.rb
Created April 23, 2019 09:26 — forked from rebelweb/prawn_report.rb
Object Oriented Prawn Report
require 'prawn'
module Reports
class PrawnReport < Reports::Report
#call this from irb or any ruby code for that matter (i.e. Reports::PrawnReport.generate)
def self.generate
Prawn::Document.generate('prawn.pdf') do |pdf|
report_header(pdf)
report_body(pdf)
@sahidursuman
sahidursuman / prawn_wrapped.rb
Created April 23, 2019 09:26 — forked from jlsync/prawn_wrapped.rb
How to prevent prawn wrap_by_char? charred.pdf
#!/usr/bin/env ruby
require 'rubygems'
require 'prawn'
@pdf = Prawn::Document.new
x = 0
texts = [ "alexander", "the alexander", "the alexander building" ]
texts.each do |text|
pdf = Prawn::Document.new(:page_size => [ 459, 595 ])
pdf.font_families.update(
"Gill" => { :bold => "#{Prawn::BASEDIR}/data/fonts/GillSansBold.ttf",
:italic => "#{Prawn::BASEDIR}/data/fonts/GillSansItalic.ttf",
:bold_italic => "#{Prawn::BASEDIR}/data/fonts/GillSansBoldItalic.ttf",
:light => "#{Prawn::BASEDIR}/data/fonts/GillSansLight.ttf",
:light_italic => "#{Prawn::BASEDIR}/data/fonts/GillSansLightItalic.ttf",
:normal => "#{Prawn::BASEDIR}/data/fonts/GillSans.ttf" } )
#Gallery
pdf = Prawn::Document.new(:page_size => [ 459, 595 ])
pdf.font_families.update(
"Gill" => { :bold => "#{Prawn::BASEDIR}/data/fonts/GillSansBold.ttf",
:italic => "#{Prawn::BASEDIR}/data/fonts/GillSansItalic.ttf",
:bold_italic => "#{Prawn::BASEDIR}/data/fonts/GillSansBoldItalic.ttf",
:light => "#{Prawn::BASEDIR}/data/fonts/GillSansLight.ttf",
:light_italic => "#{Prawn::BASEDIR}/data/fonts/GillSansLightItalic.ttf",
:normal => "#{Prawn::BASEDIR}/data/fonts/GillSans.ttf" })
module MaRuKu::Out::Prawn
def to_prawn(pdf)
@pdf = pdf
@pdf.font_size = 11
array_to_prawn(@children)
end
def array_to_prawn(children)
children.each do |c|
send("to_prawn_#{c.node_type}", c)
@sahidursuman
sahidursuman / mdtopdf.rb
Created April 23, 2019 09:05 — forked from matschaffer/mdtopdf.rb
A rough translation of markdown to pdf
require 'rubygems'
require 'jekyll'
require 'maruku'
require 'pathname'
# Need pre for inline format support
gem 'prawn', '=0.11.1.pre'
require 'prawn'
require 'to_prawn'
class Converter
@sahidursuman
sahidursuman / header.rb
Created April 23, 2019 09:05 — forked from surendrans/header.rb
Prawn PDF
def header pdf
pdf.repeat :all do
pdf.bounding_box([0, 720], :width => 540, :height => 720) do
pdf.stroke_bounds
pdf.cell :content => "<b><font size='17'>Company Name PTE LTD</font></b>
email: [email protected] web: www.sptiele.com",
:inline_format => true,
:leading => 10,
:width => pdf.bounds.width,
:height => 110,