Free Support Forum - groupdocs.com

Generate Thumbnail


#1

Hi.
I’m not sure if “Metadata” is the proper thread to post my question, sorry and please move it to place where it must be if it’s not already.

I already purchased GroupDocs Total. For the first step, I want to have a thumbnail image of document. If it is a PDF or Doc(x), I need the first page to be in thumbnail. If it is a jpg, bmp, png etc I need a small-size low-resolution version of it.

How can I have it?

#2
Hello leapinquirer,

Thank you for posting your inquiry in the forums.

Since your inquiry is related to conversion / rendering between different formats, we have a product GroupDocs.Conversion to do this job. Therefore, I am moving this thread to GroupDocs.Conversion forums where my colleague will give you some appropriate reply.

Have a nice coding experience with GroupDocs APIs.

#3

Hello,

Thank you for giving a try to the new GroupDocs API's.


GroupDocs.Conversion API for .NET have features to achieve this, It converts any file to desired output format, please have a look at this sample code.


// Convert and save converted image file.

// Returns paths to the converted image file.

var saveOptions = new ImageSaveOptions

{

ConvertFileType = ImageSaveOptions.ImageFileType.Jpg,

OutputType = OutputType.String,

Dpi = 600,

NumPagesToConvert = 1,

PageNumber = 1,

Width = 120,

Height = 120

};

var convertedDocumentPath = conversionHandler.Convert<IList>("DOCXsample.docx", saveOptions);


Please find below some resources to quickly get started with GroupDocs.Conversion API.


If you will need any help or you will have any other questions please feel free to ask.


Warm Regards



#4

Thank you for the solution. It is awesome.
However, I wanted to store the output in memory not in a file. So I created class InMem implementing IOutputDataHandler and passed an instance of it to an instance of ConversionHandler:


class InMem : IOutputDataHandler
{
string _name;
public Stream _stream{get;set;}

public InMem(string name)
{
_name = name;
}
public string SaveFile(FileDescription fileDescription, Stream stream, SaveOptions saveOptions)
{
_stream = stream;
// Problem: stream is disposed
return _name;
}
}

But as shown, the received stream is disposed. Can I do anything?

#5

Oops! Sorry, there was a better way:
Setting OutputType to OutputType.Stream in ImageSaveOptions.

Thank you.


#6

Hi,


Thank you, we are glad to hear that your issue was resolved.


If you will need any help or you will have any other questions please feel free to ask.<o:p></o:p>

<o:p></o:p>

Warm Regards