V2: Convert Tool (#3828)

🔄 Dynamic Processing Strategies

- Adaptive routing: Same tool uses different backend endpoints based on
file analysis
- Combined vs separate processing: Intelligently chooses between merge
operations and individual file processing
- Cross-format workflows: Enable complex conversions like "mixed files →
PDF" that other tools can't handle

  ⚙️ Format-Specific Intelligence

  Each conversion type gets tailored options:
  - HTML/ZIP → PDF: Zoom controls (0.1-3.0 increments) with live preview
  - Email → PDF: Attachment handling, size limits, recipient control
  - PDF → PDF/A: Digital signature detection with warnings
  - Images → PDF: Smart combining vs individual file options

 File Architecture

  Core Implementation:
  ├── Convert.tsx                     # Main stepped workflow UI
├── ConvertSettings.tsx # Centralized settings with smart detection
├── GroupedFormatDropdown.tsx # Enhanced format selector with grouping
├── useConvertParameters.ts # Smart detection & parameter management
  ├── useConvertOperation.ts         # Multi-strategy processing logic
  └── Settings Components:
      ├── ConvertFromWebSettings.tsx      # HTML zoom controls
      ├── ConvertFromEmailSettings.tsx    # Email attachment options
├── ConvertToPdfaSettings.tsx # PDF/A with signature detection
      ├── ConvertFromImageSettings.tsx    # Image PDF options
      └── ConvertToImageSettings.tsx      # PDF to image options

 Utility Layer

  Utils & Services:
├── convertUtils.ts # Format detection & endpoint routing
  ├── fileResponseUtils.ts          # Generic API response handling
└── setupTests.ts # Enhanced test environment with crypto mocks

  Testing & Quality

  Comprehensive Test Coverage

  Test Suite:
├── useConvertParameters.test.ts # Parameter logic & smart detection
  ├── useConvertParametersAutoDetection.test.ts  # File type analysis
├── ConvertIntegration.test.tsx # End-to-end conversion workflows
  ├── ConvertSmartDetectionIntegration.test.tsx  # Mixed file scenarios
  ├── ConvertE2E.spec.ts                     # Playwright browser tests
├── convertUtils.test.ts # Utility function validation
  └── fileResponseUtils.test.ts              # API response handling

  Advanced Test Features

  - Crypto API mocking: Proper test environment for file hashing
  - File.arrayBuffer() polyfills: Complete browser API simulation
  - Multi-file scenario testing: Complex batch processing validation
- CI/CD integration: Vitest runs in GitHub Actions with proper artifacts

---------

Co-authored-by: Connor Yoh <[email protected]>
Co-authored-by: Anthony Stirling <[email protected]>
This commit is contained in:
ConnorYoh
2025-08-01 16:08:04 +01:00
committed by GitHub
co-authored by Connor Yoh Anthony Stirling
parent 8881f19b03
commit 9c9acbfb5b
68 changed files with 9173 additions and 87 deletions
+81 -13
View File
@@ -347,6 +347,10 @@
"title": "Rotate",
"desc": "Easily rotate your PDFs."
},
"convert": {
"title": "Convert",
"desc": "Convert files between different formats",
},
"imageToPdf": {
"title": "Image to PDF",
"desc": "Convert a image (PNG, JPEG, GIF) to PDF."
@@ -647,6 +651,73 @@
"selectAngle": "Select rotation angle (in multiples of 90 degrees):",
"submit": "Rotate"
},
"convert": {
"title": "Convert",
"desc": "Convert files between different formats",
"files": "Files",
"selectFilesPlaceholder": "Select files in the main view to get started",
"settings": "Settings",
"conversionCompleted": "Conversion completed",
"results": "Results",
"defaultFilename": "converted_file",
"conversionResults": "Conversion Results",
"convertFrom": "Convert from",
"convertTo": "Convert to",
"sourceFormatPlaceholder": "Source format",
"targetFormatPlaceholder": "Target format",
"selectSourceFormatFirst": "Select a source format first",
"outputOptions": "Output Options",
"pdfOptions": "PDF Options",
"imageOptions": "Image Options",
"colorType": "Colour Type",
"color": "Colour",
"greyscale": "Greyscale",
"blackwhite": "Black & White",
"dpi": "DPI",
"output": "Output",
"single": "Single",
"multiple": "Multiple",
"fitOption": "Fit Option",
"maintainAspectRatio": "Maintain Aspect Ratio",
"fitDocumentToPage": "Fit Document to Page",
"fillPage": "Fill Page",
"autoRotate": "Auto Rotate",
"autoRotateDescription": "Automatically rotate images to better fit the PDF page",
"combineImages": "Combine Images",
"combineImagesDescription": "Combine all images into one PDF, or create separate PDFs for each image",
"webOptions": "Web to PDF Options",
"zoomLevel": "Zoom Level",
"emailOptions": "Email to PDF Options",
"includeAttachments": "Include email attachments",
"maxAttachmentSize": "Maximum attachment size (MB)",
"includeAllRecipients": "Include CC and BCC recipients in header",
"downloadHtml": "Download HTML intermediate file instead of PDF",
"pdfaOptions": "PDF/A Options",
"outputFormat": "Output Format",
"pdfaNote": "PDF/A-1b is more compatible, PDF/A-2b supports more features.",
"pdfaDigitalSignatureWarning": "The PDF contains a digital signature. This will be removed in the next step.",
"fileFormat": "File Format",
"wordDoc": "Word Document",
"wordDocExt": "Word Document (.docx)",
"odtExt": "OpenDocument Text (.odt)",
"pptExt": "PowerPoint (.pptx)",
"odpExt": "OpenDocument Presentation (.odp)",
"txtExt": "Plain Text (.txt)",
"rtfExt": "Rich Text Format (.rtf)",
"selectedFiles": "Selected files",
"noFileSelected": "No file selected. Use the file panel to add files.",
"convertFiles": "Convert Files",
"converting": "Converting...",
"downloadConverted": "Download Converted File",
"errorNoFiles": "Please select at least one file to convert.",
"errorNoFormat": "Please select both source and target formats.",
"errorNotSupported": "Conversion from {{from}} to {{to}} is not supported.",
"images": "Images",
"officeDocs": "Office Documents (Word, Excel, PowerPoint)",
"imagesExt": "Images (JPG, PNG, etc.)",
"markdown": "Markdown",
"textRtf": "Text/RTF"
},
"imageToPdf": {
"tags": "conversion,img,jpg,picture,photo"
},
@@ -1582,18 +1653,6 @@
"pageEditor": "Page Editor",
"fileManager": "File Manager"
},
"fileManager": {
"dragDrop": "Drag & Drop files here",
"clickToUpload": "Click to upload files",
"selectedFiles": "Selected Files",
"clearAll": "Clear All",
"storage": "Storage",
"filesStored": "files stored",
"storageError": "Storage error occurred",
"storageLow": "Storage is running low. Consider removing old files.",
"uploadError": "Failed to upload some files.",
"supportMessage": "Powered by browser database storage for unlimited capacity"
},
"pageEditor": {
"title": "Page Editor",
"save": "Save Changes",
@@ -1665,7 +1724,16 @@
"failedToLoad": "Failed to load file to active set.",
"storageCleared": "Browser cleared storage. Files have been removed. Please re-upload.",
"clearAll": "Clear All",
"reloadFiles": "Reload Files"
"reloadFiles": "Reload Files",
"dragDrop": "Drag & Drop files here",
"clickToUpload": "Click to upload files",
"selectedFiles": "Selected Files",
"storage": "Storage",
"filesStored": "files stored",
"storageError": "Storage error occurred",
"storageLow": "Storage is running low. Consider removing old files.",
"supportMessage": "Powered by browser database storage for unlimited capacity",
"noFileSelected": "No files selected"
},
"storage": {
"temporaryNotice": "Files are stored temporarily in your browser and may be cleared automatically",
@@ -1567,5 +1567,51 @@
"description": "These cookies help us understand how our tools are being used, so we can focus on building the features our community values most. Rest assured—Stirling PDF cannot and will never track the content of the documents you work with."
}
}
},
"convert": {
"files": "Files",
"selectFilesPlaceholder": "Select files in the main view to get started",
"settings": "Settings",
"conversionCompleted": "Conversion completed",
"results": "Results",
"defaultFilename": "converted_file",
"conversionResults": "Conversion Results",
"converting": "Converting...",
"convertFiles": "Convert Files",
"downloadConverted": "Download Converted File",
"convertFrom": "Convert from",
"convertTo": "Convert to",
"sourceFormatPlaceholder": "Source format",
"targetFormatPlaceholder": "Target format",
"selectSourceFormatFirst": "Select a source format first",
"imageOptions": "Image Options",
"colorType": "Color Type",
"color": "Color",
"greyscale": "Greyscale",
"blackwhite": "Black & White",
"dpi": "DPI",
"output": "Output",
"single": "Single",
"multiple": "Multiple",
"pdfOptions": "PDF Options",
"fitOption": "Fit Option",
"maintainAspectRatio": "Maintain Aspect Ratio",
"fitDocumentToPage": "Fit Document to Page",
"fillPage": "Fill Page",
"autoRotate": "Auto Rotate",
"autoRotateDescription": "Automatically rotate images to better fit the PDF page",
"combineImages": "Combine Images",
"combineImagesDescription": "Combine all images into one PDF, or create separate PDFs for each image",
"webOptions": "Web to PDF Options",
"zoomLevel": "Zoom Level",
"emailOptions": "Email to PDF Options",
"includeAttachments": "Include email attachments",
"maxAttachmentSize": "Maximum attachment size (MB)",
"includeAllRecipients": "Include CC and BCC recipients in header",
"downloadHtml": "Download HTML intermediate file instead of PDF",
"pdfaOptions": "PDF/A Options",
"outputFormat": "Output Format",
"pdfaNote": "PDF/A-1b is more compatible, PDF/A-2b supports more features.",
"pdfaDigitalSignatureWarning": "The PDF contains a digital signature. This will be removed in the next step."
}
}
@@ -0,0 +1,29 @@
{
"convert": {
"selectSourceFormat": "Select source file format",
"selectTargetFormat": "Select target file format",
"selectFirst": "Select a source format first",
"imageOptions": "Image Options:",
"emailOptions": "Email Options:",
"colorType": "Color Type",
"dpi": "DPI",
"singleOrMultiple": "Output",
"emailNote": "Email attachments and embedded images will be included"
},
"common": {
"color": "Color",
"grayscale": "Grayscale",
"blackWhite": "Black & White",
"single": "Single Image",
"multiple": "Multiple Images"
},
"groups": {
"document": "Document",
"spreadsheet": "Spreadsheet",
"presentation": "Presentation",
"image": "Image",
"web": "Web",
"text": "Text",
"email": "Email"
}
}