We're sorry Aspose doesn't work properply without JavaScript enabled.

Free Support Forum - aspose.com

Single page TIFF is created from multi page DOCX when IDE is Eclipse using Java

We encountered a strange thing when going from DOCX directly to TIF.
Only the first page will be converted/saved into the TIF-file.

Version Aspose 20.05, Java 8u201 and the following code
import com.aspose.words.Document;
import com.aspose.words.ImageBinarizationMethod;
import com.aspose.words.ImageColorMode;
import com.aspose.words.ImageSaveOptions;
import com.aspose.words.SaveFormat;
import com.aspose.words.TiffCompression;

        Document doc = new com.aspose.words.Document(sourceFile);
        
        ImageSaveOptions options = new ImageSaveOptions(SaveFormat.TIFF);
        
                    
        options.setPageIndex(0);            
        options.setPageCount(doc.getPageCount());       
        options.setTiffCompression(TiffCompression.CCITT_4);
        options.setImageColorMode(ImageColorMode.GRAYSCALE);
      options.setTiffBinarizationMethod(ImageBinarizationMethod.FLOYD_STEINBERG_DITHERING);
        options.setThresholdForFloydSteinbergDithering((byte) 128);       
                    
        doc.save(destFile, options);

I attached the original file and the produced tiff file.
Funfact: If we first create a PDF and then from PDF to TIF it works as expected.GEN_Formular_47121516459242120.zip (162.0 KB)

@pkvogt

We have tested the scenario using the latest version of Aspose.Words for Java 20.6 and have not found the shared issue. So, please use the latest version of Aspose.Words for Java 20.6. We have attached the output TIFF file with this post for your kind reference. output TIff.zip (40.0 KB)

AsposeTiffOnePageProblem.zip (9.4 MB)
We attached a video showing exactly what and how we did it. Hopefully you can now reproduce.

THX much
Patrick

@pkvogt

Please download and open the output TIFF file shared in my previous post and share either it works at our side or not. You can open the TIFF file at different system to check this issue.

Moreover, please share the name of operating system that your using.

Hi Tahir, well, the output file you generated looks OK. The point is that we cannot create this file without going the extra route via PDF (see the video).

The operating system version we use is Windows Server 2019 Version 1809 Build 17763.107.

THX
Patrick

Hi Tahir,

We can open your “output Tiff” file and see all pages. That means, our viewer is able to display multipage tiff files.

We made a lot of other tests with Aspose.Word for Java 20.6 and JDK 1.7.

The first one is the following, which is quite the same as the original one:

    // Open the document.
    Document doc = new Document(dataDir + "Test.doc");

    ImageSaveOptions options = new ImageSaveOptions(SaveFormat.TIFF);
    
    /*
    options.setPageCount(5);
    options.setPageIndex(0);
    */
    
    options.setTiffCompression(TiffCompression.CCITT_3);
    options.setImageColorMode(ImageColorMode.GRAYSCALE);
    options.setTiffBinarizationMethod(ImageBinarizationMethod.FLOYD_STEINBERG_DITHERING);
    // The default value of this property is 128. The higher value, the darker image
    options.setThresholdForFloydSteinbergDithering((byte) 254);
    
    doc.save(dataDir + "Rendering.SaveToTiff" + ".tiff", options);

As you can see, we’ve setPageCount and setPageIndex are not fired, as the default values are already the correct one.
The output tiff file still only contains one page only.

We’ve then tried to convert the same file to svg:
Document doc = new Document(dataDir + “Test.doc”);

    ImageSaveOptions options = new ImageSaveOptions(SaveFormat.SVG);
    
    doc.save(dataDir + "Rendering.SaveToSvg " + ".svg", options);

and here the generated svg file contains all pages:
Rendering.SaveTosvg.zip (109.3 KB)

Furthermore, the following code, which generate all pages in a separated file, works:
// Open the document.
Document doc = new Document(dataDir + “Test.doc”);

    ImageSaveOptions options = new ImageSaveOptions(SaveFormat.TIFF);
    options.setPageCount(1);

    for (int i = 0; i < doc.getPageCount(); i++) {
        options.setPageIndex(i);
        doc.save(dataDir + "Rendering.SaveToEmf." + Integer.toString(i) + ".tiff", options);
    }        

To resume, it’s only the multipage tiff file which does not work ! Do you have other suggestions ?

Regards,

Sam

@Samuel.Etterlen

We have tested the scenario and have managed to reproduce the same issue at our side. For the sake of correction, we have logged this problem in our issue tracking system as WORDSJAVA-2428 . You will be notified via this forum thread once this issue is resolved.

We apologize for your inconvenience.

1 Like

The issues you have found earlier (filed as WORDSJAVA-2428) have been fixed in this Aspose.Words for .NET 20.8 update and this Aspose.Words for Java 20.8 update.

Acknowledge!