humanemulator.net — справка.
Продукт, демо и покупка — на
хуманэмулятор.рф
|
Демо
|
Купить
|
API
|
лог изменений
compress_images
compress_images($inpath,$outpath,$quality=20); - сжать вложенные в pdf файл картинки (Доступна с версии 7.0.57)Функция на вход принимает параметры:
После отработки функция возвращает результат своей работы в скрипт :
Пример использования
<?php // Scenario: Compress images in a PDF file to reduce file size $xhe_host = "localhost:7010"; // Connect functional objects if not already connected if (!isset($path)){ $path = "../../../Templates/init.php"; require($path); } // info echo "\n<span >pdffile->" . basename (__FILE__) . "</span>\n"; // Example 1: Compress images in PDF file // Input data $inputFilePath = "test/test.pdf"; $outputFilePath = "test/compressed.pdf"; $quality = 20; // Compression quality (0-100) echo("\n\nExample 1. Compress images in PDF: "); $compressResult = SYSTEM::$pdffile->compress_images($inputFilePath, $outputFilePath, $quality); if ($compressResult) { echo("true: "); } else { echo("false: "); } // Get file sizes to show difference $originalSize = SYSTEM::$file_os->get_size($inputFilePath); $compressedSize = SYSTEM::$file_os->get_size($outputFilePath); $difference = $originalSize - $compressedSize; echo($difference . " bytes difference\n"); // Quit the application WINDOW::$app->quit(); ?>
# Additional paths import sys sys.path.insert(0, '../../../Templates PY/') xhe_host = "127.0.0.1:7025" from xweb_human_emulator import * # начало echo("<hr><font color=blue>sound.xxxxxxxxx</font><hr>") # 1 echo("\n1. Сожмем картинки в pdf : "); echo(pdffile.compress_images("test\\test.pdf","test\\compressed.pdf",20),": "); echo(file_os.get_size("test\\test.pdf")-file_os.get_size("test\\compressed.pdf")," байт разница"); # Quit app.quit()
#region using using System; using System.Diagnostics; using System.Collections.Generic; using System.Linq; using System.IO; using System.Text; using System.Threading; using XHE; using XHE.XHE_DOM; using XHE.XHE_System; using XHE.XHE_Window; using XHE.XHE_Web; #endregion class Program:XHEScript { static void Main(string[] args) { // init XHE server = "localhost:7010"; InitXHE(); // начало echo("<hr><font color=blue>pdffile.write</font><hr>"); // 1 echo("\n1. Сожмем картинки в pdf : "); echo(pdffile.compress_images("test\\test.pdf","test\\compressed.pdf",20)+": "); echo(file_os.get_size("test\\test.pdf")-file_os.get_size("test\\compressed.pdf")+" байт разница"); // конец echo("\n\n"); app.quit(); } }
// подключим функциональные объекты, если еще не подключен xhe_host="127.0.0.1:7025"; echo=require("../../../Templates JS/init.js"); // начало echo("<hr><font color=blue>sound.beep</font><hr>"); // 1 echo("\n1. Сожмем картинки в pdf : "); echo(pdffile.compress_images("test\\test.pdf","test\\compressed.pdf",20)+": "); echo(file_os.get_size("test\\test.pdf")-file_os.get_size("test\\compressed.pdf")+" байт разница"); // конец echo("\n"); // Quit app.quit();
=============================================
pdffile Объекты DOM System Vision Web Window
=============================================
если что-то непонятно или необходимо узнать или считаете что надо добавить по работе этой функции, пишите в комментарии или на наш форум
.