How to create image stream from pdf

Posted by: rs on 2 December 2020, 4:13 am EST

  • Posted 2 December 2020, 4:13 am EST

    i try this way but it only allows to save as png-file.

    i want to get the image as a stream to work within programm.

        Dim img As Image
        Dim DocumentSource As New C1.Win.C1Document.C1PdfDocumentSource()
        DocumentSource.LoadFromFile(FileName)
    

    filter.FileName = FileName + “.png”

    DocumentSource.Export(filter)

  • Posted 2 December 2020, 7:38 pm EST

    Hi,

    You can export PdfDocumentSource to multiple types of image format, you can use format-specific filters to export to image, please refer to the sample attached where I have used JpegFilter to export the image, you need to assign the FileName and then call the Export method with this filter. If your document has multiple pages there will be multiple images saved then from the saved images, you can load any image to a stream.

    Various Export Filters are provided in namespace C1.Win.C1Document.Export.

    Follow this link to see all classes under this namespace: https://www.grapecity.com/componentone/docs/win/online-documentlibrary/C1.Win.C1Document.4.5.2~C1.Win.C1Document.Export_namespace.html

    For more information on Exporting using Format Specific Filter follow this link:

    https://www.grapecity.com/componentone/docs/win/online-documentlibrary/Export-PDF-using-Format-Specific-Filter.html

    If you any other questions, please let me know.

    Regards,

    Prabhat Sharma.

    PdfDocumentSourceImage1.zip

  • Posted 2 December 2020, 9:20 pm EST

    Hi Prabhat,

    thanks for your information.

    This is what i do at the moment.

    But i dont want to save the image as a file before, just to read it then as a stream.

    I want to get the stream in memory! (Others can, but i dont want to change to other tools :slight_smile: )

    Regards,

    Robert Schneider

  • Posted 3 December 2020, 6:23 pm EST

    Hi Robert,

    We are discussing this issue with the developers and will get back to you with the updates soon.

    [Internal Tracking ID: 24026]

    Regards,

    Prabhat Sharma.

  • Posted 8 September 2021, 7:09 pm EST

    Hello,

    As per the developers when Stream is specified for paged image filter like BmpFilter, JpegFilter and so on then C1ZipFile is created in the provided stream. As a workaround you can use TiffFilter, for example:

        ```
    

    C1PdfDocumentSource1.LoadFromFile(“demoPDF.pdf”)

    Dim filter As TiffFilter = New TiffFilter()

    filter.Monochrome = False

    imgStream = New MemoryStream()

    filter.Stream = imgStream

    'filter.FileName = “c:\temp\img.jpg”

    C1PdfDocumentSource1.Export(filter)

    filter.Stream.Seek(0, SeekOrigin.Begin)

    PictureBox1.Image = Image.FromStream(filter.Stream)

    
    Regards,
    Prabhat Sharma.
Need extra support?

Upgrade your support plan and get personal unlimited phone support with our customer engagement team

Learn More

Forum Channels