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

Free Support Forum - aspose.com

Docx to TIF (Docx to PDF to Tif)

Hi,

We've developed an object using Aspose components to convert a docx to a faxable tif by creating an intermediate PDF. The problem we have is that the tif that is created has multiple errors in its formatting. When we attempt to fax a tif created this way through a Brooktrout fax board, it errors. Brooktrout provides a program that can analyze a tif for problems. Attached you will find the log it creates.

Note: If I convert a PDF (from Adobe's website) to a TIF using the same methods as the above workflow uses, it creates a valid tif, which would suggest the issue has something to do with the PDF that gets created.

I've also attached the image itself, as well as the source docx. Below is a portion of the dump file that seems to show what is missing from the image (and which items are fault tolerant, and which aren't).

*** Required tag T6OPTIONS (293) missing.
Valid value(s) are 0.
Brooktrout functions will tolerate the lack of this tag.
*** Required tag PAGENUMBER (297) missing.
Valid value(s) are lower 16 bits 0000, upper 16 bits non-zero.
Brooktrout functions will tolerate the lack of this tag.
Page info done.
BfvTiffReadIFD: Misc error: Incorrect file format.
*** Required tag NEWSUBFILETYPE (254) missing.
Valid value(s) are 2.
Brooktrout functions will tolerate the lack of this tag.
*** Required tag IMAGEWIDTH (256) missing.
Valid value(s) are 1728,2048,2432/200dpi; 2592,3072,3648/300dpi; 3456,4096,4864/400dpi.
5184,6144,7296/600dpi; 10368,12288,14592/1200dpi; 864,1024,1216/100dpi.
Brooktrout functions will tolerate the lack of this tag.
*** Required tag IMAGELENGTH (257) missing.
Valid value(s) are length of image.
Brooktrout functions will tolerate the lack of this tag.
*** Required tag STRIPOFFSETS (273) missing.
Valid value(s) are offset of each strip.
*** Required tag ROWSPERSTRIP (278) missing.
Valid value(s) are number of rows in each strip.
Brooktrout functions will tolerate the lack of this tag.
*** Required tag STRIPBYTECOUNTS (279) missing.
Valid value(s) are number of bytes in each strip.
*** Required tag XRESOLUTION (282) missing.
Valid value(s) are fractions representing 200, 204, 300, 400, 408, 600, 1200,
or 100 (or 77 cm).
Brooktrout functions will tolerate the lack of this tag.
*** Required tag YRESOLUTION (283) missing.
Valid value(s) are fractions representing 98, 100, 196, 200, 300, 391, 400, 600, 800,
1200, or 100 (or 38.5, 77 cm).
Brooktrout functions will tolerate the lack of this tag.
*** Required tag COMPRESSION (259) missing.
Valid value(s) are 3 and 4.
Brooktrout functions will tolerate the lack of this tag.
*** Required tag PHOTOMETRICINTERP (262) missing.
Valid value(s) are 0 and 1
Brooktrout functions will tolerate the lack of this tag.
*** Required tag T6OPTIONS (293) missing.
Valid value(s) are 0.
Brooktrout functions will tolerate the lack of this tag.
*** Required tag PAGENUMBER (297) missing.
Valid value(s) are lower 16 bits 0001.
Brooktrout functions will tolerate the lack of this tag.

Thanks in advance,

Hi<?xml:namespace prefix = o ns = "urn:schemas-microsoft-com:office:office" />

Thanks for your inquiry. Could you please let me know how you create this TIF? Please provide me code example. I suppose you are using Aspose.Pdf.Kit for converting PDF to TIF. If so you should ask this question in the Aspose.Pdf.Kit forum.

You can also try using Aspose.Words.Viewer to convert document to TIF. Please find code example in the following thread.

Best regards.

The code is sprinkled throughout an object, so I recreated the basics in a single function. This code gives the same result as mentioned in the first posting.

Dim oDocxWords As New Aspose.Words.Document("X:\test.docx")
Dim strmAPDF As IO.Stream = New IO.MemoryStream
oDocxWords.Save(strmAPDF, Aspose.Words.SaveFormat.AsposePdf)
Dim oPDF As New Aspose.Pdf.Pdf
oPDF.BindXML(strmAPDF, Nothing)
Dim oConverter As New Aspose.Pdf.Kit.PdfConverter
Dim strmPDF As New IO.MemoryStream
oPDF.Save(strmPDF)
oConverter.BindPdf(strmPDF)
oConverter.SavaAsTIFFClassF("X:\test.tif", 204, 196)
oConverter = Nothing

