How do I convert big GIF files into PDF

Hi,

I have a big GIF file and when I convert that to PDF, only a part of that GIF shows up in PDF.

There must be some property which I am missing.

Here is the Code I have (Basically what I found on ur forum)

//Instantiate a Pdf object by calling its empty constructor

Aspose.Pdf.Pdf pdf1 = new Aspose.Pdf.Pdf();

//Create a section in the Pdf object

Aspose.Pdf.Section sec1 = pdf1.Sections.Add();

//Create an image object in the section

Aspose.Pdf.Image image1 = new Aspose.Pdf.Image(sec1);

//Add image object into the Paragraphs collection of the section

sec1.Paragraphs.Add(image1);

//Set the path of image file

image1.ImageInfo.File = filename;

//what is the image extension

string targetFilename = string.Empty;

string destfileName = string.Empty;

string extname = string.Empty;

int nextIndex = filename.LastIndexOf('.');

string originalfileName = filename.Substring(0, nextIndex);

extname = filename.Substring(nextIndex, 4);

if (extname.ToUpper() == ".GIF")

{

image1.ImageInfo.ImageFileType = Aspose.Pdf.ImageFileType.Gif;

}

else

{

}

//Save the Pdf

targetFilename = originalfileName + ".pdf";

destfileName = System.IO.Path.Combine(targetPath, targetFilename);

pdf1.Save(destfileName );

return destfileName;

I have also attached the Input GIF and output PDF I got.

Please help.

Hello Vikash,

Thanks for using our products.

When placing large image files into PDF document, you can specify the Image Height and Width information. You may try using the following code lines to specify the Image Width and Height information. For your reference, I have attached the resultant PDF that I have generated using Aspose.Pdf for .NET 5.1.0

// set the Image Height equal to Section Height minus Top and Bottom margin
image1.ImageInfo.FixHeight = sec1.PageInfo.PageHeight-sec1.PageInfo.Margin.Top - sec1.PageInfo.Margin.Bottom;
// set the Image Width equal to Section Width minus Left and Right margin
image1.ImageInfo.FixWidth = sec1.PageInfo.PageWidth-sec1.PageInfo.Margin.Left-sec1.PageInfo.Margin.Right;

In case it does not satisfy your requirements or you have any further query, please feel free to contact. We apologize for your inconvenience.

FYI, You may also try using ImageScale Property of Image Class to set the Image scale value.