Problems with mail merging images

Hi
As I told you I can’t reproduce this problem on my side. If you can’t renew your Aspose.Words version then you can create simple utility for resizing images using ResizeImage method.
Just loop through all images, resize and replace them.
Best regards.

Which version of aspose words can I download and try? Can I download the 29/01/2006 version?

Hi
Yes, you can try this version. You can download any version. But new versions will work in the trial mode.
Best regards.

Hi Alexey,
I am now using the resize code that you gave me a while back with the Add handler and it is Ok except that it resizes different images , differently. Some of the images are just right, some of them like I said before loads zoomed out a bit and some them really tiny. Can I change anything in the resize code so that it resizes them uniformly?
Regds

Hi
Thanks for your inquiry. I think that you can add some conditional logic to this method. For example see the following pseudo code.
If (imageSize > definedSize)
Then
Resize image
Else
Do nothing and return the original image.
Best regards.

That works for the zoomed out loading images as these are smaller than the resize parameters.
But the one that loads small on the report is 1630kb, Width = 2456px height = 3458 px HR/VR - 300 dpi
One that loads correctly is 1332kb W iidth = 1701px Height = 2340px HR/VR - 200dpi
These are the sizes before resizing!
Any ideas???

Hi
It is not quite clear for me what you mean. Could you please attach sample images, code and template for testing?
Best regards.

Hi,
I’m using aspose.words 7.0.0.0 and am having a similar problem. My app creates images that occasionally can be scaled up into wall charts (replacing brown paper). When scaling an image (an EMF), an error is generated when the width or height of the image is over 1584 PTS.
Is there a reason for the number 1584 pts? In the tests, I’m setting the papersize to A0 or A1 so the actual space on the paper should have ample space for a larger image.
The largest image I seem to be able to make is about A2.
Any thoughts or suggestions appreciated!!
Regards, Bruce

Hi

Thanks for your request. Could you please attach your document and the picture here and provide me your code? I will check the issue and provide you more information.
Best regards,

Hi,
I’ve cleaned up my code … now handling high DPI and available space as best I can. I do not get the error with this version - however, the pictures look like they are not able to go bigger than a fixed width. The problem can be seen in the attached PDFs that have been set to print on A0, A1, A2, A3, A4. For these tests, I’ve printed to an Adobe PDF Printer.
The paper size on the PDFs is fine. The file size is fine. The image is an EMF and should not actually need to increase the file size as these are vector images.
However, the A1 and A0 PDF files are not using the full width / height of the paper.
I have attached the one subroutine in my app that uses the builder to insert the EMF Image.
Making a sample is a bit more complicated … I’ll give it a try - the problem is saving an EMF as an EMF. I’ve attached a word document that contains the EMF as an EMF. So I would need to write a sample to read the document extract the image as an EMF and then call the routine to insert the file… and set the page size… I’ll see if I can get some time to make this sample code … (unless you can see some problems with the code I’ve provided).
Thanks for your help!! Any pointers, thoughts or idea why this is happening appreciated!!
Regards, Bruce

Hi

Thank you for additional information. I cannot reproduce the problem with image size on my side. I used the following code for testing:

PaperSize[] sizes = new PaperSize[] { PaperSize.A3, PaperSize.A4, PaperSize.A5, PaperSize.B4, PaperSize.B5 };
// Open an image.
using (Image image = Image.FromFile(@"Test001\pict.emf"))
{
    foreach (PaperSize size in sizes)
    {
        // Create new document and DocumentBuilder
        Document doc = new Document();
        DocumentBuilder builder = new DocumentBuilder(doc);
        PageSetup ps = doc.FirstSection.PageSetup;
        // Set paper size and make page to be landscape.
        ps.PaperSize = size;
        ps.Orientation = Orientation.Landscape;
        // Get image size.
        double imageHeight;
        double imageWidth;
        CalculateImageSize(image, ps.PageHeight - ps.TopMargin - ps.BottomMargin,
        ps.PageWidth - ps.LeftMargin - ps.RightMargin, out imageHeight, out imageWidth);
        // Insert an image.
        builder.InsertImage(image, imageWidth, imageHeight);
        // Save docuemnt in doc and pdf formats.
        doc.Save(string.Format(@"Test001\out_{0}.doc", size));
        doc.SaveToPdf(string.Format(@"Test001\out_{0}.pdf", size));
    }
}

=====================================================================

/// 
/// Calculates size of Image
/// 
/// Original image
/// Height of container where image should be inserted.
/// Height of container where image should be inserted.
/// Height of the image
/// Width of the image
public void CalculateImageSize(Image img, double containerHeight, double containerWidth, out double targetHeight, out double targetWidth)
{
    //Calculate width and height
    targetHeight = containerHeight;
    targetWidth = containerWidth;
    //Get size of an image
    double imgHeight = ConvertUtil.PixelToPoint(img.Height);
    double imgWidth = ConvertUtil.PixelToPoint(img.Width);
    if (imgHeight < targetHeight && imgWidth < targetWidth)
    {
        targetHeight = imgHeight;
        targetWidth = imgWidth;
    }
    else
    {
        //Calculate size of an image in the document
        double ratioWidth = imgWidth / targetWidth;
        double ratioHeight = imgHeight / targetHeight;
        if (ratioWidth > ratioHeight)
            targetHeight = (targetHeight * (ratioHeight / ratioWidth));
        else
            targetWidth = (targetWidth * (ratioWidth / ratioHeight));
    }
}

If you need I can translate the code in VB.
However, I found problems with rendering EMF image on my side. Some object are moved a little bit. I used the following code to extract EMF image from the document:

Document doc = new Document(@"Test001\PBSA4.DOC");
Shape shape = (Shape) doc.GetChild(NodeType.Shape, 0, true);
shape.ImageData.Save(@"Test001\out.emf");

Best regards.

Hi,
I really appreciate your code sample … The papersizes you used all work fine on my side too.
If you specified a custom papersize of: A0 = 46.80in x 33.11in, this might look similar to the PDFA0 sample I provided. I found that A2 worked ok and A1 and A0 did not.
A1 = 33.11in x 23.39in
Also, anytime an EMF is saved to a disk file - it becomes a PNG (a microsoft .net feature) … this will not have the same characteristics as the EMF. So make sure that you are actually using an EMF from the word document… (if you know of any way to save EMF in a disk file as an EMF … please let me know).
Regards, Bruce

Hi

Thank you for additional information. The problem occurs because A0 size is not supported by MS Word formats. maximum size of page, you can specify in MS Word, is 1584x1584pt. But A0 size is 2383,9x3369,6pt.
Best regards.

Hi,
Many thanks!!! Such a simple answer!!! This explains what I observed!!
I also appreciated the sample!!
Regards, Bruce

The issues you have found earlier (filed as WORDSNET-2934) have been fixed in this .NET update and this Java update.


This message was posted using Notification2Forum from Downloads module by aspose.notifier.