• Resolved arunschandran

    (@arunschandran)


    how can I add RTL support for PDF?

    I am using Hebrew language and I added direction RTL in CSS and I can see RTL support when I output the PDF content in HTML format. But in PDF, it is still LTR

Viewing 5 replies - 1 through 5 (of 5 total)
  • Plugin Contributor Ewout

    (@pomegranate)

    Hi! The PDF converter library that we use (dompdf) does not support RTL. In addition to this, Hebrew (and Arabic) characters are not supported by the font (Open Sans) that is used in the Simple Template.

    But, we have an experimental add-on that replaces dompdf with another library (mpdf) that supports RTL and also includes a font that supports hebrew and arabic (and pretty much any characterset on the planet, for that matter).

    The plugin is hosted on github here: https://github.com/wpovernight/woocommerce-pdf-ips-mpdf
    And you can download the plugin zip in the releases section: https://github.com/wpovernight/woocommerce-pdf-ips-mpdf/releases

    After activating the plugin, you can switch to the “Simple RTL” template which already has the correct font & text direction setup. We’d love to hear your feedback!

    Thread Starter arunschandran

    (@arunschandran)

    thank you quick response.

    I tried the plugin you mentioned. But i am getting “500 error” when I generating PDF.

    • This reply was modified 5 years, 2 months ago by arunschandran.
    Plugin Contributor Ewout

    (@pomegranate)

    Can you check your PHP log or the logs found under WooCommerce > Status > Logs (specifically ones starting with woocommerce-pdf-ips-mpdf) for more information about the source of the error?

    Thread Starter arunschandran

    (@arunschandran)

    Great. I found the issue. One file failed to upload. Now I uploaded the missing file.
    Now RTL is working perfect. Thank you for your support.

    I have one more question. how can I set the orientation and paper format? I am using this code

    add_filter( ‘wpo_wcpdf_paper_orientation’, ‘wcpdf_landscape’, 10, 2 );
    function wcpdf_landscape($paper_orientation, $template_type) {
    // use $template type ( ‘invoice’ or ‘packing-slip’) to set paper oriention for only one document type.
    if ($template_type == ‘packing-slip’) {
    $paper_orientation = ‘landscape’;
    }

    return $paper_orientation;
    }

    add_filter( ‘wpo_wcpdf_paper_format’, ‘wcpdf_a5_packing_slips’, 10, 2 );
    function wcpdf_a5_packing_slips($paper_format, $template_type) {
    if ($template_type == ‘packing-slip’) {
    $paper_format = ‘b5’;
    }

    return $paper_format;
    }

    This code was working, but after adding mPDF it is not working. Can you please help me with that too?

    Plugin Contributor Ewout

    (@pomegranate)

    I just tested this and it works fine for me. I used this, which is exactly the same as your code:

    
    add_filter( 'wpo_wcpdf_paper_orientation', 'wcpdf_landscape', 10, 2 );
    function wcpdf_landscape($paper_orientation, $template_type) {
    	// use $template type ( 'invoice' or 'packing-slip') to set paper oriention for only one document type.
    	if ($template_type == 'packing-slip') {
    		$paper_orientation = 'landscape';
    	}
    	return $paper_orientation;
    }
    
    add_filter( 'wpo_wcpdf_paper_format', 'wcpdf_a5_packing_slips', 10, 2 );
    function wcpdf_a5_packing_slips($paper_format, $template_type) {
    	if ($template_type == 'packing-slip') {
    		$paper_format = 'b5';
    	}
    	return $paper_format;
    }
    

    Do note that you have limited this to the packing slip, which means the invoice will be in the standard format. If you want to apply this to all documents, use the following code:

    
    add_filter( 'wpo_wcpdf_paper_orientation', 'wcpdf_landscape', 10, 2 );
    function wcpdf_landscape($paper_orientation, $template_type) {
    	return 'landscape';
    }
    
    add_filter( 'wpo_wcpdf_paper_format', 'wcpdf_a5', 10, 2 );
    function wcpdf_a5($paper_format, $template_type) {
    	return 'b5';
    }
    
Viewing 5 replies - 1 through 5 (of 5 total)
  • The topic ‘RTL support’ is closed to new replies.