mirror of
https://github.com/iib0011/omni-tools.git
synced 2025-11-11 02:29:54 +05:30
refactor: compress pdf
This commit is contained in:
parent
958e47bf18
commit
37be76254a
3 changed files with 71 additions and 83 deletions
143
.idea/workspace.xml
generated
143
.idea/workspace.xml
generated
|
|
@ -4,17 +4,10 @@
|
||||||
<option name="autoReloadType" value="SELECTIVE" />
|
<option name="autoReloadType" value="SELECTIVE" />
|
||||||
</component>
|
</component>
|
||||||
<component name="ChangeListManager">
|
<component name="ChangeListManager">
|
||||||
<list default="true" id="b30e2810-c4c1-4aad-b134-794e52cc1c7d" name="Changes" comment="fix: stars button width for 1k+ 😊">
|
<list default="true" id="b30e2810-c4c1-4aad-b134-794e52cc1c7d" name="Changes" comment="feat: compress pdf">
|
||||||
<change afterPath="$PROJECT_DIR$/src/pages/tools/pdf/compress-pdf/index.tsx" afterDir="false" />
|
|
||||||
<change afterPath="$PROJECT_DIR$/src/pages/tools/pdf/compress-pdf/meta.ts" afterDir="false" />
|
|
||||||
<change afterPath="$PROJECT_DIR$/src/pages/tools/pdf/compress-pdf/service.test.ts" afterDir="false" />
|
|
||||||
<change afterPath="$PROJECT_DIR$/src/pages/tools/pdf/compress-pdf/service.ts" afterDir="false" />
|
|
||||||
<change afterPath="$PROJECT_DIR$/src/pages/tools/pdf/compress-pdf/types.ts" afterDir="false" />
|
|
||||||
<change beforePath="$PROJECT_DIR$/.idea/workspace.xml" beforeDir="false" afterPath="$PROJECT_DIR$/.idea/workspace.xml" afterDir="false" />
|
<change beforePath="$PROJECT_DIR$/.idea/workspace.xml" beforeDir="false" afterPath="$PROJECT_DIR$/.idea/workspace.xml" afterDir="false" />
|
||||||
<change beforePath="$PROJECT_DIR$/package-lock.json" beforeDir="false" afterPath="$PROJECT_DIR$/package-lock.json" afterDir="false" />
|
<change beforePath="$PROJECT_DIR$/src/lib/worker-init.js" beforeDir="false" afterPath="$PROJECT_DIR$/src/lib/worker-init.js" afterDir="false" />
|
||||||
<change beforePath="$PROJECT_DIR$/package.json" beforeDir="false" afterPath="$PROJECT_DIR$/package.json" afterDir="false" />
|
<change beforePath="$PROJECT_DIR$/src/pages/tools/pdf/compress-pdf/service.ts" beforeDir="false" afterPath="$PROJECT_DIR$/src/pages/tools/pdf/compress-pdf/service.ts" afterDir="false" />
|
||||||
<change beforePath="$PROJECT_DIR$/src/pages/tools/pdf/index.ts" beforeDir="false" afterPath="$PROJECT_DIR$/src/pages/tools/pdf/index.ts" afterDir="false" />
|
|
||||||
<change beforePath="$PROJECT_DIR$/vite.config.ts" beforeDir="false" afterPath="$PROJECT_DIR$/vite.config.ts" afterDir="false" />
|
|
||||||
</list>
|
</list>
|
||||||
<option name="SHOW_DIALOG" value="false" />
|
<option name="SHOW_DIALOG" value="false" />
|
||||||
<option name="HIGHLIGHT_CONFLICTS" value="true" />
|
<option name="HIGHLIGHT_CONFLICTS" value="true" />
|
||||||
|
|
@ -50,94 +43,94 @@
|
||||||
"state": "OPEN"
|
"state": "OPEN"
|
||||||
}
|
}
|
||||||
}</component>
|
}</component>
|
||||||
<component name="GitHubPullRequestState"><![CDATA[{
|
<component name="GitHubPullRequestState">{
|
||||||
"prStates": [
|
"prStates": [
|
||||||
{
|
{
|
||||||
"id": {
|
"id": {
|
||||||
"id": "PR_kwDOMJIfts51PkS9",
|
"id": "PR_kwDOMJIfts51PkS9",
|
||||||
"number": 22
|
"number": 22
|
||||||
},
|
},
|
||||||
"lastSeen": 1741207144695
|
"lastSeen": 1741207144695
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"id": {
|
"id": {
|
||||||
"id": "PR_kwDOMJIfts6NiNYl",
|
"id": "PR_kwDOMJIfts6NiNYl",
|
||||||
"number": 32
|
"number": 32
|
||||||
},
|
},
|
||||||
"lastSeen": 1741209723869
|
"lastSeen": 1741209723869
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"id": {
|
"id": {
|
||||||
"id": "PR_kwDOMJIfts6Nheyd",
|
"id": "PR_kwDOMJIfts6Nheyd",
|
||||||
"number": 31
|
"number": 31
|
||||||
},
|
},
|
||||||
"lastSeen": 1741213371410
|
"lastSeen": 1741213371410
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"id": {
|
"id": {
|
||||||
"id": "PR_kwDOMJIfts6NmRBs",
|
"id": "PR_kwDOMJIfts6NmRBs",
|
||||||
"number": 33
|
"number": 33
|
||||||
},
|
},
|
||||||
"lastSeen": 1741282429036
|
"lastSeen": 1741282429036
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"id": {
|
"id": {
|
||||||
"id": "PR_kwDOMJIfts5zyFTs",
|
"id": "PR_kwDOMJIfts5zyFTs",
|
||||||
"number": 15
|
"number": 15
|
||||||
},
|
},
|
||||||
"lastSeen": 1741535540953
|
"lastSeen": 1741535540953
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"id": {
|
"id": {
|
||||||
"id": "PR_kwDOMJIfts6QQB3c",
|
"id": "PR_kwDOMJIfts6QQB3c",
|
||||||
"number": 59
|
"number": 59
|
||||||
},
|
},
|
||||||
"lastSeen": 1743018960900
|
"lastSeen": 1743018960900
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"id": {
|
"id": {
|
||||||
"id": "PR_kwDOMJIfts6QMPEg",
|
"id": "PR_kwDOMJIfts6QMPEg",
|
||||||
"number": 58
|
"number": 58
|
||||||
},
|
},
|
||||||
"lastSeen": 1743019452983
|
"lastSeen": 1743019452983
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"id": {
|
"id": {
|
||||||
"id": "PR_kwDOMJIfts6QZvRI",
|
"id": "PR_kwDOMJIfts6QZvRI",
|
||||||
"number": 61
|
"number": 61
|
||||||
},
|
},
|
||||||
"lastSeen": 1743103196866
|
"lastSeen": 1743103196866
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"id": {
|
"id": {
|
||||||
"id": "PR_kwDOMJIfts6QqPrQ",
|
"id": "PR_kwDOMJIfts6QqPrQ",
|
||||||
"number": 73
|
"number": 73
|
||||||
},
|
},
|
||||||
"lastSeen": 1743265865001
|
"lastSeen": 1743265865001
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"id": {
|
"id": {
|
||||||
"id": "PR_kwDOMJIfts6Qp5nI",
|
"id": "PR_kwDOMJIfts6Qp5nI",
|
||||||
"number": 72
|
"number": 72
|
||||||
},
|
},
|
||||||
"lastSeen": 1743338472110
|
"lastSeen": 1743338472110
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"id": {
|
"id": {
|
||||||
"id": "PR_kwDOMJIfts6QsjlS",
|
"id": "PR_kwDOMJIfts6QsjlS",
|
||||||
"number": 76
|
"number": 76
|
||||||
},
|
},
|
||||||
"lastSeen": 1743352150953
|
"lastSeen": 1743352150953
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"id": {
|
"id": {
|
||||||
"id": "PR_kwDOMJIfts6Q0JBe",
|
"id": "PR_kwDOMJIfts6Q0JBe",
|
||||||
"number": 82
|
"number": 82
|
||||||
},
|
},
|
||||||
"lastSeen": 1743470267269
|
"lastSeen": 1743470267269
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
}]]></component>
|
}</component>
|
||||||
<component name="GithubPullRequestsUISettings">{
|
<component name="GithubPullRequestsUISettings">{
|
||||||
"selectedUrlAndAccountId": {
|
"selectedUrlAndAccountId": {
|
||||||
"url": "https://github.com/iib0011/omni-tools.git",
|
"url": "https://github.com/iib0011/omni-tools.git",
|
||||||
|
|
@ -190,10 +183,10 @@
|
||||||
"Vitest.replaceText function (regexp mode).should return the original text when passed an invalid regexp.executor": "Run",
|
"Vitest.replaceText function (regexp mode).should return the original text when passed an invalid regexp.executor": "Run",
|
||||||
"Vitest.replaceText function.executor": "Run",
|
"Vitest.replaceText function.executor": "Run",
|
||||||
"Vitest.timeBetweenDates.executor": "Run",
|
"Vitest.timeBetweenDates.executor": "Run",
|
||||||
"git-widget-placeholder": "main",
|
"git-widget-placeholder": "compression",
|
||||||
"ignore.virus.scanning.warn.message": "true",
|
"ignore.virus.scanning.warn.message": "true",
|
||||||
"kotlin-language-version-configured": "true",
|
"kotlin-language-version-configured": "true",
|
||||||
"last_opened_file_path": "C:/Users/Ibrahima/IdeaProjects/omni-tools/@types",
|
"last_opened_file_path": "C:/Users/Ibrahima/IdeaProjects/omni-tools/src",
|
||||||
"node.js.detected.package.eslint": "true",
|
"node.js.detected.package.eslint": "true",
|
||||||
"node.js.detected.package.tslint": "true",
|
"node.js.detected.package.tslint": "true",
|
||||||
"node.js.selected.package.eslint": "(autodetect)",
|
"node.js.selected.package.eslint": "(autodetect)",
|
||||||
|
|
@ -227,11 +220,11 @@
|
||||||
</component>
|
</component>
|
||||||
<component name="RecentsManager">
|
<component name="RecentsManager">
|
||||||
<key name="CopyFile.RECENT_KEYS">
|
<key name="CopyFile.RECENT_KEYS">
|
||||||
|
<recent name="C:\Users\Ibrahima\IdeaProjects\omni-tools\src" />
|
||||||
<recent name="C:\Users\Ibrahima\IdeaProjects\omni-tools\@types" />
|
<recent name="C:\Users\Ibrahima\IdeaProjects\omni-tools\@types" />
|
||||||
<recent name="C:\Users\Ibrahima\IdeaProjects\omni-tools\public\assets" />
|
<recent name="C:\Users\Ibrahima\IdeaProjects\omni-tools\public\assets" />
|
||||||
<recent name="C:\Users\Ibrahima\IdeaProjects\omni-tools\src\components\input" />
|
<recent name="C:\Users\Ibrahima\IdeaProjects\omni-tools\src\components\input" />
|
||||||
<recent name="C:\Users\Ibrahima\IdeaProjects\omni-tools\.husky" />
|
<recent name="C:\Users\Ibrahima\IdeaProjects\omni-tools\.husky" />
|
||||||
<recent name="C:\Users\Ibrahima\IdeaProjects\omni-tools\src\assets" />
|
|
||||||
</key>
|
</key>
|
||||||
<key name="MoveFile.RECENT_KEYS">
|
<key name="MoveFile.RECENT_KEYS">
|
||||||
<recent name="C:\Users\Ibrahima\IdeaProjects\omni-tools\@types" />
|
<recent name="C:\Users\Ibrahima\IdeaProjects\omni-tools\@types" />
|
||||||
|
|
@ -415,14 +408,6 @@
|
||||||
<workItem from="1743397561176" duration="25000" />
|
<workItem from="1743397561176" duration="25000" />
|
||||||
<workItem from="1743458576265" duration="13083000" />
|
<workItem from="1743458576265" duration="13083000" />
|
||||||
</task>
|
</task>
|
||||||
<task id="LOCAL-00133" summary="chore: remove prettify test">
|
|
||||||
<option name="closed" value="true" />
|
|
||||||
<created>1740662016902</created>
|
|
||||||
<option name="number" value="00133" />
|
|
||||||
<option name="presentableId" value="LOCAL-00133" />
|
|
||||||
<option name="project" value="LOCAL" />
|
|
||||||
<updated>1740662016902</updated>
|
|
||||||
</task>
|
|
||||||
<task id="LOCAL-00134" summary="chore: prettify json in home">
|
<task id="LOCAL-00134" summary="chore: prettify json in home">
|
||||||
<option name="closed" value="true" />
|
<option name="closed" value="true" />
|
||||||
<created>1740662154978</created>
|
<created>1740662154978</created>
|
||||||
|
|
@ -807,7 +792,15 @@
|
||||||
<option name="project" value="LOCAL" />
|
<option name="project" value="LOCAL" />
|
||||||
<updated>1743470832619</updated>
|
<updated>1743470832619</updated>
|
||||||
</task>
|
</task>
|
||||||
<option name="localTasksCounter" value="182" />
|
<task id="LOCAL-00182" summary="feat: compress pdf">
|
||||||
|
<option name="closed" value="true" />
|
||||||
|
<created>1743644598841</created>
|
||||||
|
<option name="number" value="00182" />
|
||||||
|
<option name="presentableId" value="LOCAL-00182" />
|
||||||
|
<option name="project" value="LOCAL" />
|
||||||
|
<updated>1743644598841</updated>
|
||||||
|
</task>
|
||||||
|
<option name="localTasksCounter" value="183" />
|
||||||
<servers />
|
<servers />
|
||||||
</component>
|
</component>
|
||||||
<component name="TypeScriptGeneratedFilesManager">
|
<component name="TypeScriptGeneratedFilesManager">
|
||||||
|
|
@ -854,7 +847,6 @@
|
||||||
<option name="CHECK_CODE_SMELLS_BEFORE_PROJECT_COMMIT" value="false" />
|
<option name="CHECK_CODE_SMELLS_BEFORE_PROJECT_COMMIT" value="false" />
|
||||||
<option name="CHECK_NEW_TODO" value="false" />
|
<option name="CHECK_NEW_TODO" value="false" />
|
||||||
<option name="ADD_EXTERNAL_FILES_SILENTLY" value="true" />
|
<option name="ADD_EXTERNAL_FILES_SILENTLY" value="true" />
|
||||||
<MESSAGE value="feat: missing tools" />
|
|
||||||
<MESSAGE value="refactor: use ToolContent" />
|
<MESSAGE value="refactor: use ToolContent" />
|
||||||
<MESSAGE value="fix: prettify json" />
|
<MESSAGE value="fix: prettify json" />
|
||||||
<MESSAGE value="refactor: sum" />
|
<MESSAGE value="refactor: sum" />
|
||||||
|
|
@ -879,7 +871,8 @@
|
||||||
<MESSAGE value="docs: github trendings" />
|
<MESSAGE value="docs: github trendings" />
|
||||||
<MESSAGE value="docs: optimize" />
|
<MESSAGE value="docs: optimize" />
|
||||||
<MESSAGE value="fix: stars button width for 1k+ " />
|
<MESSAGE value="fix: stars button width for 1k+ " />
|
||||||
<option name="LAST_COMMIT_MESSAGE" value="fix: stars button width for 1k+ " />
|
<MESSAGE value="feat: compress pdf" />
|
||||||
|
<option name="LAST_COMMIT_MESSAGE" value="feat: compress pdf" />
|
||||||
</component>
|
</component>
|
||||||
<component name="XSLT-Support.FileAssociations.UIState">
|
<component name="XSLT-Support.FileAssociations.UIState">
|
||||||
<expand />
|
<expand />
|
||||||
|
|
|
||||||
|
|
@ -1,9 +1,4 @@
|
||||||
export async function _GSPS2PDF(
|
export async function compressWithGhostScript(dataStruct) {
|
||||||
dataStruct,
|
|
||||||
responseCallback,
|
|
||||||
progressCallback,
|
|
||||||
statusUpdateCallback
|
|
||||||
) {
|
|
||||||
const worker = new Worker(
|
const worker = new Worker(
|
||||||
new URL('./background-worker.js', import.meta.url),
|
new URL('./background-worker.js', import.meta.url),
|
||||||
{ type: 'module' }
|
{ type: 'module' }
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,5 @@
|
||||||
import { InitialValuesType } from './types';
|
import { InitialValuesType } from './types';
|
||||||
import { _GSPS2PDF } from '../../../../lib/worker-init';
|
import { compressWithGhostScript } from '../../../../lib/worker-init';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Compresses a PDF file using either Ghostscript WASM (preferred)
|
* Compresses a PDF file using either Ghostscript WASM (preferred)
|
||||||
|
|
@ -19,7 +19,7 @@ export async function compressPdf(
|
||||||
}
|
}
|
||||||
|
|
||||||
const dataObject = { psDataURL: URL.createObjectURL(pdfFile) };
|
const dataObject = { psDataURL: URL.createObjectURL(pdfFile) };
|
||||||
const compressedFileUrl: string = await _GSPS2PDF(dataObject);
|
const compressedFileUrl: string = await compressWithGhostScript(dataObject);
|
||||||
return await loadPDFData(compressedFileUrl, pdfFile.name);
|
return await loadPDFData(compressedFileUrl, pdfFile.name);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue