You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
@jakejackson1 I believe my colleague @sandervdwnl reported this issue.
For your consideration: In our custom template, where it is possible to use the textarea field value as a merge tag, we solved it using the new WP_HTML_Tag_Processor (WP 6.2+)
/**
* Reduce classes of HTML that is being used to generate a PDF up to a maximum of 5.
*
* @param string $html PDF template HTML in string format
* @param array $form The current Gravity Forms array
* @param array $entry The raw Gravity Forms Entry array.
* @param array $settings The current PDF configuration array.
* @param object $Helper_PDF The initialised GFPDFHelperHelper_PDF class
* @return string $html The updated html.
*/
function reduce_classes_in_html_of_pdf( $html, $form, $entry, $settings, $Helper_PDF ) {
$processor = new WP_HTML_Tag_Processor( $html );
// Iterate through all tags.
while ( $processor->next_tag() ) {
$classes = $processor->get_attribute( 'class' );
if ( $classes !== null ) {
$class_array = explode( ' ', $classes );
// Limit the number of classes to 5.
if ( count( $class_array ) > 5 ) {
$class_array = array_slice( $class_array, 0, 5 );
// Set the new class attribute value.
$processor->set_attribute( 'class', implode( ' ', $class_array ) );
}
}
}
// Get the modified HTML.
return $processor->get_updated_html();
}
add_filter( 'gfpdf_pdf_html_output', 'reduce_classes_in_html_of_pdf', 20, 5 );
Description
This problem can occur if a user copy/paste code from another source that includes a lot of class names.
Consider stripping all the classes from the Rich Text field when output in a Core / Universal PDF.
The text was updated successfully, but these errors were encountered: