13 class Packaging extends \Magento\Sales\Model\Order\Pdf\AbstractPdf
57 \
Magento\Payment\Helper\Data $paymentData,
63 \
Magento\Sales\Model\Order\Pdf\ItemsFactory $pdfItemsFactory,
64 \
Magento\Framework\Stdlib\DateTime\TimezoneInterface $localeDate,
69 \
Magento\Framework\View\LayoutInterface $layout,
70 \
Magento\Framework\Locale\ResolverInterface $localeResolver,
73 $this->_carrierHelper = $carrierHelper;
75 $this->_layout = $layout;
76 $this->_localeResolver = $localeResolver;
104 $pdf = new \Zend_Pdf();
109 $this->_localeResolver->emulate(
$shipment->getStoreId());
110 $this->_storeManager->setCurrentStore(
$shipment->getStoreId());
122 $this->_localeResolver->revert();
137 $page->setLineWidth(0.5);
138 $page->drawRectangle(25, 790, 570, 755);
140 $page->drawText(
__(
'Packages'), 35, 770,
'UTF-8');
158 if ($this->getPackageShippingBlock()) {
159 $packaging = $this->getPackageShippingBlock();
161 $packaging = $this->_layout->getBlockSingleton(\
Magento\
Shipping\Block\Adminhtml\Order\Packaging::class);
163 $packages = $packaging->getPackages();
166 foreach ($packages as $package) {
168 $page->drawRectangle(25, $this->y + 15, 190, $this->y - 35);
169 $page->drawRectangle(190, $this->y + 15, 350, $this->y - 35);
170 $page->drawRectangle(350, $this->y + 15, 570, $this->y - 35);
173 $page->drawRectangle(520, $this->y + 15, 570, $this->y - 5);
176 $packageText =
__(
'Package') .
' ' . $packageNum;
177 $page->drawText($packageText, 525, $this->y,
'UTF-8');
180 $package = new \Magento\Framework\DataObject($package);
181 $params = new \Magento\Framework\DataObject($package->getParams());
182 $dimensionUnits = $this->_carrierHelper->getMeasureDimensionName(
$params->getDimensionUnits());
184 $typeText =
__(
'Type') .
' : ' . $packaging->getContainerTypeByCode(
$params->getContainer());
185 $page->drawText($typeText, 35, $this->y,
'UTF-8');
187 if (
$params->getLength() !=
null) {
188 $lengthText =
$params->getLength() .
' ' . $dimensionUnits;
192 $lengthText =
__(
'Length') .
' : ' . $lengthText;
193 $page->drawText($lengthText, 200, $this->y,
'UTF-8');
195 if (
$params->getDeliveryConfirmation() !=
null) {
196 $confirmationText =
__(
197 'Signature Confirmation' 198 ) .
' : ' . $packaging->getDeliveryConfirmationTypeByCode(
199 $params->getDeliveryConfirmation()
201 $page->drawText($confirmationText, 355, $this->y,
'UTF-8');
204 $this->y = $this->y - 10;
206 if ($packaging->displayCustomsValue() !=
null) {
207 $customsValueText =
__(
'Customs Value') .
' : ' . $packaging->displayPrice(
$params->getCustomsValue());
208 $page->drawText($customsValueText, 35, $this->y,
'UTF-8');
210 if (
$params->getWidth() !=
null) {
211 $widthText =
$params->getWidth() .
' ' . $dimensionUnits;
215 $widthText =
__(
'Width') .
' : ' . $widthText;
216 $page->drawText($widthText, 200, $this->y,
'UTF-8');
218 if (
$params->getContentType() !=
null) {
219 if (
$params->getContentType() ==
'OTHER') {
220 $contentsValue =
$params->getContentTypeOther();
222 $contentsValue = $packaging->getContentTypeByCode(
$params->getContentType());
224 $contentsText =
__(
'Contents') .
' : ' . $contentsValue;
225 $page->drawText($contentsText, 355, $this->y,
'UTF-8');
228 $this->y = $this->y - 10;
232 ) .
' : ' .
$params->getWeight() .
' ' . $this->_carrierHelper->getMeasureWeightName(
235 $page->drawText($weightText, 35, $this->y,
'UTF-8');
237 if (
$params->getHeight() !=
null) {
238 $heightText =
$params->getHeight() .
' ' . $dimensionUnits;
242 $heightText =
__(
'Height') .
' : ' . $heightText;
243 $page->drawText($heightText, 200, $this->y,
'UTF-8');
245 $this->y = $this->y - 10;
248 $sizeText =
__(
'Size') .
' : ' . ucfirst(strtolower(
$params->getSize()));
249 $page->drawText($sizeText, 35, $this->y,
'UTF-8');
251 if (
$params->getGirth() !=
null) {
252 $dimensionGirthUnits = $this->_carrierHelper->getMeasureDimensionName(
253 $params->getGirthDimensionUnits()
255 $girthText =
__(
'Girth') .
' : ' .
$params->getGirth() .
' ' . $dimensionGirthUnits;
256 $page->drawText($girthText, 200, $this->y,
'UTF-8');
259 $this->y = $this->y - 5;
261 $page->drawRectangle(25, $this->y, 570, $this->y - 30 - count($package->getItems()) * 12);
263 $this->y = $this->y - 10;
265 $page->drawText(
__(
'Items in the Package'), 30, $this->y,
'UTF-8');
268 $itemCollsNumber = $packaging->displayCustomsValue() ? 5 : 4;
271 $itemCollsX[1] = 250;
273 $itemCollsXEnd = 565;
274 $itemCollsXStep = round(($itemCollsXEnd - $itemCollsX[1]) / ($itemCollsNumber - 1));
276 for (
$i = 2;
$i <= $itemCollsNumber;
$i++) {
277 $itemCollsX[
$i] = $itemCollsX[
$i - 1] + $itemCollsXStep;
282 $page->drawRectangle($itemCollsX[
$i], $this->y - 5, $itemCollsX[++
$i], $this->y - 15);
283 $page->drawRectangle($itemCollsX[
$i], $this->y - 5, $itemCollsX[++
$i], $this->y - 15);
284 $page->drawRectangle($itemCollsX[
$i], $this->y - 5, $itemCollsX[++
$i], $this->y - 15);
285 $page->drawRectangle($itemCollsX[
$i], $this->y - 5, $itemCollsX[++
$i], $this->y - 15);
286 $page->drawRectangle($itemCollsX[
$i], $this->y - 5, $itemCollsXEnd, $this->y - 15);
288 $this->y = $this->y - 12;
292 $page->drawText(
__(
'Product'), $itemCollsX[
$i] + $txtIndent, $this->y,
'UTF-8');
293 $page->drawText(
__(
'Weight'), $itemCollsX[++
$i] + $txtIndent, $this->y,
'UTF-8');
294 if ($packaging->displayCustomsValue()) {
295 $page->drawText(
__(
'Customs Value'), $itemCollsX[++
$i] + $txtIndent, $this->y,
'UTF-8');
297 $page->drawText(
__(
'Qty Ordered'), $itemCollsX[++
$i] + $txtIndent, $this->y,
'UTF-8');
298 $page->drawText(
__(
'Qty'), $itemCollsX[++
$i] + $txtIndent, $this->y,
'UTF-8');
301 foreach ($package->getItems() as $itemId =>
$item) {
302 $item = new \Magento\Framework\DataObject(
$item);
306 $page->drawRectangle($itemCollsX[
$i], $this->y - 3, $itemCollsX[++
$i], $this->y - 15);
307 $page->drawRectangle($itemCollsX[
$i], $this->y - 3, $itemCollsX[++
$i], $this->y - 15);
308 $page->drawRectangle($itemCollsX[
$i], $this->y - 3, $itemCollsX[++
$i], $this->y - 15);
309 $page->drawRectangle($itemCollsX[
$i], $this->y - 3, $itemCollsX[++
$i], $this->y - 15);
310 $page->drawRectangle($itemCollsX[
$i], $this->y - 3, $itemCollsXEnd, $this->y - 15);
312 $this->y = $this->y - 12;
317 if ($packaging->displayCustomsValue()) {
319 $packaging->displayPrice(
$item->getCustomsValue()),
320 $itemCollsX[++
$i] + $txtIndent,
326 $packaging->getQtyOrderedItem(
$item->getOrderItemId()),
327 $itemCollsX[++
$i] + $txtIndent,
333 $this->y = $this->y - 30;
_drawHeaderBlock(\Zend_Pdf_Page $page)
newPage(array $settings=[])
$params[\Magento\Store\Model\StoreManager::PARAM_RUN_CODE]
__construct(\Magento\Payment\Helper\Data $paymentData, \Magento\Framework\Stdlib\StringUtils $string, \Magento\Framework\App\Config\ScopeConfigInterface $scopeConfig, \Magento\Framework\Filesystem $filesystem, \Magento\Sales\Model\Order\Pdf\Config $pdfConfig, \Magento\Sales\Model\Order\Pdf\Total\Factory $pdfTotalFactory, \Magento\Sales\Model\Order\Pdf\ItemsFactory $pdfItemsFactory, \Magento\Framework\Stdlib\DateTime\TimezoneInterface $localeDate, \Magento\Framework\Translate\Inline\StateInterface $inlineTranslation, \Magento\Sales\Model\Order\Address\Renderer $addressRenderer, Carrier $carrierHelper, \Magento\Store\Model\StoreManagerInterface $storeManager, \Magento\Framework\View\LayoutInterface $layout, \Magento\Framework\Locale\ResolverInterface $localeResolver, array $data=[])
_setFontRegular($object, $size=7)
foreach($order->getItems() as $orderItem) $shipment
_drawPackageBlock(\Zend_Pdf_Page $page)