fix: use qpdf-wasm-esm-embedded + add logs
This commit is contained in:
		
							parent
							
								
									48dd7bb695
								
							
						
					
					
						commit
						c35e7102d5
					
				
							
								
								
									
										10
									
								
								components.d.ts
									
									
									
									
										vendored
									
									
								
							
							
						
						
									
										10
									
								
								components.d.ts
									
									
									
									
										vendored
									
									
								
							| @ -127,27 +127,25 @@ declare module '@vue/runtime-core' { | ||||
|     MetaTagGenerator: typeof import('./src/tools/meta-tag-generator/meta-tag-generator.vue')['default'] | ||||
|     MimeTypes: typeof import('./src/tools/mime-types/mime-types.vue')['default'] | ||||
|     NavbarButtons: typeof import('./src/components/NavbarButtons.vue')['default'] | ||||
|     NCode: typeof import('naive-ui')['NCode'] | ||||
|     NCheckbox: typeof import('naive-ui')['NCheckbox'] | ||||
|     NCollapseTransition: typeof import('naive-ui')['NCollapseTransition'] | ||||
|     NConfigProvider: typeof import('naive-ui')['NConfigProvider'] | ||||
|     NDivider: typeof import('naive-ui')['NDivider'] | ||||
|     NEllipsis: typeof import('naive-ui')['NEllipsis'] | ||||
|     NFormItem: typeof import('naive-ui')['NFormItem'] | ||||
|     NGi: typeof import('naive-ui')['NGi'] | ||||
|     NGrid: typeof import('naive-ui')['NGrid'] | ||||
|     NH1: typeof import('naive-ui')['NH1'] | ||||
|     NH3: typeof import('naive-ui')['NH3'] | ||||
|     NIcon: typeof import('naive-ui')['NIcon'] | ||||
|     NInputNumber: typeof import('naive-ui')['NInputNumber'] | ||||
|     NLabel: typeof import('naive-ui')['NLabel'] | ||||
|     NInput: typeof import('naive-ui')['NInput'] | ||||
|     NLayout: typeof import('naive-ui')['NLayout'] | ||||
|     NLayoutSider: typeof import('naive-ui')['NLayoutSider'] | ||||
|     NMenu: typeof import('naive-ui')['NMenu'] | ||||
|     NScrollbar: typeof import('naive-ui')['NScrollbar'] | ||||
|     NSpace: typeof import('naive-ui')['NSpace'] | ||||
|     NSpin: typeof import('naive-ui')['NSpin'] | ||||
|     NumeronymGenerator: typeof import('./src/tools/numeronym-generator/numeronym-generator.vue')['default'] | ||||
|     OtpCodeGeneratorAndValidator: typeof import('./src/tools/otp-code-generator-and-validator/otp-code-generator-and-validator.vue')['default'] | ||||
|     PasswordStrengthAnalyser: typeof import('./src/tools/password-strength-analyser/password-strength-analyser.vue')['default'] | ||||
|     PdfEncrypt: typeof import('./src/tools/pdf-encrypt/pdf-encrypt.vue')['default'] | ||||
|     PdfSignatureChecker: typeof import('./src/tools/pdf-signature-checker/pdf-signature-checker.vue')['default'] | ||||
|     PdfSignatureDetails: typeof import('./src/tools/pdf-signature-checker/components/pdf-signature-details.vue')['default'] | ||||
|     PercentageCalculator: typeof import('./src/tools/percentage-calculator/percentage-calculator.vue')['default'] | ||||
|  | ||||
| @ -81,6 +81,7 @@ | ||||
|     "pdf-signature-reader": "^1.4.2", | ||||
|     "pinia": "^2.0.34", | ||||
|     "plausible-tracker": "^0.3.8", | ||||
|     "qpdf-wasm-esm-embedded": "^1.1.1", | ||||
|     "qrcode": "^1.5.1", | ||||
|     "sql-formatter": "^13.0.0", | ||||
|     "ua-parser-js": "^1.0.35", | ||||
|  | ||||
							
								
								
									
										10
									
								
								pnpm-lock.yaml
									
									
									
										generated
									
									
									
								
							
							
						
						
									
										10
									
								
								pnpm-lock.yaml
									
									
									
										generated
									
									
									
								
							| @ -143,6 +143,9 @@ dependencies: | ||||
|   plausible-tracker: | ||||
|     specifier: ^0.3.8 | ||||
|     version: 0.3.8 | ||||
|   qpdf-wasm-esm-embedded: | ||||
|     specifier: ^1.1.1 | ||||
|     version: 1.1.1 | ||||
|   qrcode: | ||||
|     specifier: ^1.5.1 | ||||
|     version: 1.5.1 | ||||
| @ -7687,6 +7690,12 @@ packages: | ||||
|     engines: {node: '>=6'} | ||||
|     dev: true | ||||
| 
 | ||||
|   /qpdf-wasm-esm-embedded@1.1.1: | ||||
|     resolution: {integrity: sha512-e6Pb8jRw+VflZQvsS+eOfYF9BqjubvTBnxJc44LhI1btg2WYNKE5/lGMmzWZ2gd9YrdWByf8IdNZw6S7+7t27w==} | ||||
|     dependencies: | ||||
|       '@types/emscripten': 1.39.10 | ||||
|     dev: false | ||||
| 
 | ||||
|   /qrcode@1.5.1: | ||||
|     resolution: {integrity: sha512-nS8NJ1Z3md8uTjKtP+SGGhfqmTCs5flU/xR623oI0JX+Wepz9R8UrRVCTBTJm3qGw3rH6jJ6MUHjkDx15cxSSg==} | ||||
|     engines: {node: '>=10.13.0'} | ||||
| @ -9456,6 +9465,7 @@ packages: | ||||
| 
 | ||||
|   /workbox-google-analytics@7.0.0: | ||||
|     resolution: {integrity: sha512-MEYM1JTn/qiC3DbpvP2BVhyIH+dV/5BjHk756u9VbwuAhu0QHyKscTnisQuz21lfRpOwiS9z4XdqeVAKol0bzg==} | ||||
|     deprecated: It is not compatible with newer versions of GA starting with v4, as long as you are using GAv3 it should be ok, but the package is not longer being maintained | ||||
|     dependencies: | ||||
|       workbox-background-sync: 7.0.0 | ||||
|       workbox-core: 7.0.0 | ||||
|  | ||||
							
								
								
									
										
											BIN
										
									
								
								public/qpdf.wasm
									
									
									
									
									
								
							
							
						
						
									
										
											BIN
										
									
								
								public/qpdf.wasm
									
									
									
									
									
								
							
										
											Binary file not shown.
										
									
								
							
							
								
								
									
										2
									
								
								src/libs/qpdf/qpdf.d.ts
									
									
									
									
										vendored
									
									
								
							
							
						
						
									
										2
									
								
								src/libs/qpdf/qpdf.d.ts
									
									
									
									
										vendored
									
									
								
							| @ -1,2 +0,0 @@ | ||||
| const createModule: EmscriptenModuleFactory; | ||||
| export default createModule; | ||||
										
											
												File diff suppressed because it is too large
												Load Diff
											
										
									
								
							| @ -1,6 +1,6 @@ | ||||
| <script setup lang="ts"> | ||||
| import { Base64 } from 'js-base64'; | ||||
| import createQPDFModule from '@/libs/qpdf/qpdf'; | ||||
| import createQPDFModule from 'qpdf-wasm-esm-embedded'; | ||||
| import { useDownloadFileFromBase64Refs } from '@/composable/downloadBase64'; | ||||
| 
 | ||||
| const status = ref<'idle' | 'done' | 'error' | 'processing'>('idle'); | ||||
| @ -19,6 +19,7 @@ const userPassword = ref(''); | ||||
| const ownerPassword = ref(''); | ||||
| 
 | ||||
| const base64OutputPDF = ref(''); | ||||
| const logs = ref<string[]>([]); | ||||
| const fileName = ref(''); | ||||
| const fileExtension = ref('pdf'); | ||||
| const { download } = useDownloadFileFromBase64Refs( | ||||
| @ -42,6 +43,7 @@ async function onProcessClicked() { | ||||
|   status.value = 'processing'; | ||||
|   try { | ||||
|     const options = [ | ||||
|       '--verbose', | ||||
|       '--encrypt', | ||||
|     ]; | ||||
|     options.push(`${userPassword.value}`); | ||||
| @ -75,7 +77,15 @@ async function onProcessClicked() { | ||||
| } | ||||
| 
 | ||||
| async function callMainWithInOutPdf(data: ArrayBuffer, args: string[], expected_exitcode: number) { | ||||
|   const mod = await createQPDFModule(); | ||||
|   logs.value = []; | ||||
|   const mod = await createQPDFModule({ | ||||
|     print(text: string) { | ||||
|       logs.value.push(text); | ||||
|     }, | ||||
|     printErr(text: string) { | ||||
|       logs.value.push(text); | ||||
|     }, | ||||
|   }); | ||||
|   mod.FS.writeFile('in.pdf', new Uint8Array(data)); | ||||
|   const ret = mod.callMain(args); | ||||
|   if (expected_exitcode !== ret) { | ||||
| @ -190,5 +200,9 @@ const modificationRestrictionOptions = [ | ||||
|         size="small" | ||||
|       /> | ||||
|     </div> | ||||
| 
 | ||||
|     <c-card title="Logs"> | ||||
|       <pre>{{ logs.join('\n') }}</pre> | ||||
|     </c-card> | ||||
|   </div> | ||||
| </template> | ||||
|  | ||||
		Loading…
	
		Reference in New Issue
	
	Block a user