public function __construct($item_id) { if ($item_id) { $this->item_id = $item_id; $this->root_item_id = WPD_Product::get_parent($item_id); } }
private function generate_pdf_layers($variation_id, $layers_array, $output_file) { global $wpc_options_settings; $product_id = WPD_Product::get_parent($variation_id); $wpc_metas = get_post_meta($product_id, 'wpc-metas', true); $product_metas = WPD_Admin::get_proper_value($wpc_metas, $variation_id, array()); $variation_output_settings = WPD_Admin::get_proper_value($product_metas, "output-settings", array()); $global_output_settings = $wpc_options_settings['wpc-output-options']; $pdf_format = WPD_Product::get_option($variation_output_settings, $global_output_settings, "pdf-format", "A0"); //WPD_Admin::get_proper_value($wpc_output_options, "pdf-format", "A0"); $pdf_orientation = WPD_Product::get_option($variation_output_settings, $global_output_settings, "pdf-orientation", "P"); //WPD_Admin::get_proper_value($wpc_output_options, "pdf-orientation", "P"); $pdf_margin_lr = WPD_Product::get_option($variation_output_settings, $global_output_settings, "pdf-margin-lr", 20); //WPD_Admin::get_proper_value($wpc_output_options, "pdf-margin-lr", 20); $pdf_margin_tb = WPD_Product::get_option($variation_output_settings, $global_output_settings, "pdf-margin-tb", 20); //WPD_Admin::get_proper_value($wpc_output_options, "pdf-margin-tb", 20); /*if ($nbCol <= 0 || $total <= 0) { $nbCol = 1; $total = 1; }*/ $pdf = new TCPDF($pdf_orientation, PDF_UNIT, $pdf_format, true, 'UTF-8', false); $pdf->SetCreator("Woocommerce Products Designer by ORION"); $pdf->SetAuthor('Woocommerce Products Designer by ORION'); $pdf->SetTitle('Output'); $pdf->setPrintHeader(false); $pdf->setPrintFooter(false); // set default monospaced font $pdf->SetDefaultMonospacedFont(PDF_FONT_MONOSPACED); // set margins $pdf->SetMargins($pdf_margin_lr, $pdf_margin_tb, -1, true); $pdf->SetHeaderMargin(PDF_MARGIN_HEADER); $pdf->SetFooterMargin(PDF_MARGIN_FOOTER); // set auto page breaks $pdf->SetAutoPageBreak(TRUE, PDF_MARGIN_BOTTOM); // set image scale factor $pdf->setImageScale(PDF_IMAGE_SCALE_RATIO); // set some language-dependent strings (optional) if (@file_exists(dirname(__FILE__) . '/lang/eng.php')) { require_once dirname(__FILE__) . '/lang/eng.php'; $pdf->setLanguageArray($l); } $pdf->AddPage(); //$pdf->Image($input_file, '', '', '', '', '', false, 'C', false, 300, 'C', false, false, 0, false, false, false); $layers_id = 0; foreach ($layers_array as $layer) { $pdf->startLayer('layer' . $layers_id, true, true, false); $pdf->Image($layer, '', '', '', '', '', '', 'C', true, 300, 'C', false, false, 0, '', false, false); $pdf->endLayer(); $layers_id++; } // $defaultImageSize = getimagesize($img_output_file_path); // $pageWidth = $pdf->getPageWidth(); // $pagHeight = $pdf->getPageHeight(); // // $nblign = $total / $nbCol; // $marge = 10; // // //Set width and height // $w = ($pageWidth - $marge * ($nbCol + 1)) / $nbCol; // $h = ($defaultImageSize[1] * $w) / $defaultImageSize[0]; // if ($h * ($nblign + 1) + 20 > $pagHeight) { // $h = ($pagHeight - 2 * ($nblign + 1) - 20) / ($nblign + 1); // $w = ($defaultImageSize[0] * $h) / $defaultImageSize[1]; // $marge = ($pageWidth - ($w * $nbCol)) / ($nbCol + 1); // } // // //Print images // $x = $marge; // $y = 20; // $i = 0; // $layers_id = 0; // while ($i < $total) { // for ($i2 = 0; $i2 < $nbCol; $i2++) { // if ($i < $total) { // foreach ($layers_array as $layer) { // $pdf->startLayer('layer' . $layers_id, true, true, false); // $pdf->Image($layer, $x, $y, $w, $h, '', '', '', true, 300, '', false, false, 0, '', false, false); // $pdf->endLayer(); // $layers_id ++; // } // // $x += ($w + $marge); // $i ++; // } // } // $x = $marge; // $y += $h; // } $pdf->Output($output_file, 'F'); }