combine_pdf
combine_pdf copied to clipboard
Smart links are not updating or working in the combine process
Let me explain the two scenarios where we are using the links to refer a different sections in the PDF.
1.- If the links and the sections are in the same PDF generated those are working properly as expected. 2.- If you have multiple PDF's and combine them in the following way: 2.1 .- PDF 1 Generate links to X, N references. Those references are not included in this PDF but they will be present in the PDF 2. 2.2 .- PDF 2 Include the references. The output in the point 2 is that those links are not working and unable to click them. Please advice.
result = CombinePDF.new
# Cover
@export = ExportTemplate.where(:name => "Test Cover").first
cover_pdf_html_content = ApplicationController.new.render_to_string( :locals => {:"@export" => @export, :"@project" => @project, :"@project_products" => @project_products}, :show_as_html => false, :header => header_settings, :footer => footer_settings, :margin => margin_settings, :pdf => 'marriott-cover.pdf', :layout => "pdf.html.erb", :encoding => "UTF-8", :template => "firm/templates/show.html.erb", :page_size => 'Letter', :javascript_delay => 100 )
cover_src_temp_file = Tempfile.new(['cover_src_temp_file', '.pdf'])
cover_src_temp_file.binmode
cover_src_temp_file.write(cover_pdf_html_content)
cover_src_temp_file.rewind
result << CombinePDF.load(cover_src_temp_file.path)
# Table of Contents
@export = ExportTemplate.where(:name => "Test TOC").first
toc_pdf_html_content = ApplicationController.new.render_to_string( :locals => {:"@export" => @export, :"@project" => @project, :"@firm" => @firm, :"@project_products" => @project_products}, :show_as_html => false, :margin => margin_settings, :pdf => 'marriott-toc.pdf', :layout => "pdf.html.erb", :encoding => "UTF-8", :template => "firm/templates/show.html.erb", :page_size => 'Letter', :javascript_delay => 100 )
toc_src_temp_file = Tempfile.new(['toc_src_temp_file', '.pdf'])
toc_src_temp_file.binmode
toc_src_temp_file.write(toc_pdf_html_content)
toc_src_temp_file.rewind
result << CombinePDF.load(toc_src_temp_file.path)
# Loop all the intro attachments here
# 1 PDF
@export = ExportTemplate.where(:name => "Test Title Center").first
title_center_pdf_html_content = ApplicationController.new.render_to_string( :locals => {:"@export" => @export, :"@project" => @project, :"@firm" => @firm, :"@title" => "Test 1", :"@title_index" => "text_index_1"}, :show_as_html => false, :margin => margin_settings, :pdf => 'marriott-title-center.pdf', :layout => "pdf.html.erb", :encoding => "UTF-8", :template => "firm/templates/show.html.erb", :page_size => 'Letter', :javascript_delay => 100 )
title_center_src_temp_file = Tempfile.new(['title_center_src_temp_file', '.pdf'])
title_center_src_temp_file.binmode
title_center_src_temp_file.write(title_center_pdf_html_content)
title_center_src_temp_file.rewind
result << CombinePDF.load(title_center_src_temp_file.path)
temp_file = Tempfile.new([filename_wo_ext, ".#{@export.extension}"])
temp_file.binmode
temp_file.write(result.to_pdf)
temp_file`