From 5fff3f35af09295bf7fb42486929f7c3b6b52945 Mon Sep 17 00:00:00 2001 From: Artem Vasilev Date: Mon, 25 Nov 2024 20:26:03 +0300 Subject: [PATCH 1/3] =?UTF-8?q?=D0=98=D0=B7=D0=BC=D0=B5=D0=BD=D0=B8=D0=BB?= =?UTF-8?q?=20=D0=B8=D0=BC=D1=8F=20=D0=BF=D0=B0=D0=BA=D0=B5=D1=82=D0=B0=20?= =?UTF-8?q?=D0=B2=20=D1=81=D0=B1=D0=BE=D1=80=D0=BA=D0=B5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .github/workflows/build.yml | 8 ++++---- README.md | 21 ++++++++++----------- 2 files changed, 14 insertions(+), 15 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 4888b6f..22052bd 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -53,7 +53,7 @@ jobs: - name: Build release archive with fonts run: | export TERM=xterm - zip -r pkg_rzs_with_fonts.zip libraries src config.php jmpdf.xml + zip -r lib_jmpdf_with_fonts.zip libraries src config.php jmpdf.xml - name: Removes all unnecessary fonts run: composer clear-fonts @@ -61,13 +61,13 @@ jobs: - name: Build release archive without fonts run: | export TERM=xterm - zip -r pkg_rzs.zip libraries src config.php jmpdf.xml + zip -r lib_jmpdf.zip libraries src config.php jmpdf.xml - name: Draft release uses: softprops/action-gh-release@v2 with: files: | - pkg_rzs.zip - pkg_rzs_with_fonts.zip + lib_jmpdf.zip + lib_jmpdf_with_fonts.zip tag_name: "build.${{ steps.build_info.outputs.TIMESTAMP }}" name: "${{ steps.build_info.outputs.VERSION }}-build.${{ steps.build_info.outputs.TIMESTAMP }}" \ No newline at end of file diff --git a/README.md b/README.md index 2c414e1..50db8f3 100644 --- a/README.md +++ b/README.md @@ -13,8 +13,8 @@ Mpdf for Joomla! ## Сборки В релизе содержится 2 сборки (2 архива): -- `pkg_rzs.zip` - облегчённая сборки библиотеки, из которой удалены все дополнительные шрифты, кроме `DejaVuSans`; -- `pkg_rzs_with_fonts.zip` - полная сборка, которая содержит абсолютно все шрифты из оригинальной библиотеки `mpdf/mpdf`. +- `lib_jmpdf.zip` - облегчённая сборки библиотеки, из которой удалены все дополнительные шрифты, кроме `DejaVuSans`; +- `lib_jmpdf_with_fonts.zip` - полная сборка, которая содержит абсолютно все шрифты из оригинальной библиотеки `mpdf/mpdf`. ## Изменения Прочитать изменения вы можете в файле [changelog.md](https://github.com/Delo-Design/jmpdf/blob/master/changelog.md) @@ -26,14 +26,14 @@ Mpdf for Joomla! 1) html - html для записи в pdf 2) $config - параметры для mpdf, список параметров: - - mode - - format - - margin_left - - margin_right - - margin_top - - margin_bottom - - margin_header - - margin_footer + - mode + - format + - margin_left + - margin_right + - margin_top + - margin_bottom + - margin_header + - margin_footer - tempDir - author - creator @@ -42,7 +42,6 @@ Mpdf for Joomla! - display_mode - instanceConfigurator - ## Самостоятельная сборка из исходных кодов В git репозитории отсутствуют дополнительные библиотеки, требующиеся для работы пакета. Они устанавливаются, при помощи менеджера пакетов `composer`. From be8bf33f35c0fd38261f5282243d91537b7fe6aa Mon Sep 17 00:00:00 2001 From: Artem Vasilev Date: Mon, 25 Nov 2024 20:50:07 +0300 Subject: [PATCH 2/3] coedstyle --- src/JMpdf.php | 26 ++++++-------------------- 1 file changed, 6 insertions(+), 20 deletions(-) diff --git a/src/JMpdf.php b/src/JMpdf.php index a1d20ed..27dc8fc 100644 --- a/src/JMpdf.php +++ b/src/JMpdf.php @@ -1,16 +1,16 @@ getInstance($uconfig); } - /** * Создание/Пересоздание объекта mpdf с сохранением прежных настроек * @@ -97,11 +95,9 @@ protected function getInstance($uconfig = []) $this->mpdf->WriteHTML($this->config->get('html', '')); } - - /* + /** * Магический метод, который позволяет напрямую обращаться к mpdf - * - */ + **/ public function __call($name, $arguments) { if (method_exists($this->mpdf, $name)) { @@ -109,7 +105,6 @@ public function __call($name, $arguments) } } - /** * Получение конфигурации mpdf * @@ -123,7 +118,6 @@ protected function getConfig($key, $default = '') return $this->config->get($key, $default); } - /** * Установка новой конфигурации и пересоздается mpdf * @@ -140,7 +134,6 @@ protected function setConfig($key, $value) return true; } - /** * Уставливает пароль на pdf * @@ -159,7 +152,6 @@ public function setProtection($permisson, $userPassword = '', $ownerPassword = ' return $this->mpdf->SetProtection($permisson, $userPassword, $ownerPassword); } - /** * Вовзращает сгенерированный pdf документ в виде строки * @@ -170,7 +162,6 @@ public function output() return $this->mpdf->Output('', 'S'); } - /** * Сохранение в указанный файл * @@ -183,7 +174,6 @@ public function save($filename) return $this->mpdf->Output($filename, 'F'); } - /** * * Проставление заголовков http на скачку pdf @@ -198,7 +188,6 @@ public function download($filename = 'document.pdf') return $this->mpdf->Output($filename, 'D'); } - /** * Проставление заголовков http на вывод в браузер * @@ -211,7 +200,6 @@ public function stream($filename = 'document.pdf') return $this->mpdf->Output($filename, 'I'); } - /** * Добавление новых шрифтов * @@ -240,6 +228,4 @@ public function addFonts($font_path, $fonts) return true; } - - -} \ No newline at end of file +} From 1cbb6c8f2e764225b2f6464528cbb8d06614e89a Mon Sep 17 00:00:00 2001 From: Artem Vasilev Date: Mon, 25 Nov 2024 21:21:36 +0300 Subject: [PATCH 3/3] =?UTF-8?q?=D0=9F=D0=BE=D0=B4=D0=BF=D1=80=D0=B0=D0=B2?= =?UTF-8?q?=D0=B8=D0=BB=20examples?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- examples/basic.php | 9 +++++---- examples/fonts.php | 11 +++++------ examples/layout.php | 1 - 3 files changed, 10 insertions(+), 11 deletions(-) delete mode 100644 examples/layout.php diff --git a/examples/basic.php b/examples/basic.php index 7a96bb8..2e7f21e 100644 --- a/examples/basic.php +++ b/examples/basic.php @@ -1,9 +1,10 @@ Мой текст какой-то' . $filename = 'example.pdf'; -JLoader::register('JMpdf', JPATH_LIBRARIES . '/mpdf/jmpdf.php'); -$pdf = new JMpdf($html); -$pdf->download($filename); \ No newline at end of file + +$pdf = new \Joomla\Libraries\JMpdf\JMpdf($html); +$pdf->stream(dirname(__FILE__) . '/' . $filename); \ No newline at end of file diff --git a/examples/fonts.php b/examples/fonts.php index 6d8ace5..9730289 100644 --- a/examples/fonts.php +++ b/examples/fonts.php @@ -6,15 +6,15 @@ * Полное описание можете получить на официальной документации mpdf: https://mpdf.github.io/fonts-languages/fonts-in-mpdf-7-x.html */ +// Подключение неймспейса библиотеки +JLoader::registerNamespace('\\Joomla\\Libraries\\JMpdf', JPATH_LIBRARIES . '/mpdf/src'); $html = 'Мой текст какой-то с шрифтом alaruss ' . 'Мой текст какой-то с шрифтом other'; - $filename = 'example.pdf'; -// регистрируем класс JMpdf -JLoader::register('JMpdf', JPATH_LIBRARIES . '/mpdf/jmpdf.php'); -$pdf = new JMpdf($html); +// Byb +$pdf = new \Joomla\Libraries\JMpdf\JMpdf($html); $pdf->addFonts( JPATH_THEMES . '/mytemplate/fonts', //путь до шрифтов. Допустимо передать массив путей @@ -36,5 +36,4 @@ ] ); - -$pdf->stream($filename); \ No newline at end of file +$pdf->stream(dirname(__FILE__) . '/' . $filename); \ No newline at end of file diff --git a/examples/layout.php b/examples/layout.php deleted file mode 100644 index b3d9bbc..0000000 --- a/examples/layout.php +++ /dev/null @@ -1 +0,0 @@ -