Class: Intersail::Rpdf::ZapPdfClient

Inherits:
Object
  • Object
show all
Defined in:
lib/rpdf/services/zap_pdf_client.rb

Instance Method Summary collapse

Constructor Details

#initialize(address) ⇒ ZapPdfClient

Returns a new instance of ZapPdfClient.



7
8
9
10
# File 'lib/rpdf/services/zap_pdf_client.rb', line 7

def initialize(address)
  @url = address
  @ws = Savon.client(wsdl: "#{address}?wsdl")
end

Instance Method Details

#get_template_tags(templateFile) ⇒ Object



28
29
30
31
32
33
34
35
36
37
38
# File 'lib/rpdf/services/zap_pdf_client.rb', line 28

def get_template_tags(templateFile)
  templateData = Base64.encode64(File.read(templateFile))

  response = @ws.call(:get_template_tags, message: { data: templateData })

  return nil unless response

  tags = response.body[:get_template_tags_response][:get_template_tags_result]

  Intersail::Rpdf::Node.new(tags) unless tags.nil?
end

#make_pdf_with_local_file(templateFile, data, options = {}) ⇒ Object



16
17
18
19
20
21
22
23
24
25
26
# File 'lib/rpdf/services/zap_pdf_client.rb', line 16

def make_pdf_with_local_file(templateFile, data, options = {})
  templateData = Base64.encode64(File.read(templateFile))

  response = @ws.call(:make_pdf_with_xml, message: { data: templateData, xmlTags: data.to_xml(options) })

  return nil unless response

  pdfData = response.body[:make_pdf_with_xml_response][:make_pdf_with_xml_result]

  Base64.decode64(pdfData)
end

#urlObject



12
13
14
# File 'lib/rpdf/services/zap_pdf_client.rb', line 12

def url
  @url
end