Skip to content

Commit 8111d4a

Browse files
author
Bob Strahan
committed
Fix inline display of PNG, JPG and PDF files in document viewer
1 parent 704c304 commit 8111d4a

File tree

2 files changed

+22
-15
lines changed

2 files changed

+22
-15
lines changed

CHANGELOG.md

Lines changed: 4 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -23,21 +23,11 @@ SPDX-License-Identifier: MIT-0
2323
- Markdown table headers now explicitly left-aligned using `|:-----|:-----------|` format for consistent appearance
2424

2525

26-
2726
### Fixed
28-
- **OCR Service Image Processing for PNG/JPG Files**
29-
- Fixed issue where PNG files were being unnecessarily converted to JPEG format and resized
30-
- PNG and JPG files now preserve their original format when stored in S3
31-
- Image resolution is preserved by default unless explicitly configured via `resize_config`
32-
- DPI settings now only apply to PDF files, not to image files
33-
- Resolves issue where PNG files were being converted to lower resolution JPG files
34-
- **Image File Display in Document Viewer**
35-
- Fixed issue where PNG and JPG image files were not rendering inline in the Document Details page
36-
- Images were incorrectly loaded in iframes which caused browsers to download them instead of displaying
37-
- Added specific handling for image file types to use `<img>` tag instead of iframe
38-
- Images now display inline with responsive sizing (max-width: 100%, max-height: 800px)
39-
- Added error handling with fallback download link if image fails to load
40-
- Maintains consistent UI with other document types (PDF, Excel, Word)
27+
- Fixed issue where PNG files were being unnecessarily converted to JPEG format and resized to lower resolution with lost quality
28+
- Fixed issue where PNG and JPG image files were not rendering inline in the Document Details page
29+
- Fixed issue where PDF files were being downloaded instead of displayed inline
30+
4131

4232

4333
## [0.3.7]

src/ui/src/components/common/generate-s3-presigned-url.js

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ const parseS3Url = (s3Url) => {
3434
return { bucket, key };
3535
};
3636

37-
const generateS3PresignedUrl = async (url, credentials) => {
37+
const generateS3PresignedUrl = async (url, credentials, options = {}) => {
3838
// If it's already a special URL (like detailType), return as is
3939
if (url.includes('detailType')) {
4040
return url;
@@ -72,7 +72,24 @@ const generateS3PresignedUrl = async (url, credentials) => {
7272

7373
// Parse the URL for the presigner
7474
const s3ObjectUrl = parseUrl(newUrl);
75+
76+
// Determine file type from key to set appropriate content disposition
77+
const fileExtension = key.split('.').pop().toLowerCase();
78+
const isDisplayableFile = ['pdf', 'jpg', 'jpeg', 'png', 'gif', 'svg', 'webp'].includes(fileExtension);
79+
80+
// Add query parameters for inline display if it's a displayable file type
81+
if (isDisplayableFile && options.forceInline !== false) {
82+
s3ObjectUrl.query = s3ObjectUrl.query || {};
83+
s3ObjectUrl.query['response-content-disposition'] = 'inline';
84+
85+
// Set appropriate content type for PDFs to ensure proper display
86+
if (fileExtension === 'pdf') {
87+
s3ObjectUrl.query['response-content-type'] = 'application/pdf';
88+
}
89+
}
90+
7591
logger.debug('Canonical URL:', newUrl);
92+
logger.debug('Query parameters:', s3ObjectUrl.query);
7693

7794
// Create presigner instance
7895
const presigner = new S3RequestPresigner({

0 commit comments

Comments
 (0)