depends on the pdf generator you use. i believe most tools will keep the styles for print into account.
you can achieve this as @jshock pointed out before by adding thise code to your theme’s style.css file:
@media print {
.wpcf7cf-hidden {
display: block !important;
}
}
Thread Starter
Sam
(@samaresh)
Jules, Thanks I am using https://wordpress.org/plugins/send-pdf-for-contact-form-7/ PDF generator.
Looks like the above solution is not working for me. Any other alternate?
Regards
Sam
Hi Sam,
I just tested the plugin and it seems to work. Could you please explain what exactly isn’t working for you?
Jules
Thread Starter
Sam
(@samaresh)
Jules,
While I am adding the code like [group] <p> this is a test</p> [/group] inside Send PDF CF7(http://prntscr.com/f9pn4i) Here is the refrence ( http://prntscr.com/f9pm89 ).
Another end while I am receving the PDF in email all the empty filds are reflecting, which should be close.
REgards
Sam
Hi Sam,
I see. I looked into the code of the PDF plugin, but the plugin doesn’t allow other plugins to filter the text that is being written to the PDF, so there is not much I can do now. If you could convince the author of the plugin to make the text filterable I could edit the text before it is written to the PDF.
I think the change needs to happen in send-pdf-for-contact-form-7/classes/send-pdf.php at line 556
The text there should be changed to something like this:
} else {
$text = apply_filters('wpcf7pdf_text', $text, $contact_form);
$mpdf->WriteHTML($text);
}
that way I could use the wpcf7pdf_text filter to remove the hidden groups from the PDF
Thread Starter
Sam
(@samaresh)
Hi Jules
Thanks alot for your quick response. Let me try with your code and definitely I will update here.
Regards
Sam
well, the code in itself will not do anything. After the filter is exposed in the PDF plugin I will still need to write some code to actually use the filter.
If you are okay with WordPress development yourself, the thing you would need to do is extend my class in cf7cf.php, and use the filter to call a function inside the class that executes this code:
$regex = '@\[[\t ]*([a-zA-Z_][0-9a-zA-Z:._-]*)[\t ]*\](.*?)\[[\t ]*/[\t ]*\1[\t ]*\]@s';
preg_replace_callback($regex, array($this, 'hide_hidden_mail_fields_regex_callback'), $text)