Dear Team,
I have loaded pdf document (tifflzw decoded) using pdf sharp . I would like to extract image from pdf. I am using below code. I can able to extract jpeg decoded images from pdf but tiff decoded images could not. How to achieve this.
Code:
Dim document As PdfSharp.Pdf.PdfDocument = PdfSharp.Pdf.IO.PdfReader.Open(tpath)
Dim imageCount As Integer = 0
' Iterate pages
For Each page As PdfSharp.Pdf.PdfPage In document.Pages
Dim resources As PdfSharp.Pdf.PdfDictionary = page.Elements.GetDictionary("/Resources")
If resources IsNot Nothing Then
' Get external objects dictionary
Dim xObjects As PdfSharp.Pdf.PdfDictionary = resources.Elements.GetDictionary("/XObject")
If xObjects IsNot Nothing Then
Dim items As ICollection(Of PdfSharp.Pdf.PdfItem) = xObjects.Elements.Values
' Iterate references to external objects
For Each item As PdfSharp.Pdf.PdfItem In items
Dim reference As PdfSharp.Pdf.Advanced.PdfReference = TryCast(item, PdfSharp.Pdf.Advanced.PdfReference)
If reference IsNot Nothing Then
Dim xObject As PdfSharp.Pdf.PdfDictionary = TryCast(reference.Value, PdfSharp.Pdf.PdfDictionary)
' Is external object an image?
If xObject IsNot Nothing AndAlso xObject.Elements.GetString("/Subtype") = "/Image" Then
ExportImage(xObject, imageCount)
End If
End If
Next
End If
End If
Next
Thanks in advance,
Senthil D