Closed SubhaPrince closed 6 years ago
Hi @SubhaPrince ,
Thank you for opening this issue. I hope we can find a fast solution.
Could you send me the example PDFs so I can re-create the issue on my system?
Also, two question:
It's possible that the white background is actually an object (opaque rather than transparent).
Could test for this possibility?
Perhaps you could test if the order of the PDF attachment effects the result (the PDF "on top" hiding the one below it)...?
Which version of CombinePDF are you running? Can you make sure the issue occurs on the latest version (1.0.15)?
Kindly, Bo.
Hi, @boazsegev Thanks for your quick respond, i've attach the simple PDF file created by MAC pages.
@SubhaPrince , thank you for the example PDF.
I can recreate the issue and testing it. I'll keep you updated once I know more.
Bo.
I can confirm that the issue is with the example PDF.
For some reason, macOS prints a white background object (box), preventing the background from being transparent.
Here is a way to see for yourself:
# make a new PDF, fill it with a blue box.
pdf = CombinePDF.new
pdf.new_page
pdf.pages[0].textbox("Blue Box", box_color: [0,0,0.7], font_color: [1,1,1])
# Save a reference / control PDF as a control group for the experiment
pdf.save "1-control.pdf"
# load the "white font" PDF_created_by_MAC_pages.pdf
pdf2 = CombinePDF.load("~/Desktop/white_font.pdf")
# imprint the white page on top of the blue page
pdf.pages[0] << pdf2.pages[0]
# The saved PDF shows a blue stripe where the white background (margins) don't cover the blue.
pdf.save '1.pdf'
As you will see, due to differences in page sizes, the resulting PDF will have a thing blue stripe on the right margin where the white background isn't overlapping the blue box.
Kindly, Bo
@boazsegev exactly that's the issue. Can we set the example pdf(created by mac) to the background and write the content on temple ?
@SubhaPrince ,
It's quite easy to reverse the position of the "imprinting" - simply replace the <<
operator with >>
, or use the inject_page
method.
Here's another example:
pdf = CombinePDF.new
pdf.new_page
pdf.pages[0].textbox("Transparent Example")
# Save a reference / control PDF as a control group for the experiment
pdf.save "1-control.pdf"
# load the "white font" PDF_created_by_MAC_pages.pdf
pdf2 = CombinePDF.load("Desktop/white_font.pdf")
# imprint the white page beneath of the example PDF
pdf.pages[0] >> pdf2.pages[0]
# The saved PDF shows the example text above the white template.
pdf.save '1.pdf'
This example successfully imprints text on your example PDF.
Kindly, Bo
@boazsegev thanks for helping me.. Here is my solution
final_pdf = CombinePDF.new
company_template = CombinePDF.load(template_file.pdf).pages[0]
pdf = CombinePDF.load (content_file.pdf)
pdf.pages.each {|page| final_pdf << (company_template << page)}
final_pdf.save "final_document.pdf"
I've generate a pdf template using mac page/google doc
I've another pdf for content
But when i am merging them that time text font color of a content file is getting white
The combined pdf
Here is my sample code
Thanks