Method: PDF::Writer#render
- Defined in:
- lib/extensions/pdf-writer/pdf/writer.rb
#render(debug = false) ⇒ Object Also known as: to_s
Return the PDF stream as a string.
703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 |
# File 'lib/extensions/pdf-writer/pdf/writer.rb', line 703 def render(debug = false) add_page_numbers @compression = false if $DEBUG or debug @arc4.init(@encryption_key) unless @arc4.nil? check_all_here xref = [] content = "%PDF-#{@version}\n%âãÏÓ\n" pos = content.size objects.each do |oo| cont = oo.to_s content << cont xref << pos pos += cont.size end # pos += 1 # Newline character before XREF content << "\nxref\n0 #{xref.size + 1}\n0000000000 65535 f \n" xref.each { |xx| content << "#{'%010d' % [xx]} 00000 n \n" } content << "\ntrailer\n" content << " << /Size #{xref.size + 1}\n" content << " /Root 1 0 R\n /Info #{@info.oid} 0 R\n" # If encryption has been applied to this document, then add the marker # for this dictionary if @arc4 and @encryption content << "/Encrypt #{@encryption.oid} 0 R\n" end if @file_identifier content << "/ID[<#{@file_identifier}><#{@file_identifier}>]\n" end content << " >>\nstartxref\n#{pos}\n%%EOF\n" content end |