suite
This commit is contained in:
parent
291b0ceefa
commit
143d2f03b6
1
.gitignore
vendored
1
.gitignore
vendored
@ -9,3 +9,4 @@ csv/
|
||||
private_medias/
|
||||
public/public_medias
|
||||
public/assets
|
||||
node_modules
|
@ -24,60 +24,38 @@ class Admin::PDocumentsController < ApplicationController
|
||||
@p_document = PDocument.find_by_token(params[:id])
|
||||
@element = @p_document.element
|
||||
params[:inline] = true
|
||||
if true
|
||||
|
||||
|
||||
if !params[:html]
|
||||
|
||||
@temp_file = "#{Rails.root}/pdf/p_documents/#{@p_document.d_number}_temp.pdf"
|
||||
@final_file = "#{Rails.root}/pdf/p_documents/#{@p_document.d_number}.pdf"
|
||||
|
||||
|
||||
view = ActionView::Base.new(Rails.root.join('app/views'))
|
||||
view.class.include ApplicationHelper
|
||||
view.class.include Rails.application.routes.url_helpers
|
||||
url = (Rails.env.development? ? "http://localhost:4000" : "http://biocoton.quartz.xyz").to_s+admin_p_document_path(:id => @p_document.token, :html => true)
|
||||
puts url
|
||||
pdf = ("pdf")
|
||||
system("node #{pdf}.js #{Shellwords.escape(url)} #{Shellwords.escape(@temp_file)}")
|
||||
|
||||
pdf = view.render(
|
||||
:pdf => "#{@p_document.element.id}",
|
||||
:template => "admin/p_documents/show.html.haml",
|
||||
|
||||
:locals => {:@element => @element, :@p_document => @p_document})
|
||||
|
||||
# then save to a file
|
||||
pdf = WickedPdf.new.pdf_from_string(pdf, :margin => { top: 0, # default 10 (mm)
|
||||
bottom: 0,
|
||||
left: 0,
|
||||
right: 0 })
|
||||
|
||||
save_path = @temp_file
|
||||
File.open(save_path, 'wb') do |file|
|
||||
file << pdf
|
||||
end
|
||||
require 'posix/spawn'
|
||||
|
||||
if @p_document.p_document_type.data_file
|
||||
|
||||
|
||||
|
||||
require 'posix/spawn'
|
||||
|
||||
::POSIX::Spawn::Child.new 'pdftk', @temp_file, 'background', @p_document.p_document_type.data_file.file.path, 'output', @final_file
|
||||
|
||||
#pdftk /Users/nico/Desktop/Sanstitre4.pdf background /Users/nico/Dev/negos_app/pdf_stamp/bl.pdf output sortie.pdf
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@data_to_send = File.open( @final_file).read
|
||||
else
|
||||
::POSIX::Spawn::Child.new 'pdftk', @temp_file, 'stamp', "#{Rails.root}/pdf_stamp/en-tete.pdf", 'output', @final_file
|
||||
|
||||
require 'posix/spawn'
|
||||
|
||||
::POSIX::Spawn::Child.new 'pdftk', @temp_file, 'background', "#{Rails.root}/pdf_stamp/en-tete.pdf", 'output', @final_file
|
||||
|
||||
@data_to_send = File.open( @final_file).read
|
||||
end
|
||||
|
||||
@data_to_send = File.open( @final_file).read
|
||||
|
||||
|
||||
send_data @data_to_send, :filename =>"#{@p_document.d_number}.pdf" , :type => 'application/pdf',:disposition => (params[:inline] ? 'inline' : "attachment")
|
||||
|
||||
|
||||
|
||||
else
|
||||
render :layout => false
|
||||
end
|
||||
|
@ -66,6 +66,8 @@ class PCustomerSheet < ActiveRecord::Base
|
||||
|
||||
self.payment_fin_de_mois= self.p_customer.payment_fin_de_mois
|
||||
|
||||
self.p_payment_type_id = self.p_customer.p_payment_type_id
|
||||
|
||||
end
|
||||
end
|
||||
|
||||
|
@ -2,6 +2,9 @@ class PDocument < ActiveRecord::Base
|
||||
belongs_to :p_document_type
|
||||
has_many :p_sheet_lines
|
||||
belongs_to :p_customer
|
||||
belongs_to :p_payment_type
|
||||
belongs_to :p_customer_sheet
|
||||
belongs_to :p_sheet_line
|
||||
|
||||
belongs_to :particular_bill, :class_name => "Particular"
|
||||
belongs_to :particular_send, :class_name => "Particular"
|
||||
@ -13,6 +16,26 @@ class PDocument < ActiveRecord::Base
|
||||
|
||||
attr_accessor :sheet_id
|
||||
|
||||
|
||||
after_initialize do
|
||||
|
||||
if self.element and self.element_type == "PCustomerSheet" and !self.id
|
||||
|
||||
|
||||
self.comptant = self.element.comptant
|
||||
|
||||
self.acompte = self.element.acompte
|
||||
self.acompte_percent = self.element.acompte_percent
|
||||
|
||||
self.payment_delais = self.element.payment_delais
|
||||
|
||||
self.payment_fin_de_mois= self.element.payment_fin_de_mois
|
||||
|
||||
self.p_payment_type_id= self.element.p_payment_type_id
|
||||
|
||||
end
|
||||
end
|
||||
|
||||
after_create do
|
||||
generate_number
|
||||
archive_sheet_line
|
||||
@ -252,5 +275,20 @@ class PDocument < ActiveRecord::Base
|
||||
end
|
||||
|
||||
|
||||
def echeance
|
||||
d = self.created_at
|
||||
if self.comptant
|
||||
d
|
||||
else
|
||||
d + self.payment_delais.to_i.day
|
||||
end
|
||||
if self.payment_fin_de_mois
|
||||
d = d.end_of_month
|
||||
end
|
||||
return d
|
||||
|
||||
end
|
||||
|
||||
|
||||
|
||||
end
|
||||
|
@ -232,6 +232,10 @@
|
||||
%hr
|
||||
%h4 Paiements
|
||||
|
||||
= form.input :p_payment_type_id, :label => "Type de paiement :", :include_blank => false, :collection => PPaymentType.order(:name).all, :as => :select, :input_html => {:id => "payment_type_id_select"}
|
||||
|
||||
|
||||
|
||||
= form.input :comptant, :label => "Paiement comptant nécessaire ?"
|
||||
|
||||
= form.input :acompte, :label => "Acompte nécessaire ?"
|
||||
|
@ -58,6 +58,9 @@
|
||||
|
||||
%h4 Paiements
|
||||
|
||||
= form.input :p_payment_type_id, :label => "Type de paiement :", :include_blank => false, :collection => PPaymentType.order(:name).all, :as => :select, :input_html => {:id => "payment_type_id_select"}
|
||||
|
||||
|
||||
= form.input :comptant, :label => "Paiement comptant nécessaire ?"
|
||||
|
||||
= form.input :acompte, :label => "Acompte nécessaire ?"
|
||||
|
@ -1,24 +1,15 @@
|
||||
#main
|
||||
|
||||
%div{:style => "position:absolute;top:4.4cm;right:1cm;text-align:right;"}
|
||||
=@p_document.label
|
||||
|
||||
n°
|
||||
=@p_document.d_number
|
||||
%br
|
||||
=l @element.created_at, :format => :date #@p_document.created_at
|
||||
|
||||
|
||||
|
||||
%div{:style => "height:380px;"}
|
||||
%div{:style => "height:4cm;"}
|
||||
|
||||
|
||||
|
||||
%table.table{:style => "position:absolute;right:1cm;top:220px"}
|
||||
%tr
|
||||
%td{:style => "width:5.5cm;border:0"}
|
||||
-if @p_document.particular_bill
|
||||
%h3 Adresse de facturation
|
||||
%div{:style => "position:relative;width:6cm;margin-right:0.2cm;float:right;"}
|
||||
%div{:style => "border:1px solid black;padding:4px 8px;min-height:80px;"}
|
||||
%h3{:style => "position:absolute;top:-30px;"} Adresse de facturation
|
||||
|
||||
|
||||
%strong=@p_document.particular_bill.organisation
|
||||
@ -38,14 +29,19 @@
|
||||
=@p_document.particular_bill.city
|
||||
%br
|
||||
=@p_document.particular_bill.country
|
||||
%br
|
||||
%br
|
||||
=@p_document.particular_bill.tel
|
||||
|
||||
.p_contacts
|
||||
-@element.particular_bill.p_contacts.each do |p_contact|
|
||||
.p_contact
|
||||
=p_contact.name if p_contact.name?
|
||||
=p_contact.tel if p_contact.tel?
|
||||
=link_to p_contact.email, "mailto:"+p_contact.email.to_s if p_contact.email?
|
||||
|
||||
|
||||
%td{:style => "width:5.5cm;border:0"}
|
||||
-if @p_document.particular_send
|
||||
%h3 Adresse de livraison
|
||||
%div{:style => "position:relative;width:6cm;margin-right:0.5cm;float:right;"}
|
||||
%div{:style => "border:1px solid black;padding:4px 8px;min-height:80px;"}
|
||||
|
||||
%h3{:style => "position:absolute;top:-30px;"} Adresse de livraison
|
||||
|
||||
%strong=@p_document.particular_send.organisation
|
||||
%br
|
||||
@ -64,11 +60,102 @@
|
||||
=@p_document.particular_send.city
|
||||
%br
|
||||
=@p_document.particular_send.country
|
||||
%br
|
||||
%br
|
||||
=@p_document.particular_bill.tel
|
||||
|
||||
.p_contacts
|
||||
-@element.particular_send.p_contacts.each do |p_contact|
|
||||
.p_contact
|
||||
=p_contact.name if p_contact.name?
|
||||
=p_contact.tel if p_contact.tel?
|
||||
=link_to p_contact.email, "mailto:"+p_contact.email.to_s if p_contact.email?
|
||||
|
||||
|
||||
%p{:style => "clear:both;height:0.5cm;"}
|
||||
|
||||
%table.en-tete-table{:style => "width:auto;"}
|
||||
%tr
|
||||
%th Date
|
||||
-if false
|
||||
%th N° Client
|
||||
%th Type
|
||||
%th Référence doc.
|
||||
|
||||
%tr
|
||||
|
||||
|
||||
%td{:style => "width:100px"}
|
||||
=l @element.created_at, :format => :date #@p_document.created_at
|
||||
|
||||
-if false
|
||||
%td{:style => "width:70px"}
|
||||
=@element.p_customer.code
|
||||
|
||||
%td{:style => "width:110px"}
|
||||
=@p_document.label
|
||||
|
||||
%td{:style => "width:90px"}
|
||||
=@p_document.d_number
|
||||
%br
|
||||
|
||||
|
||||
=render :partial => "admin/p_sheet_lines/print_p_sheet_lines", :locals => {:sheet_lines => @p_document.p_sheet_lines }
|
||||
|
||||
|
||||
%table.en-tete-table{:style => "width:auto;position:relative;"}
|
||||
%tr
|
||||
%th Conditions de réglement
|
||||
%th Echéance
|
||||
|
||||
|
||||
%tr
|
||||
|
||||
|
||||
%td{:style => "width:150px;"}
|
||||
-if @p_document.p_payment_type
|
||||
=@p_document.p_payment_type.name
|
||||
="-"
|
||||
|
||||
-if @p_document.comptant
|
||||
Comptant
|
||||
-else
|
||||
=@p_document.payment_delais.to_i
|
||||
-if @p_document.payment_fin_de_mois
|
||||
jours fin de moi
|
||||
-else
|
||||
jours nets
|
||||
|
||||
%td{:style => "width:100px"}
|
||||
=l @p_document.echeance, :format => :date
|
||||
|
||||
|
||||
-if @element.p_customer.p_contacts.count > 0
|
||||
%p{:style => "margin-bottom:0;"} Contacts généraux du compte client :
|
||||
.p_contacts
|
||||
-@element.p_customer.p_contacts.each do |p_contact|
|
||||
.p_contact
|
||||
=p_contact.name if p_contact.name?
|
||||
=p_contact.tel if p_contact.tel?
|
||||
=link_to p_contact.email, "mailto:"+p_contact.email.to_s if p_contact.email?
|
||||
|
||||
-if @p_document.d_prefix == "F"
|
||||
%p.reglement
|
||||
|
||||
Passée la date d'échéance ci-dessus, une pénalité de retard de 1% mois sera
|
||||
appliquée (Loi 2008-776 du 4 août 2008) ainsi qu'une indemnité pour frais de
|
||||
recouvrement de 40€ (Décret 2012-1115 du 2 octobre 2012).
|
||||
%br
|
||||
Pas d'escompte pour règlement anticipé.
|
||||
|
||||
:scss
|
||||
.en-tete-table{
|
||||
table{
|
||||
border-collapse:collapse;
|
||||
}
|
||||
td,th{
|
||||
border:1px solid black;
|
||||
}
|
||||
}
|
||||
.reglement{
|
||||
margin-top:20px;
|
||||
color:rgba(0,0,0,0.6);
|
||||
font-size:8pt;
|
||||
}
|
@ -7,7 +7,7 @@
|
||||
<link href="https://fonts.googleapis.com/css?family=Lato:400,400i,700,700i" rel="stylesheet">
|
||||
:scss
|
||||
body{
|
||||
font-size:11pt;
|
||||
font-size:9pt;
|
||||
padding :0px;
|
||||
margin:0px;
|
||||
background-color: transparent;
|
||||
|
@ -67,7 +67,7 @@
|
||||
|
||||
-if form.object.p_product
|
||||
|
||||
-p_product.p_sizes.all.each do |p_size|
|
||||
-p_product.p_sizes.order("p_sizes.position ASC, p_sizes.id ASC").all.each do |p_size|
|
||||
%th.size_th
|
||||
=p_size.name
|
||||
|
||||
@ -79,7 +79,7 @@
|
||||
%tr.color_line
|
||||
%td=p_color.name
|
||||
|
||||
-p_product.p_sizes.all.each do |p_size|
|
||||
-p_product.p_sizes.order("p_sizes.position ASC, p_sizes.id ASC").all.each do |p_size|
|
||||
%td
|
||||
-ps = p_product.p_product_stocks.where(:p_size_id => p_size.id, :p_color_id => p_color.id).first
|
||||
|
||||
|
@ -44,7 +44,7 @@
|
||||
=sheet_line.product_name
|
||||
|
||||
|
||||
-sheet_line.p_product.p_sizes.all.each do |psize|
|
||||
-sheet_line.p_product.p_sizes.order("p_sizes.position ASC, p_sizes.id ASC").all.each do |psize|
|
||||
%th.p_size_td=psize.name
|
||||
|
||||
|
||||
@ -63,7 +63,7 @@
|
||||
%td
|
||||
=pc.name
|
||||
|
||||
-sheet_line.p_product.p_sizes.all.each do |psize|
|
||||
-sheet_line.p_product.p_sizes.order("p_sizes.position ASC, p_sizes.id ASC").all.each do |psize|
|
||||
|
||||
%td.p_size_td
|
||||
-psl = p_sheet_line_lines.joins(:p_product_stock).where(:p_product_stocks => {:p_size_id => psize.id, :p_color_id => pc.id} ).first
|
||||
|
@ -37,7 +37,7 @@
|
||||
=sheet_line.product_name
|
||||
|
||||
|
||||
-p_sheet_line_lines.group(:p_size_id).uniq.each do |psize|
|
||||
-p_sheet_line_lines.group(:p_size_id).joins(:p_size).order("p_sizes.position ASC, p_sizes.id ASC").uniq.each do |psize|
|
||||
%th.p_size_td=psize.p_size.name
|
||||
|
||||
|
||||
@ -55,7 +55,7 @@
|
||||
%td
|
||||
=pc.p_color.name
|
||||
|
||||
-p_sheet_line_lines.group(:p_size_id).uniq.each do |psize|
|
||||
-p_sheet_line_lines.group(:p_size_id).joins(:p_size).order("p_sizes.position ASC, p_sizes.id ASC").uniq.each do |psize|
|
||||
|
||||
%td.p_size_td
|
||||
-psl = p_sheet_line_lines.where(:p_size_id => psize.p_size_id, :p_color_id => pc.p_color_id ).first
|
||||
@ -106,7 +106,8 @@
|
||||
|
||||
|
||||
%tr.sheet_line_head
|
||||
%td{:style => "text-align:right;padding-right:10px;", :colspan =>6}
|
||||
%td{:style => "border:0;", :colspan =>3}
|
||||
%td{:style => "text-align:right;padding-right:10px;", :colspan =>3}
|
||||
%strong
|
||||
=total[:label]
|
||||
%td
|
||||
@ -114,18 +115,21 @@
|
||||
|
||||
-if @p_document and @p_document.label == "Facture Acompte"
|
||||
%tr
|
||||
%td{:style => "text-align:right;padding-right:10px;", :colspan =>6}
|
||||
%td{:style => "border:0;", :colspan =>3}
|
||||
%td{:style => "text-align:right;padding-right:10px;", :colspan =>3}
|
||||
Pourcentage d'acompte :
|
||||
%td
|
||||
=@p_document.acompte_percent.to_s+"%"
|
||||
%tr
|
||||
%td{:style => "text-align:right;padding-right:10px;", :colspan =>6}
|
||||
%td{:style => "border:0;", :colspan =>3}
|
||||
%td{:style => "text-align:right;padding-right:10px;", :colspan =>3}
|
||||
Acompte HT :
|
||||
%td
|
||||
=number_to_currency @p_document.total_with_labels_table[:total][:value] * (@p_document.acompte_percent.to_f/100)
|
||||
|
||||
%tr.sheet_line_head
|
||||
%td{:style => "text-align:right;padding-right:10px;", :colspan =>6}
|
||||
%td{:style => "border:0;", :colspan =>3}
|
||||
%td{:style => "text-align:right;padding-right:10px;", :colspan =>3}
|
||||
%strong Acompte TTC :
|
||||
%td
|
||||
%strong=number_to_currency @p_document.total_with_labels_table[:total_ttc][:value] * (@p_document.acompte_percent.to_f/100)
|
||||
|
@ -72,6 +72,10 @@ namespace :deploy do
|
||||
run "ln -s #{deploy_to}shared/storage/public #{current_path}/public/public_medias"
|
||||
|
||||
|
||||
run "ln -s #{deploy_to}shared/storage/pdf #{current_path}/pdf"
|
||||
|
||||
run "ln -s #{deploy_to}shared/node_modules #{current_path}/node_modules"
|
||||
|
||||
run "ln -s #{deploy_to}shared/production.sqlite3 #{current_path}/db/production.sqlite3"
|
||||
|
||||
sudo "cp #{current_path}/config/env_init #{deploy_to}env_init"
|
||||
@ -117,6 +121,8 @@ namespace :deploy do
|
||||
run "mkdir #{deploy_to}shared/storage"
|
||||
run "mkdir #{deploy_to}shared/storage/private"
|
||||
run "mkdir #{deploy_to}shared/storage/public"
|
||||
run "mkdir #{deploy_to}shared/storage/pdf"
|
||||
run "mkdir #{deploy_to}shared/node_modules"
|
||||
run "mkdir #{deploy_to}shared/tmp"
|
||||
end
|
||||
|
||||
|
12
db/migrate/20190113232951_add_comptant_to_p_documents.rb
Normal file
12
db/migrate/20190113232951_add_comptant_to_p_documents.rb
Normal file
@ -0,0 +1,12 @@
|
||||
class AddComptantToPDocuments < ActiveRecord::Migration
|
||||
def change
|
||||
add_column :p_documents, :comptant, :boolean, :default => true
|
||||
add_column :p_documents, :acompte, :boolean, :default => false
|
||||
|
||||
|
||||
add_column :p_documents, :payment_delais, :integer
|
||||
add_column :p_documents, :payment_fin_de_mois, :boolean, :default => false
|
||||
|
||||
|
||||
end
|
||||
end
|
@ -0,0 +1,7 @@
|
||||
class AddTypePaymentToPCustomers < ActiveRecord::Migration
|
||||
def change
|
||||
|
||||
add_column :p_customers, :p_payment_type_id, :integer
|
||||
add_column :p_documents, :p_payment_type_id, :integer
|
||||
end
|
||||
end
|
5
db/migrate/20190120142139_add_position_to_p_sizes.rb
Normal file
5
db/migrate/20190120142139_add_position_to_p_sizes.rb
Normal file
@ -0,0 +1,5 @@
|
||||
class AddPositionToPSizes < ActiveRecord::Migration
|
||||
def change
|
||||
add_column :p_sizes, :position, :integer
|
||||
end
|
||||
end
|
@ -11,7 +11,7 @@
|
||||
#
|
||||
# It's strongly recommended that you check this file into your version control system.
|
||||
|
||||
ActiveRecord::Schema.define(version: 20181217203838) do
|
||||
ActiveRecord::Schema.define(version: 20190120142139) do
|
||||
|
||||
create_table "admin_admin_roles", force: :cascade do |t|
|
||||
t.integer "admin_id", limit: 4
|
||||
@ -850,6 +850,7 @@ ActiveRecord::Schema.define(version: 20181217203838) do
|
||||
t.string "siren", limit: 255
|
||||
t.string "siret", limit: 255
|
||||
t.string "ape", limit: 255
|
||||
t.integer "p_payment_type_id", limit: 4
|
||||
end
|
||||
|
||||
add_index "p_customers", ["p_price_cat_id"], name: "index_p_customers_on_p_price_cat_id", using: :btree
|
||||
@ -918,6 +919,11 @@ ActiveRecord::Schema.define(version: 20181217203838) do
|
||||
t.decimal "fdp_force_price", precision: 10, scale: 2
|
||||
t.decimal "acompte_percent", precision: 10, scale: 2
|
||||
t.decimal "acompte_value", precision: 10, scale: 2
|
||||
t.boolean "comptant", default: true
|
||||
t.boolean "acompte", default: false
|
||||
t.integer "payment_delais", limit: 4
|
||||
t.boolean "payment_fin_de_mois", default: false
|
||||
t.integer "p_payment_type_id", limit: 4
|
||||
end
|
||||
|
||||
create_table "p_eps", force: :cascade do |t|
|
||||
@ -1198,6 +1204,7 @@ ActiveRecord::Schema.define(version: 20181217203838) do
|
||||
t.datetime "created_at", null: false
|
||||
t.datetime "updated_at", null: false
|
||||
t.boolean "archived", default: false
|
||||
t.integer "position", limit: 4
|
||||
end
|
||||
|
||||
create_table "p_tank_stocks", force: :cascade do |t|
|
||||
|
317
package-lock.json
generated
Normal file
317
package-lock.json
generated
Normal file
@ -0,0 +1,317 @@
|
||||
{
|
||||
"name": "3p_app",
|
||||
"version": "1.0.0",
|
||||
"lockfileVersion": 1,
|
||||
"requires": true,
|
||||
"dependencies": {
|
||||
"agent-base": {
|
||||
"version": "4.2.1",
|
||||
"resolved": "https://registry.npmjs.org/agent-base/-/agent-base-4.2.1.tgz",
|
||||
"integrity": "sha512-JVwXMr9nHYTUXsBFKUqhJwvlcYU/blreOEUkhNR2eXZIvwd+c+o5V4MgDPKWnMS/56awN3TRzIP+KoPn+roQtg==",
|
||||
"requires": {
|
||||
"es6-promisify": "^5.0.0"
|
||||
}
|
||||
},
|
||||
"async-limiter": {
|
||||
"version": "1.0.0",
|
||||
"resolved": "https://registry.npmjs.org/async-limiter/-/async-limiter-1.0.0.tgz",
|
||||
"integrity": "sha512-jp/uFnooOiO+L211eZOoSyzpOITMXx1rBITauYykG3BRYPu8h0UcxsPNB04RR5vo4Tyz3+ay17tR6JVf9qzYWg=="
|
||||
},
|
||||
"balanced-match": {
|
||||
"version": "1.0.0",
|
||||
"resolved": "https://registry.npmjs.org/balanced-match/-/balanced-match-1.0.0.tgz",
|
||||
"integrity": "sha1-ibTRmasr7kneFk6gK4nORi1xt2c="
|
||||
},
|
||||
"brace-expansion": {
|
||||
"version": "1.1.11",
|
||||
"resolved": "https://registry.npmjs.org/brace-expansion/-/brace-expansion-1.1.11.tgz",
|
||||
"integrity": "sha512-iCuPHDFgrHX7H2vEI/5xpz07zSHB00TpugqhmYtVmMO6518mCuRMoOYFldEBl0g187ufozdaHgWKcYFb61qGiA==",
|
||||
"requires": {
|
||||
"balanced-match": "^1.0.0",
|
||||
"concat-map": "0.0.1"
|
||||
}
|
||||
},
|
||||
"buffer-from": {
|
||||
"version": "1.1.1",
|
||||
"resolved": "https://registry.npmjs.org/buffer-from/-/buffer-from-1.1.1.tgz",
|
||||
"integrity": "sha512-MQcXEUbCKtEo7bhqEs6560Hyd4XaovZlO/k9V3hjVUF/zwW7KBVdSK4gIt/bzwS9MbR5qob+F5jusZsb0YQK2A=="
|
||||
},
|
||||
"concat-map": {
|
||||
"version": "0.0.1",
|
||||
"resolved": "https://registry.npmjs.org/concat-map/-/concat-map-0.0.1.tgz",
|
||||
"integrity": "sha1-2Klr13/Wjfd5OnMDajug1UBdR3s="
|
||||
},
|
||||
"concat-stream": {
|
||||
"version": "1.6.2",
|
||||
"resolved": "https://registry.npmjs.org/concat-stream/-/concat-stream-1.6.2.tgz",
|
||||
"integrity": "sha512-27HBghJxjiZtIk3Ycvn/4kbJk/1uZuJFfuPEns6LaEvpvG1f0hTea8lilrouyo9mVc2GWdcEZ8OLoGmSADlrCw==",
|
||||
"requires": {
|
||||
"buffer-from": "^1.0.0",
|
||||
"inherits": "^2.0.3",
|
||||
"readable-stream": "^2.2.2",
|
||||
"typedarray": "^0.0.6"
|
||||
}
|
||||
},
|
||||
"core-util-is": {
|
||||
"version": "1.0.2",
|
||||
"resolved": "https://registry.npmjs.org/core-util-is/-/core-util-is-1.0.2.tgz",
|
||||
"integrity": "sha1-tf1UIgqivFq1eqtxQMlAdUUDwac="
|
||||
},
|
||||
"debug": {
|
||||
"version": "4.1.1",
|
||||
"resolved": "https://registry.npmjs.org/debug/-/debug-4.1.1.tgz",
|
||||
"integrity": "sha512-pYAIzeRo8J6KPEaJ0VWOh5Pzkbw/RetuzehGM7QRRX5he4fPHx2rdKMB256ehJCkX+XRQm16eZLqLNS8RSZXZw==",
|
||||
"requires": {
|
||||
"ms": "^2.1.1"
|
||||
}
|
||||
},
|
||||
"es6-promise": {
|
||||
"version": "4.2.5",
|
||||
"resolved": "https://registry.npmjs.org/es6-promise/-/es6-promise-4.2.5.tgz",
|
||||
"integrity": "sha512-n6wvpdE43VFtJq+lUDYDBFUwV8TZbuGXLV4D6wKafg13ldznKsyEvatubnmUe31zcvelSzOHF+XbaT+Bl9ObDg=="
|
||||
},
|
||||
"es6-promisify": {
|
||||
"version": "5.0.0",
|
||||
"resolved": "https://registry.npmjs.org/es6-promisify/-/es6-promisify-5.0.0.tgz",
|
||||
"integrity": "sha1-UQnWLz5W6pZ8S2NQWu8IKRyKUgM=",
|
||||
"requires": {
|
||||
"es6-promise": "^4.0.3"
|
||||
}
|
||||
},
|
||||
"extract-zip": {
|
||||
"version": "1.6.7",
|
||||
"resolved": "https://registry.npmjs.org/extract-zip/-/extract-zip-1.6.7.tgz",
|
||||
"integrity": "sha1-qEC0uK9kAyZMjbV/Txp0Mz74H+k=",
|
||||
"requires": {
|
||||
"concat-stream": "1.6.2",
|
||||
"debug": "2.6.9",
|
||||
"mkdirp": "0.5.1",
|
||||
"yauzl": "2.4.1"
|
||||
},
|
||||
"dependencies": {
|
||||
"debug": {
|
||||
"version": "2.6.9",
|
||||
"resolved": "https://registry.npmjs.org/debug/-/debug-2.6.9.tgz",
|
||||
"integrity": "sha512-bC7ElrdJaJnPbAP+1EotYvqZsb3ecl5wi6Bfi6BJTUcNowp6cvspg0jXznRTKDjm/E7AdgFBVeAPVMNcKGsHMA==",
|
||||
"requires": {
|
||||
"ms": "2.0.0"
|
||||
}
|
||||
},
|
||||
"ms": {
|
||||
"version": "2.0.0",
|
||||
"resolved": "https://registry.npmjs.org/ms/-/ms-2.0.0.tgz",
|
||||
"integrity": "sha1-VgiurfwAvmwpAd9fmGF4jeDVl8g="
|
||||
}
|
||||
}
|
||||
},
|
||||
"fd-slicer": {
|
||||
"version": "1.0.1",
|
||||
"resolved": "https://registry.npmjs.org/fd-slicer/-/fd-slicer-1.0.1.tgz",
|
||||
"integrity": "sha1-i1vL2ewyfFBBv5qwI/1nUPEXfmU=",
|
||||
"requires": {
|
||||
"pend": "~1.2.0"
|
||||
}
|
||||
},
|
||||
"fs.realpath": {
|
||||
"version": "1.0.0",
|
||||
"resolved": "https://registry.npmjs.org/fs.realpath/-/fs.realpath-1.0.0.tgz",
|
||||
"integrity": "sha1-FQStJSMVjKpA20onh8sBQRmU6k8="
|
||||
},
|
||||
"glob": {
|
||||
"version": "7.1.3",
|
||||
"resolved": "https://registry.npmjs.org/glob/-/glob-7.1.3.tgz",
|
||||
"integrity": "sha512-vcfuiIxogLV4DlGBHIUOwI0IbrJ8HWPc4MU7HzviGeNho/UJDfi6B5p3sHeWIQ0KGIU0Jpxi5ZHxemQfLkkAwQ==",
|
||||
"requires": {
|
||||
"fs.realpath": "^1.0.0",
|
||||
"inflight": "^1.0.4",
|
||||
"inherits": "2",
|
||||
"minimatch": "^3.0.4",
|
||||
"once": "^1.3.0",
|
||||
"path-is-absolute": "^1.0.0"
|
||||
}
|
||||
},
|
||||
"https-proxy-agent": {
|
||||
"version": "2.2.1",
|
||||
"resolved": "https://registry.npmjs.org/https-proxy-agent/-/https-proxy-agent-2.2.1.tgz",
|
||||
"integrity": "sha512-HPCTS1LW51bcyMYbxUIOO4HEOlQ1/1qRaFWcyxvwaqUS9TY88aoEuHUY33kuAh1YhVVaDQhLZsnPd+XNARWZlQ==",
|
||||
"requires": {
|
||||
"agent-base": "^4.1.0",
|
||||
"debug": "^3.1.0"
|
||||
},
|
||||
"dependencies": {
|
||||
"debug": {
|
||||
"version": "3.2.6",
|
||||
"resolved": "https://registry.npmjs.org/debug/-/debug-3.2.6.tgz",
|
||||
"integrity": "sha512-mel+jf7nrtEl5Pn1Qx46zARXKDpBbvzezse7p7LqINmdoIk8PYP5SySaxEmYv6TZ0JyEKA1hsCId6DIhgITtWQ==",
|
||||
"requires": {
|
||||
"ms": "^2.1.1"
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"inflight": {
|
||||
"version": "1.0.6",
|
||||
"resolved": "https://registry.npmjs.org/inflight/-/inflight-1.0.6.tgz",
|
||||
"integrity": "sha1-Sb1jMdfQLQwJvJEKEHW6gWW1bfk=",
|
||||
"requires": {
|
||||
"once": "^1.3.0",
|
||||
"wrappy": "1"
|
||||
}
|
||||
},
|
||||
"inherits": {
|
||||
"version": "2.0.3",
|
||||
"resolved": "https://registry.npmjs.org/inherits/-/inherits-2.0.3.tgz",
|
||||
"integrity": "sha1-Yzwsg+PaQqUC9SRmAiSA9CCCYd4="
|
||||
},
|
||||
"isarray": {
|
||||
"version": "1.0.0",
|
||||
"resolved": "https://registry.npmjs.org/isarray/-/isarray-1.0.0.tgz",
|
||||
"integrity": "sha1-u5NdSFgsuhaMBoNJV6VKPgcSTxE="
|
||||
},
|
||||
"mime": {
|
||||
"version": "2.4.0",
|
||||
"resolved": "https://registry.npmjs.org/mime/-/mime-2.4.0.tgz",
|
||||
"integrity": "sha512-ikBcWwyqXQSHKtciCcctu9YfPbFYZ4+gbHEmE0Q8jzcTYQg5dHCr3g2wwAZjPoJfQVXZq6KXAjpXOTf5/cjT7w=="
|
||||
},
|
||||
"minimatch": {
|
||||
"version": "3.0.4",
|
||||
"resolved": "https://registry.npmjs.org/minimatch/-/minimatch-3.0.4.tgz",
|
||||
"integrity": "sha512-yJHVQEhyqPLUTgt9B83PXu6W3rx4MvvHvSUvToogpwoGDOUQ+yDrR0HRot+yOCdCO7u4hX3pWft6kWBBcqh0UA==",
|
||||
"requires": {
|
||||
"brace-expansion": "^1.1.7"
|
||||
}
|
||||
},
|
||||
"minimist": {
|
||||
"version": "0.0.8",
|
||||
"resolved": "https://registry.npmjs.org/minimist/-/minimist-0.0.8.tgz",
|
||||
"integrity": "sha1-hX/Kv8M5fSYluCKCYuhqp6ARsF0="
|
||||
},
|
||||
"mkdirp": {
|
||||
"version": "0.5.1",
|
||||
"resolved": "https://registry.npmjs.org/mkdirp/-/mkdirp-0.5.1.tgz",
|
||||
"integrity": "sha1-MAV0OOrGz3+MR2fzhkjWaX11yQM=",
|
||||
"requires": {
|
||||
"minimist": "0.0.8"
|
||||
}
|
||||
},
|
||||
"ms": {
|
||||
"version": "2.1.1",
|
||||
"resolved": "https://registry.npmjs.org/ms/-/ms-2.1.1.tgz",
|
||||
"integrity": "sha512-tgp+dl5cGk28utYktBsrFqA7HKgrhgPsg6Z/EfhWI4gl1Hwq8B/GmY/0oXZ6nF8hDVesS/FpnYaD/kOWhYQvyg=="
|
||||
},
|
||||
"once": {
|
||||
"version": "1.4.0",
|
||||
"resolved": "https://registry.npmjs.org/once/-/once-1.4.0.tgz",
|
||||
"integrity": "sha1-WDsap3WWHUsROsF9nFC6753Xa9E=",
|
||||
"requires": {
|
||||
"wrappy": "1"
|
||||
}
|
||||
},
|
||||
"path-is-absolute": {
|
||||
"version": "1.0.1",
|
||||
"resolved": "https://registry.npmjs.org/path-is-absolute/-/path-is-absolute-1.0.1.tgz",
|
||||
"integrity": "sha1-F0uSaHNVNP+8es5r9TpanhtcX18="
|
||||
},
|
||||
"pend": {
|
||||
"version": "1.2.0",
|
||||
"resolved": "https://registry.npmjs.org/pend/-/pend-1.2.0.tgz",
|
||||
"integrity": "sha1-elfrVQpng/kRUzH89GY9XI4AelA="
|
||||
},
|
||||
"process-nextick-args": {
|
||||
"version": "2.0.0",
|
||||
"resolved": "https://registry.npmjs.org/process-nextick-args/-/process-nextick-args-2.0.0.tgz",
|
||||
"integrity": "sha512-MtEC1TqN0EU5nephaJ4rAtThHtC86dNN9qCuEhtshvpVBkAW5ZO7BASN9REnF9eoXGcRub+pFuKEpOHE+HbEMw=="
|
||||
},
|
||||
"progress": {
|
||||
"version": "2.0.3",
|
||||
"resolved": "https://registry.npmjs.org/progress/-/progress-2.0.3.tgz",
|
||||
"integrity": "sha512-7PiHtLll5LdnKIMw100I+8xJXR5gW2QwWYkT6iJva0bXitZKa/XMrSbdmg3r2Xnaidz9Qumd0VPaMrZlF9V9sA=="
|
||||
},
|
||||
"proxy-from-env": {
|
||||
"version": "1.0.0",
|
||||
"resolved": "https://registry.npmjs.org/proxy-from-env/-/proxy-from-env-1.0.0.tgz",
|
||||
"integrity": "sha1-M8UDmPcOp+uW0h97gXYwpVeRx+4="
|
||||
},
|
||||
"puppeteer": {
|
||||
"version": "1.11.0",
|
||||
"resolved": "https://registry.npmjs.org/puppeteer/-/puppeteer-1.11.0.tgz",
|
||||
"integrity": "sha512-iG4iMOHixc2EpzqRV+pv7o3GgmU2dNYEMkvKwSaQO/vMZURakwSOn/EYJ6OIRFYOque1qorzIBvrytPIQB3YzQ==",
|
||||
"requires": {
|
||||
"debug": "^4.1.0",
|
||||
"extract-zip": "^1.6.6",
|
||||
"https-proxy-agent": "^2.2.1",
|
||||
"mime": "^2.0.3",
|
||||
"progress": "^2.0.1",
|
||||
"proxy-from-env": "^1.0.0",
|
||||
"rimraf": "^2.6.1",
|
||||
"ws": "^6.1.0"
|
||||
}
|
||||
},
|
||||
"readable-stream": {
|
||||
"version": "2.3.6",
|
||||
"resolved": "https://registry.npmjs.org/readable-stream/-/readable-stream-2.3.6.tgz",
|
||||
"integrity": "sha512-tQtKA9WIAhBF3+VLAseyMqZeBjW0AHJoxOtYqSUZNJxauErmLbVm2FW1y+J/YA9dUrAC39ITejlZWhVIwawkKw==",
|
||||
"requires": {
|
||||
"core-util-is": "~1.0.0",
|
||||
"inherits": "~2.0.3",
|
||||
"isarray": "~1.0.0",
|
||||
"process-nextick-args": "~2.0.0",
|
||||
"safe-buffer": "~5.1.1",
|
||||
"string_decoder": "~1.1.1",
|
||||
"util-deprecate": "~1.0.1"
|
||||
}
|
||||
},
|
||||
"rimraf": {
|
||||
"version": "2.6.3",
|
||||
"resolved": "https://registry.npmjs.org/rimraf/-/rimraf-2.6.3.tgz",
|
||||
"integrity": "sha512-mwqeW5XsA2qAejG46gYdENaxXjx9onRNCfn7L0duuP4hCuTIi/QO7PDK07KJfp1d+izWPrzEJDcSqBa0OZQriA==",
|
||||
"requires": {
|
||||
"glob": "^7.1.3"
|
||||
}
|
||||
},
|
||||
"safe-buffer": {
|
||||
"version": "5.1.2",
|
||||
"resolved": "https://registry.npmjs.org/safe-buffer/-/safe-buffer-5.1.2.tgz",
|
||||
"integrity": "sha512-Gd2UZBJDkXlY7GbJxfsE8/nvKkUEU1G38c1siN6QP6a9PT9MmHB8GnpscSmMJSoF8LOIrt8ud/wPtojys4G6+g=="
|
||||
},
|
||||
"string_decoder": {
|
||||
"version": "1.1.1",
|
||||
"resolved": "https://registry.npmjs.org/string_decoder/-/string_decoder-1.1.1.tgz",
|
||||
"integrity": "sha512-n/ShnvDi6FHbbVfviro+WojiFzv+s8MPMHBczVePfUpDJLwoLT0ht1l4YwBCbi8pJAveEEdnkHyPyTP/mzRfwg==",
|
||||
"requires": {
|
||||
"safe-buffer": "~5.1.0"
|
||||
}
|
||||
},
|
||||
"typedarray": {
|
||||
"version": "0.0.6",
|
||||
"resolved": "https://registry.npmjs.org/typedarray/-/typedarray-0.0.6.tgz",
|
||||
"integrity": "sha1-hnrHTjhkGHsdPUfZlqeOxciDB3c="
|
||||
},
|
||||
"util-deprecate": {
|
||||
"version": "1.0.2",
|
||||
"resolved": "https://registry.npmjs.org/util-deprecate/-/util-deprecate-1.0.2.tgz",
|
||||
"integrity": "sha1-RQ1Nyfpw3nMnYvvS1KKJgUGaDM8="
|
||||
},
|
||||
"wrappy": {
|
||||
"version": "1.0.2",
|
||||
"resolved": "https://registry.npmjs.org/wrappy/-/wrappy-1.0.2.tgz",
|
||||
"integrity": "sha1-tSQ9jz7BqjXxNkYFvA0QNuMKtp8="
|
||||
},
|
||||
"ws": {
|
||||
"version": "6.1.2",
|
||||
"resolved": "https://registry.npmjs.org/ws/-/ws-6.1.2.tgz",
|
||||
"integrity": "sha512-rfUqzvz0WxmSXtJpPMX2EeASXabOrSMk1ruMOV3JBTBjo4ac2lDjGGsbQSyxj8Odhw5fBib8ZKEjDNvgouNKYw==",
|
||||
"requires": {
|
||||
"async-limiter": "~1.0.0"
|
||||
}
|
||||
},
|
||||
"yauzl": {
|
||||
"version": "2.4.1",
|
||||
"resolved": "https://registry.npmjs.org/yauzl/-/yauzl-2.4.1.tgz",
|
||||
"integrity": "sha1-lSj0QtqxsihOWLQ3m7GU4i4MQAU=",
|
||||
"requires": {
|
||||
"fd-slicer": "~1.0.1"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
23
package.json
Normal file
23
package.json
Normal file
@ -0,0 +1,23 @@
|
||||
{
|
||||
"name": "3p_app",
|
||||
"version": "1.0.0",
|
||||
"description": "== README",
|
||||
"main": "pdf.js",
|
||||
"directories": {
|
||||
"lib": "lib",
|
||||
"test": "test"
|
||||
},
|
||||
"scripts": {
|
||||
"test": "echo \"Error: no test specified\" && exit 1"
|
||||
},
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "git@quartz.snlab.fr:nicolas/3p_app.git"
|
||||
},
|
||||
"author": "",
|
||||
"license": "ISC",
|
||||
"dependencies": {
|
||||
"puppeteer": "1.11.0"
|
||||
},
|
||||
"devDependencies": {}
|
||||
}
|
28
pdf.js
Normal file
28
pdf.js
Normal file
@ -0,0 +1,28 @@
|
||||
'use strict';
|
||||
|
||||
const puppeteer = require('puppeteer');
|
||||
|
||||
const createPdf = async() => {
|
||||
let browser;
|
||||
try {
|
||||
browser = await puppeteer.launch({args: ['--no-sandbox', '--disable-setuid-sandbox']});
|
||||
const page = await browser.newPage();
|
||||
//await page.setViewport({width: 794, height: 1122, deviceScaleFactor: 1});
|
||||
await page.goto(process.argv[2], {timeout: 3000, waitUntil: 'networkidle2'});
|
||||
await page.waitFor(250);
|
||||
await page.pdf({
|
||||
path: process.argv[3],
|
||||
format: 'A4',
|
||||
margin: { top: 0, right: 0, bottom: 0, left: 0 },
|
||||
printBackground: false
|
||||
});
|
||||
} catch (err) {
|
||||
console.log(err.message);
|
||||
} finally {
|
||||
if (browser) {
|
||||
browser.close();
|
||||
}
|
||||
process.exit();
|
||||
}
|
||||
};
|
||||
createPdf();
|
Binary file not shown.
Loading…
x
Reference in New Issue
Block a user