mirror of
https://github.com/Frooodle/Stirling-PDF.git
synced 2025-11-16 01:21:16 +01:00
blank images
This commit is contained in:
parent
ded2edcfc5
commit
338afbc8f3
@ -2647,8 +2647,18 @@ public class PdfJsonConversionService {
|
|||||||
pageNumber);
|
pageNumber);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
try {
|
||||||
contentStream.showText(
|
contentStream.showText(
|
||||||
new String(encoded, StandardCharsets.ISO_8859_1));
|
new String(encoded, StandardCharsets.ISO_8859_1));
|
||||||
|
} catch (IllegalArgumentException ex) {
|
||||||
|
log.warn(
|
||||||
|
"Failed to render text '{}' with font {} on page {}: {}",
|
||||||
|
run.text(),
|
||||||
|
run.font().getName(),
|
||||||
|
pageNumber,
|
||||||
|
ex.getMessage());
|
||||||
|
continue;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -3380,8 +3390,18 @@ public class PdfJsonConversionService {
|
|||||||
// or return null to trigger fallback font
|
// or return null to trigger fallback font
|
||||||
} else if (!isType3Font || fontModel == null) {
|
} else if (!isType3Font || fontModel == null) {
|
||||||
// For non-Type3 fonts without Type3 metadata, use standard encoding
|
// For non-Type3 fonts without Type3 metadata, use standard encoding
|
||||||
|
try {
|
||||||
byte[] encoded = font.encode(text);
|
byte[] encoded = font.encode(text);
|
||||||
return sanitizeEncoded(encoded);
|
return sanitizeEncoded(encoded);
|
||||||
|
} catch (IllegalArgumentException ex) {
|
||||||
|
log.info(
|
||||||
|
"[FONT-DEBUG] Font {} cannot encode text '{}': {}",
|
||||||
|
font.getName(),
|
||||||
|
text,
|
||||||
|
ex.getMessage());
|
||||||
|
// Return null to trigger fallback font mechanism
|
||||||
|
return null;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Type3 glyph mapping logic (for actual Type3 fonts AND normalized Type3 fonts)
|
// Type3 glyph mapping logic (for actual Type3 fonts AND normalized Type3 fonts)
|
||||||
|
|||||||
@ -4471,7 +4471,8 @@
|
|||||||
"title": "PDF Editor",
|
"title": "PDF Editor",
|
||||||
"badges": {
|
"badges": {
|
||||||
"unsaved": "Unsaved changes",
|
"unsaved": "Unsaved changes",
|
||||||
"modified": "Edited"
|
"modified": "Edited",
|
||||||
|
"earlyAccess": "Early Access - Pre-Alpha"
|
||||||
},
|
},
|
||||||
"controls": {
|
"controls": {
|
||||||
"title": "Document Controls"
|
"title": "Document Controls"
|
||||||
@ -4526,6 +4527,12 @@
|
|||||||
"paragraph": "Paragraph",
|
"paragraph": "Paragraph",
|
||||||
"singleLine": "Single Line"
|
"singleLine": "Single Line"
|
||||||
},
|
},
|
||||||
|
"modeChange": {
|
||||||
|
"title": "Confirm Mode Change",
|
||||||
|
"warning": "Changing the text grouping mode will reset all unsaved changes. Are you sure you want to continue?",
|
||||||
|
"cancel": "Cancel",
|
||||||
|
"confirm": "Reset and Change Mode"
|
||||||
|
},
|
||||||
"disclaimer": {
|
"disclaimer": {
|
||||||
"heading": "Preview limitations",
|
"heading": "Preview limitations",
|
||||||
"textFocus": "This workspace focuses on editing text and repositioning embedded images. Complex page artwork, form widgets, and layered graphics are preserved for export but are not fully editable here.",
|
"textFocus": "This workspace focuses on editing text and repositioning embedded images. Complex page artwork, form widgets, and layered graphics are preserved for export but are not fully editable here.",
|
||||||
|
|||||||
@ -255,8 +255,8 @@ const FontStatusPanel: React.FC<FontStatusPanelProps> = ({ document, pageIndex }
|
|||||||
|
|
||||||
{/* Font List */}
|
{/* Font List */}
|
||||||
<Stack gap={4} mt="xs">
|
<Stack gap={4} mt="xs">
|
||||||
{fonts.map((font) => (
|
{fonts.map((font, index) => (
|
||||||
<FontDetailItem key={font.fontId} analysis={font} />
|
<FontDetailItem key={`${font.fontId}-${index}`} analysis={font} />
|
||||||
))}
|
))}
|
||||||
</Stack>
|
</Stack>
|
||||||
</Stack>
|
</Stack>
|
||||||
|
|||||||
@ -976,6 +976,36 @@ const PdfTextEditor = ({ onComplete, onError }: BaseToolProps) => {
|
|||||||
} catch (textError) {
|
} catch (textError) {
|
||||||
console.warn('[PdfTextEditor] Failed to strip text from preview', textError);
|
console.warn('[PdfTextEditor] Failed to strip text from preview', textError);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Also mask out images to prevent ghost/shadow images when they're moved
|
||||||
|
try {
|
||||||
|
const pageImages = imagesByPage[pageIndex] ?? [];
|
||||||
|
if (pageImages.length > 0) {
|
||||||
|
context.save();
|
||||||
|
context.globalCompositeOperation = 'destination-out';
|
||||||
|
context.fillStyle = '#000000';
|
||||||
|
for (const image of pageImages) {
|
||||||
|
if (!image) continue;
|
||||||
|
// Get image bounds in PDF coordinates
|
||||||
|
const left = image.left ?? image.x ?? 0;
|
||||||
|
const bottom = image.bottom ?? image.y ?? 0;
|
||||||
|
const width = image.width ?? Math.max((image.right ?? left) - left, 0);
|
||||||
|
const height = image.height ?? Math.max((image.top ?? bottom) - bottom, 0);
|
||||||
|
const right = left + width;
|
||||||
|
const top = bottom + height;
|
||||||
|
|
||||||
|
// Convert to canvas coordinates (PDF origin is bottom-left, canvas is top-left)
|
||||||
|
const canvasX = left * scale;
|
||||||
|
const canvasY = canvas.height - top * scale;
|
||||||
|
const canvasWidth = width * scale;
|
||||||
|
const canvasHeight = height * scale;
|
||||||
|
context.fillRect(canvasX, canvasY, canvasWidth, canvasHeight);
|
||||||
|
}
|
||||||
|
context.restore();
|
||||||
|
}
|
||||||
|
} catch (imageError) {
|
||||||
|
console.warn('[PdfTextEditor] Failed to strip images from preview', imageError);
|
||||||
|
}
|
||||||
const dataUrl = canvas.toDataURL('image/png');
|
const dataUrl = canvas.toDataURL('image/png');
|
||||||
page.cleanup();
|
page.cleanup();
|
||||||
if (previewRequestIdRef.current !== currentToken) {
|
if (previewRequestIdRef.current !== currentToken) {
|
||||||
@ -993,7 +1023,7 @@ const PdfTextEditor = ({ onComplete, onError }: BaseToolProps) => {
|
|||||||
previewRenderingRef.current.delete(pageIndex);
|
previewRenderingRef.current.delete(pageIndex);
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
[hasVectorPreview],
|
[hasVectorPreview, imagesByPage],
|
||||||
);
|
);
|
||||||
|
|
||||||
// Re-group text when grouping mode changes without forcing a full reload
|
// Re-group text when grouping mode changes without forcing a full reload
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user