Skip to content

Commit f373de0

Browse files
committed
pdf: tolerate missing renderer when using pdfpig
1 parent 9fcba23 commit f373de0

1 file changed

Lines changed: 16 additions & 1 deletion

File tree

src/MarkItDown/Converters/PdfConverter.cs

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -405,7 +405,22 @@ private PdfExtractionResult BuildExtractionFromExtractedText(IReadOnlyList<PdfPa
405405
private async Task<PdfExtractionResult> BuildExtractionFromPdfPigAsync(byte[] pdfBytes, StreamInfo streamInfo, CancellationToken cancellationToken)
406406
{
407407
var pages = await textExtractor.ExtractTextAsync(pdfBytes, cancellationToken).ConfigureAwait(false);
408-
var pageImages = await imageRenderer.RenderImagesAsync(pdfBytes, cancellationToken).ConfigureAwait(false);
408+
409+
IReadOnlyList<string> pageImages;
410+
411+
try
412+
{
413+
pageImages = await imageRenderer.RenderImagesAsync(pdfBytes, cancellationToken).ConfigureAwait(false);
414+
}
415+
catch (OperationCanceledException)
416+
{
417+
throw;
418+
}
419+
catch
420+
{
421+
pageImages = Array.Empty<string>();
422+
}
423+
409424
return BuildExtractionFromExtractedText(pages, pageImages, streamInfo);
410425
}
411426

0 commit comments

Comments
 (0)