Viewing 1 replies (of 1 total)
  • Plugin Author algol.plus

    (@algolplus)

    Hi Shane

    we use CSV file as storage for PDF. So it’s possible to rebuild it.

    try add following code to section “Misc Settings”
    thanks, Alex

    // rebuild CSV file to 3 columns 
    add_action("woe_pdf_started", function($pdf, $formatter){
        //read
        $file = fopen($formatter->filename, 'r');
        $keys = fgetcsv($file);
        $rows = array();
        while ($val = fgetcsv($file))
            $rows[] = $val;
        fclose($file);
    
        //write back
        $file = fopen($formatter->filename, 'w');
        fputcsv($file, array_merge($keys,$keys,$keys) ); //write 3 headers
        
        // merge lines 
        $row_out = array(); 
        $out_counter = 0;
        foreach($rows as $row) {
    		$out_counter++;
    		$row_out = array_merge($row_out,$row);
    		if($out_counter == 3 ) {
    			fputcsv($file,$row_out);
    			$row_out = array(); 
    			$out_counter = 0;
    		}	
        }    
    	if($out_counter != 0 ) 
    		fputcsv($file,$row_out);
    		
        fclose($file);
    },10,2);
    • This reply was modified 4 years, 7 months ago by algol.plus.
Viewing 1 replies (of 1 total)
  • The topic ‘PDF Export – Format / Display – Column’ is closed to new replies.