PDFsharp & MigraDoc Forum

PDFsharp - A .NET library for processing PDF & MigraDoc - Creating documents on the fly
It is currently Sun Sep 14, 2025 9:59 am

All times are UTC


Forum rules


Please read this before posting on this forum: Forum Rules

Also see our new Tailored Support & Services site.



Post new topic Reply to topic  [ 6 posts ] 
Author Message
PostPosted: Wed Nov 20, 2013 11:53 am 
Offline

Joined: Wed Nov 20, 2013 11:43 am
Posts: 3
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


Top
 Profile  
Reply with quote  
PostPosted: Wed Nov 20, 2013 2:43 pm 
Offline
PDFsharp Guru
User avatar

Joined: Mon Oct 16, 2006 8:16 am
Posts: 3135
Location: Cologne, Germany
This thread might be helpful:
viewtopic.php?p=4544#p4544

_________________
Regards
Thomas Hoevel
PDFsharp Team


Top
 Profile  
Reply with quote  
PostPosted: Fri Nov 22, 2013 12:48 pm 
Offline

Joined: Wed Nov 20, 2013 11:43 am
Posts: 3
Hi Thomas,

Thanks for the thread provided. I had gone through that and it was helpful for png format. Can you help me for tiff format ?

Thank you,
Senthil D


Top
 Profile  
Reply with quote  
PostPosted: Mon Nov 25, 2013 3:57 am 
Offline

Joined: Wed Nov 20, 2013 11:43 am
Posts: 3
Hi Team,

Could you please help us on above query ?.

Thank you,
Senthil D


Top
 Profile  
Reply with quote  
PostPosted: Mon Nov 25, 2013 9:02 am 
Offline
PDFsharp Guru
User avatar

Joined: Mon Oct 16, 2006 8:16 am
Posts: 3135
Location: Cologne, Germany
"TIFF images" are left as an exercise for the reader. PDFsharp implements the encoding, but not the decoding.

BTW: PDF files contain JPEG images and PDF images. It's up to you to convert them to PNG or TIFF. We don't have code that does it.

_________________
Regards
Thomas Hoevel
PDFsharp Team


Top
 Profile  
Reply with quote  
PostPosted: Fri Aug 28, 2015 2:21 am 
Offline

Joined: Fri Dec 19, 2014 1:46 am
Posts: 8
I also want to get a code sample for extraction of TIFF from PDF, but I only find resource for extracting other image from PDF. Are there any resource for it now? Any help will be appreciated.


Top
 Profile  
Reply with quote  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 6 posts ] 

All times are UTC


Who is online

Users browsing this forum: No registered users and 155 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
Privacy Policy, Data Protection Declaration, Impressum
Powered by phpBB® Forum Software © phpBB Group