Monday, 05 March 2012 07:29

Export PDF Document to images

The sample demonstrates how to export PDF pages as images by PdfDocumentViewer Component.

Download PDFViewer.pdf

Published in PDF Document Viewer
Wednesday, 06 April 2011 09:47

PDF Extract in C#, VB.NET

The sample demonstrates how to extract images and text from PDF document.

(NO screenshot)

Published in Document Operation
Wednesday, 06 April 2011 06:56

PDF ImageWaterMark in C#, VB.NET

The sample demonstrates how to draw an image as watermark in PDF document.

Download ImageWaterMark.pdf

Published in WaterMark
Wednesday, 06 April 2011 05:25

PDF ImageTable in C#, VB.NET

The sample demonstrates how to export data and pictures from database into a table in PDF document and set table format.

Download ImageTable.pdf

Published in Table
Wednesday, 06 April 2011 01:41

PDF Template in C#, VB.NET

The sample demonstrates how to set PDF documentaion template, page header&footer, page number and automatic page number count.

Download Template.pdf

Published in Page
Tuesday, 05 April 2011 09:25

PDF TextLayout in C#, VB.NET

The sample demonstrates how to work with text layout in PDF document.

Download TextLayout.pdf

Published in Formating
Tuesday, 05 April 2011 07:21

PDF DrawImage in C#, VB.NET

The sample demonstrates how to draw image in PDF document.

Download DrawImage.pdf

Published in Drawing
Tuesday, 05 April 2011 06:47

PDF Image in C#, VB.NET

The sample demonstrates how to insert an image to a PDF document.

Download Image.pdf

Published in Quick Guide
Thursday, 20 January 2011 10:33

Insert Image in Excel in C#, VB.NET

Users are allowed to insert image in Excel files. With image, the appearance of Excel file will be more beautiful. Besides decorating, some images are related to data information in Excel. For example, the image will be a chart. These images can make readers learn data information more clearly. This guide will show an easy method to insert image in Excel with C#, VB.NET

Spire.XLS for .NET, a professional component to operating Excel files, enables users to insert image in Excel by using C# and VB.NET. This guide focuses on how to easily insert image in Excel by using Spire.XLS for .NET.  Developers can use sheet.Pictures.Add(int toprow, int leftcolumn, filename string) method to insert image in Excel directly. Below demonstrates an Excel with an image of flower.

Insert Excel Image

Download and install Spire.XLS for .NET and then use the following code to insert image.

[C#]
using Spire.Xls;

namespace InsertImage
{
    class Program
    {
        static void Main(string[] args)
        {
            //Create Workbook
            Workbook workbook = new Workbook();
            Worksheet sheet = workbook.Worksheets[0];

            //Insert Image
            sheet.Pictures.Add(1, 1, @"E:\work\sample.jpg");

            //Save and Launch
            workbook.SaveToFile("ExcelImage.xlsx", ExcelVersion.Version2010);
            System.Diagnostics.Process.Start("ExcelImage.xlsx");
        }
    }
}
[VB.NET]
Imports Spire.Xls

Namespace InsertImage
    Friend Class Program
        Shared Sub Main(ByVal args() As String)
            'Create Workbook
            Dim workbook As New Workbook()
            Dim sheet As Worksheet = workbook.Worksheets(0)

            'Insert Image
            sheet.Pictures.Add(1, 1, "E:\work\sample.jpg")

            'Save and Launch
            workbook.SaveToFile("ExcelImage.xlsx", ExcelVersion.Version2010)
            System.Diagnostics.Process.Start("ExcelImage.xlsx")
        End Sub
    End Class
End Namespace
Published in Image
Tuesday, 28 December 2010 07:50

Extract Images from Word in C#, VB.NET

Solution in this guide demonstrates how to extract images from an existing Word document and save them to a specified path in C# and VB.NET via Spire.Doc for .NET.

Image is one kind of document objects which belongs to paragraph items. Spire.Doc for .NET provides a DocumentObject class to store images in Document. And also provides a DocPicture class to get and set images of document. Download and Install Spire.Doc for .NET. Follow steps to extract images from Word.

  • Get each Paragraph of each Section in Document.
  • Get each DocumentObject of ChildObjects in Paragraph.
  • If the gotten DocumentObjectType is Picture, initialize a DocPicture class instance and assign the DocumentObject as value for this instance.
  • Initialize a String class instance to name extracted image instead of its original name by invoking String.Format(String format, object arg0)
  • Invoke DocPictrue.Image.Save(String, ImageFormat) method to save images.
[C#]
            //Load document
            Document document = new Document(@"E:\Work\Documents\WordDocuments\Spire.Doc for .NET.docx");
            int index = 0;

            //Get Each Section of Document
            foreach (Section section in document.Sections)
            {
                //Get Each Paragraph of Section
                foreach (Paragraph paragraph in section.Paragraphs)
                {
                    //Get Each Document Object of Paragraph Items
                    foreach (DocumentObject docObject in paragraph.ChildObjects)
                    {
                        //If Type of Document Object is Picture, Extract.
                        if (docObject.DocumentObjectType == DocumentObjectType.Picture)
                        {
                            DocPicture picture = docObject as DocPicture;

                            //Name Image
                            String imageName = String.Format(@"images\Image-{0}.png", index);

                            //Save Image
                            picture.Image.Save(imageName, System.Drawing.Imaging.ImageFormat.Png);
                            index++;
                        }
                    }
                }
            }
[VB.NET]
            'Load document
            Dim document As New Document("E:\Work\Documents\WordDocuments\Spire.Doc for .NET.docx")
            Dim index As Integer = 0

            'Get Each Section of Document
            For Each section As Section In document.Sections
                'Get Each Paragraph of Section
                For Each paragraph As Paragraph In section.Paragraphs
                    'Get Each Document Object of Paragraph Items
                    For Each docObject As DocumentObject In paragraph.ChildObjects
                        'If Type of Document Object is Picture, Extract.
                        If docObject.DocumentObjectType = DocumentObjectType.Picture Then
                            Dim picture As DocPicture = TryCast(docObject, DocPicture)

                            'Name Image
                            Dim imageName As String = String.Format("images\Image-{0}.png", index)

                            'Save Image
                            picture.Image.Save(imageName, System.Drawing.Imaging.ImageFormat.Png)
                            index += 1
                        End If
                    Next docObject
                Next paragraph
            Next section

After debugging, all the extracted images are saved in a specified path. Open the directory, the images will be found.

Extract Word Image

Spire.Doc, an easy-to-use component to operate Word document, allows developers to fast generate, write, edit and save Word (Word 97-2003, Word 2007, Word 2010) in C# and VB.NET for .NET, Silverlight and WPF.

Published in Image and Shape
Page 1 of 2