Spire.Doc
Friday, 23 March 2012 02:30

How to Convert Word to Tiff

Written by support iceblue

TIFF(Tagged Image File Format) is a flexible and adaptable file format for handling images and data within a single file. It's popular among graphic artists or the publishing industry. As a popular image format, TIFF file owns the ability of storing image data in a lossless format and it can be a container holding compressed (lossy) JPEG and (lossless) PackBits compressed images. However, TIFF can be created through Spire.Doc. By using Spire.Doc, developers can easily convert documents from Word to TIFF.

Download Spire.Doc (or Spire.Office) with .NET Framework 2.0 (or above) together. Once make sure Spire.Doc (or Spire.Office) are correctly installed on system, follow the steps below to convert Word to TIFF.

Step 1: Open your Visual Studio and create a new project, choose "Windows Forms Application". In "Solution Explorer", right click "Reference" and then choose "Add Reference". Browse to the directory where you install the component. Now you can add codes to convert word to Tiff Image.

Step 2: Add a "Button" to Form1. Double click the button, add the following codes in the top of file.

[C#]
using Spire;
using Spire.Doc;
using Spire.Doc.Documents;
using System.Drawing.Imaging;
[VB.NET]
Imports Spire
Imports Spire.Doc
Imports Spire.Doc.Documents
Imports System.Drawing.Imaging

Step 3: Spire.Doc allows users to create Word document with colorful content. Here we can use Spire.Doc to create a test Word document.

[C#]
Document document = new Document();  
doc.LoadFromFile("Word.docx"); 
[VB.NET]
Dim document As New Document()
doc.LoadFromFile("Word.docx")

Step 4: Spire.Doc presents almost the easiest solution to do Word to TIFF conversion. Through the following 2 simple sentences of code, we can save Word document as TIFF format.

[C#]
Image image = document.SaveToImages(0, ImageType.Bitmap);  
image.Save("Sample.tif", ImageFormat.Tiff);
[VB.NET]
Dim image As Image = document.SaveToImages(0, ImageType.Bitmap)
image.Save("Sample.tif", ImageFormat.Tiff)

After finish writing codes, start the project by pressing F5 and click the button. Then, a TIFF file will be automatically generated. Check out the effect image below:

Effective Screenshot:

Word to Tiff

Spire.Doc can convert Word to most of popular file formats. It can convert Word to PDF, HTML, XML, RTF, Text, ePub, etc. Click to learn more

Wednesday, 21 March 2012 09:29

Insert Comments into Word in Silverlight

Written by support iceblue

The sample demonstrates how to insert comments into Word for Silverlight via Spire.Doc.

 

Thursday, 15 March 2012 09:31

How to Set Word Table Column Width

Written by support iceblue

By using Spire.Doc, developers can create Word document with a table inside (Click to learn how to create table in Word document). But when users create table in Word document, they would not only create table with blank cells. They need set formats or sometimes set table size like column width. This article will show you how to set Word table column width.

Make sure Spire.Doc and Visual Studio are correctly installed on system. Follow the simple steps below to set Word table column width.

Step 1: Create a C# windows form application in Visual Studio. Add Spire.Doc.dll as reference. The default setting of Spire.Doc.dll is placed under "C:\Program Files\e-iceblue\Spire.Doc\Bin". Select assembly Spire.Doc.dll and click OK to add it to the project.

[C#]
using System;
using Spire.Doc;
using Spire.Doc.Fields;
using Spire.Doc.Documents;

namespace TableWidth
{
    public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();
        }
        private void button1_Click(object sender, EventArgs e)
        {
        }
    }
}
[VB.NET]
Imports Spire.Doc
Imports Spire.Doc.Fields
Imports Spire.Doc.Documents

Namespace TableWidth
	Public Partial Class Form1
		Inherits Form
		Public Sub New()
			InitializeComponent()
		End Sub
		Private Sub button1_Click(sender As Object, e As EventArgs)
		End Sub
	End Class
End Namespace

Step 2Put the word document with table into the project folder. Use the following code to load it into project.

[C#]
Document doc = new Document();
            doc.LoadFromFile(@"..\..\Table.docx",FileFormat.Docx);
[VB.NET]
Dim doc As New Document()
doc.LoadFromFile("..\..\Table.docx", FileFormat.Docx)

Step 3Because Spire.Doc doesn't have a direct method to set column width, we need set the first cell width of in each row.

[C#]
            for (int i = 0; i < document.Sections[0].Tables[0].Rows.Count; i++)
            {
                document.Sections[0].Tables[0].Rows[i].Cells[0].Width = 20;
            }
[VB.NET]
For i As Integer = 0 To document.Sections(0).Tables(0).Rows.Count - 1
	document.Sections(0).Tables(0).Rows(i).Cells(0).Width = 20
Next

Step 4: Save and Preview

[C#]
document.SaveToFile(@"..\..\Sample.docx",FileFormat.Docx);
          
[VB.NET]
document.SaveToFile("..\..\Sample.docx", FileFormat.Docx)
System.Diagnostics.Process.Start("..\..\Test.pdf")

Now, the whole process is finished. Press F5 and click the button to run the project. The generated docx file can be found at the project debug folder. Check the effect.

Before Setting Width:

Word Table Column Width

After Setting Width:

Word Table Column Width

As a professional and powerful Word component, Spire.Doc doesn't need Microsoft Office Word Automation but also allows user to directly operate Word document, format and style and insert content to Word document.Click to learn more feature functions of Spire.Doc