Image file must be between 0pt and 1584pt


#1

Hello,

Please find attached a copy of a file I tried to import into Aspose words and had the above error message. Theactual width of the image was reported as 2015.4.

Does Aspose words not scale wmf files ?. How can I resolve the issue. I need to ship the product out. I had a similar problem with Aspose Slides which you sorted out, and gave me a code snippet using GDI+.

Many thanks in advance


#2

The following code works in my test:

string imageFileName = Application.StartupPath + @"\Image Error\cm_tmp1610421001.wmf";

builder.InsertImage(imageFileName, RelativeHorizontalPosition.Page, 10, RelativeVerticalPosition.Page, 10, 2686, 914, WrapType.Through, WrapSide.Both, false, null);

Please provide the code snippet that will allow us to reproduce the error.

Best regards,


#3

Hi Miklovan,

I forgot to mention that we were using the merge event handler. Anyway here is the code snippet

/// overriden event handler for Image Field events

///

/// Event argument

protected override void ImageFieldEventHandler(Aspose.Words.Reporting.MergeImageFieldEventArgs e)

{

// process ctq diagram

if (( e.FieldName.ToLower() == "diagram" ) && ( m_Index < m_DiagramIDArray.Count))

{

string tmpStorageFile = cm.Lib.utl.getCreateTempFileName(".wmf",true);

//delete the file - makes sure there are no locking issues

File.Delete(tmpStorageFile);

// run the query and get the row iD

int diagramID = int.Parse((string) m_DiagramIDArray[m_Index]) ;

// and read file from BLOB table

if ( GetBlobToFile("ProcessDiagram",diagramID,"metafile",".wmf",0,out tmpStorageFile))

{

// and return the file name

e.ImageFileName = tmpStorageFile ;

}

// and increment the index for next call

m_Index++ ;

}

}

Hope this helps. For purposes of the test you need only return the image file as this is the standard aspose image event handler.

kind regards

William


#4

Thanks for additional info. It helped me to reproduce the error.

I have logged this problem to our defect base as issue #1083. We will try to fix it in the next hotfix which will be released in a few days.

Best regards,


#5

Try using the following code:

DocumentBuilder builder = new DocumentBuilder(e.Document);

builder.MoveToMergeField(e.FieldName);

// width/height set to 1/10 of the original size

// you can change width/height to desired values

double width = 268.6;

double height = 91.4;

builder.InsertImage(tmpStorageFile, width, height, null);

instead of:

// and return the file name

e.ImageFileName = tmpStorageFile ;

Hope it will help. It works in my test.


#6

Yes,

The suggested code works for all our instances.

Many thanks

WilliamW