Hi<?xml:namespace prefix = o ns = "urn:schemas-microsoft-com:office:office" />

I don’t think that this issue is related to Aspose.Words. I think you should post this request in Aspose.Pdf.Kit forum. Also please see the attached file. This is TIFF produced by Aspose.Words Viewer.

Best regards.

This tif has the same issue as the one I posted.

I posted my issue on the PDF.Kit forum as well.

http://www.aspose.com/community/forums/149412/docx-to-tif-docx-to-pdf-to-tif/showthread.aspx#149412

On a side note, the tif you sent me was 96 X 96...

any chance we could try one that has a resolution of 204 X 196?

Hi<?xml:namespace prefix = o ns = "urn:schemas-microsoft-com:office:office" />

Thanks for your inquiry. Yes, of course you can change resolution. I modified code to allow set resolution of output TIF.

public void Test132()

{

Document doc = new Document(@"Test132\PACER.docx");

DocumentRenderer renderer = new DocumentRenderer(doc);

CombineTif(renderer.GetPages(), @"Test132\out.tiff", 196, 204);

}

///

/// Combine some file into 1 tif multipage file

/// if black and write image, we use CCITT4 compression

/// else we use the LZW compression

///

/// the files to be combined, canbe (bmp, jpg, gif, png, tif)

/// the output filename

///

public static void CombineTif(Image[] InputImages, string OutputFilename, float vResolution, float hResolution)

{

//get ImageCodecInfo, generate tif format

ImageCodecInfo info = null;

foreach (ImageCodecInfo ice in ImageCodecInfo.GetImageEncoders())

{

if (ice.MimeType == "image/tiff")

{

info = ice;

break;

}

}

//define the encoderparameter,

//when the 1st page, will be EncoderValue.MultiFrame.

//when the other pages, will be EncoderValue.FrameDimensionPage.

//when all pages saved, will be the EncoderValue.Flush.

EncoderParameters ep = new EncoderParameters(2);

//when the 1st file, 1st frame, will be true.

//from the 1st file, 2nd frame, will be false.

bool isFirstPage = true;

Image img = null;

Bitmap bmpTemp = null;

//create a image instance from the 1st image

for (int imgIndex = 0; imgIndex < InputImages.Length; imgIndex++)

{

//get image from src file

Image img_src = InputImages[imgIndex];

ep.Param[0] = new EncoderParameter(System.Drawing.Imaging.Encoder.Compression, Convert.ToInt32(EncoderValue.CompressionLZW));

if (isFirstPage)

{

//1st file, 1st frame, create the master image

bmpTemp = (Bitmap)img_src;

bmpTemp.SetResolution(hResolution, vResolution);

img = (Image)bmpTemp;

ep.Param[1] = new EncoderParameter(System.Drawing.Imaging.Encoder.SaveFlag, Convert.ToInt32(EncoderValue.MultiFrame));

img.Save(OutputFilename, info, ep);

isFirstPage = false;

continue;

}

ep.Param[1] = new EncoderParameter(System.Drawing.Imaging.Encoder.SaveFlag, Convert.ToInt32(EncoderValue.FrameDimensionPage));

img.SaveAdd(img_src, ep);

}

ep.Param[1] = new EncoderParameter(System.Drawing.Imaging.Encoder.SaveFlag, Convert.ToInt32(EncoderValue.Flush));

img.SaveAdd(ep);

}

Also see attached TIF.

Best regards.

Hi<?xml:namespace prefix = o ns = "urn:schemas-microsoft-com:office:office" />

We are happy to tell you that the new Rendering Engine has replaced the “old Viewer Beta”. The Rendering Engine can print, save as images or draw onto .NET Graphics object any document page.

Please see Aspose.Words documentation to learn more about new features.

SaveToImage method renders document pages into images:

http://www.aspose.com/documentation/file-format-components/aspose.words-for-.net-and-java/aspose.words.document.savetoimage_overloads.html

In additional, new Rendering engine allows you to convert Word document to PDF directly (without using Aspose.Pdf).

SaveToPdf method converts the whole document or selected pages to PDF.

http://www.aspose.com/documentation/file-format-components/aspose.words-for-.net-and-java/aspose.words.document.savetopdf_overloads.html

The latest version of Aspose.Words is available for download from here:

http://www.aspose.com/community/files/51/file-format-components/aspose.words/entry158153.aspx

Best regards,