Image file types


#1

I keep getting this error even after defining the file type.

Invalid image file type for image Parameter name: Unknown

I am trying to insert an image as a watermark, I have looked at the notes in Wiki but still no avale thanks for any help.


#2

Thanks for considering Aspose.

Could u attach image file for our tests?


#3

Aspose.Pdf gets image type from the extended file name. For example, image1.png will be considered as a PNG image. If your file name is not normal, please use ImageFileType to set the image file type.


#4

Here you go I have used the filetype as well is still gives me an error too


#5

Thanks for considering Aspose.

I have tried to make wartermark with your gif, everything works well. My test code is below:

Pdf pdf1 = new Pdf();

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

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

image1.ImageInfo.File = @"E:\NeedToTest\Complete.gif";
image1.ImageInfo.ImageFileType = ImageFileType.Gif;
Aspose.Pdf.GraphNote note1 = new GraphNote(sec1);
note1.Content = "this is note1";
note1.PositionX = 50;
note1.PositionY = 100;
image1.ImageNotes.Add(note1);

Aspose.Pdf.Image image2 = new Aspose.Pdf.Image(sec1);
sec1.Paragraphs.Add(image2);

image2.ImageInfo.File = @"E:\NeedToTest\Complete.gif";
image2.ImageInfo.ImageFileType = ImageFileType.Gif;
image2.ImageInfo.CcittSubFormat = CcittSubFormat.Group31D;
image2.ImageWidth = 350;
image2.ImageHeight = 400;

pdf1.Save(@"E:\NeedToTest\pdftest.pdf");

I used Aspose.Pdf version 2.9.5.2.


#6

Thanks Tommy and Kevin