I am using aspose component
With that i try to convert a gif file to pdf by using the following code.
public static void ConvertImageToPdf(string inputFileName, string outputFileName)
{
// Create Aspose.Words.Document and DocumentBuilder.
// The builder makes it simple to add content to the document.
Document doc = new Document();
DocumentBuilder builder = new DocumentBuilder(doc);<span style="color:green;">// Read the image from file, ensure it is disposed.</span> <span style="color:blue;">using</span> (<span style="color:#2b91af;">Image</span> image = <span style="color:#2b91af;">Image</span>.FromFile(inputFileName)) { <span style="color:green;">// Get the number of frames in the image.</span> <span style="color:blue;">int</span> framesCount = image.GetFrameCount(<span style="color:#2b91af;">FrameDimension</span>.Page); <span style="color:green;">// Loop through all frames.</span> <span style="color:blue;">for</span> (<span style="color:blue;">int</span> frameIdx = 0; frameIdx < framesCount; frameIdx++) { <span style="color:green;">// Insert a section break before each new page, in case of a multi-frame TIFF.</span> <span style="color:blue;">if</span> (frameIdx != 0) builder.InsertBreak(<span style="color:#2b91af;">BreakType</span>.SectionBreakNewPage); <span style="color:green;">// Select active frame.</span> image.SelectActiveFrame(<span style="color:#2b91af;">FrameDimension</span>.Page, frameIdx); <span style="color:green;">// We want the size of the page to be the same as the size of the image.</span> <span style="color:green;">// Convert pixels to points to size the page to the actual image size.</span> <span style="color:#2b91af;">PageSetup</span> ps = builder.PageSetup; ps.PageWidth = <span style="color:#2b91af;">ConvertUtil</span>.PixelToPoint(image.Width, image.HorizontalResolution); ps.PageHeight = <span style="color:#2b91af;">ConvertUtil</span>.PixelToPoint(image.Height, image.VerticalResolution); <span style="color:green;">// Insert the image into the document and position it at the top left corner of the page.</span> builder.InsertImage(image, <span style="color:#2b91af;">RelativeHorizontalPosition</span>.Page, 0, <span style="color:#2b91af;">RelativeVerticalPosition</span>.Page, 0, ps.PageWidth, ps.PageHeight, <span style="color:#2b91af;">WrapType</span>.None); } } <span style="color:green;">// Save the document to PDF.</span> doc.Save(outputFileName); } <br><br>But when it reach at <br><span style="color:blue;">int</span> framesCount = image.GetFrameCount(<span style="color:#2b91af;">FrameDimension</span>.Page);
It is throwing an error "A generic error occurred in GDI+"
Can you please help me on this
Regards
Anish