Initial experience using Spire.office for. NET (Word, Excel, PPT, PDF, etc.)

Source: Internet
Author: User
Tags watermark images

Objective

Most of this article comes from Http://www.codeproject.com/Articles/710747/First-thoughts-on-Spire-Doc-for-NET.

For me personally, there is little demand for office automation. But as a developer, it's a good idea to have a library tool if there's a need. Some time ago, one of E-iceblue's sales staff contacted me, hoping that I could help them spire.office do a test. First of all, I'm glad they found me, and it also gives me an opportunity to get in touch and learn new technology, and I'm very grateful to E-iceblue's staff. Their official website is http://www.e-iceblue.com/.

Spire.office for. NET is a compiled, enterprise-class. NET component that is provided by E-iceblue. It contains the Spire.doc,spire xmls,spire.presentation,spire.pdf,spire.dataexport, Spire.pdfviewer, Spire.DocViewer, and Spire.BarCode.Spire.Office contains the latest version based on. Net components.

With Spire.office for. NET, developers can create a wider range of applications. It enables developers to open, create, modify, convert, print, view Microsoft Word, excel,powerpoint,pdf documents. In addition, it allows users to export data to popular files such as Ms Word/excel/rtf/access,powerpoint, Pdf,xps, Html,xml, Text, CSV, DBF, clipboard clipboard, SYLK etc.

One of the most independent office. NET components, Spire.office does not require the installation of Microsoft Office files on the system. In addition, it is a better alternative to Microsoft Office Automation in terms of security, stability, scalability, speed, price and functionality.

Spire.office for. NET can be linked to any type of 32-bit or 64-bit. NET application, which includes applications such as Asp.net,web services and WinForms based on the. NET Framework 2.0 through 4.5.

Here I will briefly introduce the next Spire.doc and spire.pdf, about my simple introduction to use a situation.

Spire.doc for. NET

Spire.doc for. NET is a professional word. NET Library that developers can use in any of the tools. NET quality Platform (c#,vb.net,asp.net) to quickly create, read, write, convert, and print Word document files. As a standalone word component, spire.doc for. NET does not require Microsoft Word to be installed on your machine. Moreover, it can integrate Microsoft Word document creation into any developer's. NET application.

How to get it?

First you can enter the official website http://www.e-iceblue.com/

Then you can click on the components you need, such as the Spire.doc for. NET I need now, and then you can download and eventually buy Spire.doc from their website.

Once downloaded, you will find an MSI installation file.

The Spire.doc installation package is a clean, professional MSI installer. The first few dialog boxes are some hints and license agreements. By the way, who will read all the warning messages? However, if you are a company that is prepared to invest and use the product for commercial purposes, read the license agreement of any software company.

Installing the SPIRE.DCO package only uses 180M of space.

The MSI installation option provides comprehensive information, including:

1. Install components (multiple components that support different versions of the. NET framework)

2. Install demo and source code

3. Install the file on the developer's Local machine

4. Adding components to the Reference dialog box in Visual Studio

After the installation is complete, the developer must manually add the referenced assembly. Here you can install the files locally with the help of Windows HTML.

Create a Word document

Many years ago, we faced the problem of finding an effective way to insert formatted text into a document. Specifically, you want to create a multi-paragraph, multi-text, Word document that contains special formatting.

Let's use Spire.doc to create a familiar Word document that says Hello World. The following are the specific steps:

1. I created a console-enabled application with VS2012

2. In Solution Explorer (Solution Explorer), add a new reference (reference) to Spire.Doc.dll (under the bin path after installing the MSI)

3. I want to see Spiral.doc's naming convention as consistent with my intuition. So I started not looking at their documents, using Object Browser to check the available interfaces. As I guess, I think something like the following code can help me build the word text I want.

        Static voidMain (string[] args) {Spire.Doc.Document Document=NewDocument (); Section Section=document.            AddSection (); Paragraph Paragraph=Section .            Addparagraph (); Paragraph. AppendText ("Hello World"); Document. SaveToFile ("Hello Wrold.doc", Fileformat.doc); Console.WriteLine ("Word document creation succeeded!");        Console.ReadLine (); }

After the compilation is successful, F5 runs

If you have a license, the evaluation Information (Evaluation Warning) disappears.

4, although we are very busy, may also let us see if it can export Word documents to PDF or HTML.

Spire.Doc.Document Document =NewDocument (); Section Section=document.            AddSection (); Paragraph Paragraph=Section .            Addparagraph (); Paragraph. AppendText ("Hello World"); Document. SaveToFile ("Hello Wrold.doc", Fileformat.doc); Document. SaveToFile ("Hello world.pdf", fileformat.pdf); Console.WriteLine ("Word document creation succeeded!"); Console.ReadLine ();

One of the world spelling mistakes, haha. Mention it will not be modified.

I am here to open a PDF file via a browser

Well, not bad, just a line of code, I can convert, my Word document is saved in PDF format. This is very handy for our developers, and almost every day jobless will require word to be converted to PDF. From my personal experience, this is one of the hottest issues on a daily forum.

5. This is one of the simplest examples, but you can also read HTML from a stream to create a Word document, insert an HTML file, format a file, or add any metadata attributes to a Word document.

Supported file formats

Spire.pdf for. NET

Spire.pdf for. NET is a professional PDF document creation component developed by E-iceblue Corporation. It enables users to use. NET applications to read, write, and manipulate PDF documents without Adobe Acrobat and other external controls. Spire.pdf for. NET can be used not only on the server side, such as asp: or other environments, but also in Windows Forms applications. Spire.pdf for. NET is suitable for use in all common bad environments, such as: Created PDF documents can be stored on disk, and can be saved as data streams in the Windows Forms application, ASP.

Spire.pdf for. NET feature Rich. In addition to the basic functions such as: Draw a variety of graphics, pictures, create form fields, insert header footer, input data table, automatically paging large tables, spire.pdf for. NET also supports PDF digital signatures, converting HTML into PDF format, extracting text information and images from PDF documents, saving them in text format and various image formats, and even extracting attachments from PDFs.

Key Features
1. Support embedded fonts, Truetype fonts and CJK fonts.

2, support the drawing. For example: Rectangle, Ring, arc, oval, or you can customize the brush to fill it.

3. You can load a picture from a data stream, a disk file, into a PDF document. You can draw both ladder and vector images in PDF documents, as well as mask and watermark images.

4. You can load a data sheet into a PDF document. You can format rows and columns in a table, and you can include graphic elements within a table.

5. Automatic paging of large tables in PDFs.

6. Create a form field. For example, create buttons, text boxes, list boxes, check boxes, and so on in PDF documents.

7. Insert the header and footer in the PDF.

8. Encrypt the PDF document by setting the owner password and user password.

9, the author's signature to protect the PDF document.

10. Read the table of the current PDF document and populate the table.

11. HTML pages are split into large pages when they are converted to PDF documents, which can be displayed in PDF documents without any truncation of text at the page of the PDF document. Users can also convert these pages directly to a data stream without needing temporary files to create PDF documents.

12, etc.

Let's create a PDF file below.

1. Create another console Application project

2, add Spire.pdf Reference, this time I through the NuGet plugin to add

Here's the code to make a simple PDF

    classProgram {Static voidMain (string[] args) {            ///1. Create a PDF documentPdfdocument doc =Newpdfdocument (); Pdfunitconvertor UNITCVTR=NewPdfunitconvertor (); Pdfmargins margin=NewPdfmargins (); Margin. Top= Unitcvtr.convertunits (2.54f, Pdfgraphicsunit.centimeter, Pdfgraphicsunit.point); Margin. Bottom=margin.            Top; Margin. Left= Unitcvtr.convertunits (3.17f, Pdfgraphicsunit.centimeter, Pdfgraphicsunit.point); Margin. Right=margin.                        Left; //2. Create a margin page for the PDF defined abovePdfpagebase page =Doc.                        Pages.Add (pdfpagesize.a4, margin); ///3. Insert a background imageSystem.Drawing.Image img = System.Drawing.Image.FromFile (@"1.png"); Page. BackgroundImage=img; ////4, add watermarkPdftilingbrush Brush=NewPdftilingbrush (NewSizeF (page. Canvas.ClientSize.Width/2, page. Canvas.ClientSize.Height/3)); Brush. Graphics.settransparency (0.3f); Brush.            Graphics.save (); Brush. Graphics.translatetransform (brush. Size.width/2, Brush. Size.Height/2); Brush. Graphics.rotatetransform (- $); Brush. Graphics.DrawString ("Www.cnblogs.com/aehyok",                NewPdffont (Pdffontfamily.helvetica, -), Pdfbrushes.violet,0,0,                NewPdfstringformat (Pdftextalignment.center)); Brush.            Graphics.restore (); Brush. Graphics.settransparency (1); Page. Canvas.drawrectangle (Brush,NewRectangleF (NewPointF (0,0), page.            Canvas.clientsize)); floaty =Ten; //5. Set the titlePdfbrush BRUSH1 =Pdfbrushes.black; Pdftruetypefont Font1=NewPdftruetypefont (NewFont ("Arial", 16f, FontStyle.Bold)); Pdfstringformat FORMAT1=NewPdfstringformat (Pdftextalignment.center); Page. Canvas.drawstring ("Country List", Font1, BRUSH1, page. Canvas.ClientSize.Width/2, y, FORMAT1); Y= y + font1. MeasureString ("Country List", FORMAT1).            Height; Y= y +5; ////6. Define table meta-datastring[] data = {                "Name; capital; Continent; area; Population",                "Argentina; Buenos Aires; South america;2777815;32300003",                "Bolivia; La Paz; South america;1098575;7300000",                "Brazil; Brasilia; South america;8511196;150400000",                "Canada;ottawa; North america;9976147;26500000",                }; String[][] DataSource=NewString[data.            Length][];  for(inti =0; I < data. Length; i++) {Datasource[i]= Data[i]. Split (';'); }            ///7. Draw Table Binding Datapdftable table =Newpdftable (); Table. Style.cellpadding=2; Table. Style.headersource=pdfheadersource.rows; Table. Style.headerrowcount=1; Table. Style.showheader=true; Table. DataSource= DataSource;///directly binding the data sourcePdflayoutresult result = table. Draw (page,NewPointF (0, y)); Y= y + result. Bounds.height +5; Pdfbrush Brush2=Pdfbrushes.gray; Pdftruetypefont Font2=NewPdftruetypefont (NewFont ("Arial", 9f)); Page. Canvas.drawstring (String.Format ("* {0} countries in the list.", data. Length-1), Font2, Brush2,5, y); //8. Save the fileDoc. SaveToFile ("simpletable.pdf"); Doc.            Close (); ///9. Open the file you just madeSystem.Diagnostics.Process.Start ("simpletable.pdf"); }    }
View Code

After running the

You can find a few simple elements

1. Background image

2, the Watermark added

3. Table Le

Overall, I was impressed by the functionality and ease of use offered by this product. Although it is not always as much as I want to do, this may also be due to my lack of understanding of how the Spire.office component works correctly.

Tips for English

1. Susan: Excuse me! I am new to the campus. Know where the student cafeteria is?—— excuse me. I'm a freshman. Do you know where the school cafeteria is?

2. Kathy: sure! Do you have a map?—— of course!

3. Susan: Yes, here it is.--there. The map is here.

4. Kathy: Let's See--here ' s where we are right now. To get to the cafeteria, you'll need to cross this square and go to the south.--I'll take a look--here's where we are now. to the cafeteria. You have to go through the square and walk south.

5, Susan: ok--good.

6, Kathy: And then the cafeteria are about five hundred yards past the gym, on your left. You'll see a sign in front of the building.--cafeteria is at about 500 yards past the gym. Right on your left. You will be seen in front of the building.

7, Susan: No Wonder I got lost. I was heading in the wrong direction! Anyway, thanks a lot for your help.--no wonder I'm lost. I'm going in the wrong direction. Thank you very much for your help, anyway.

8, Kathy: No problem. Good luck!—— you're welcome. Good luck.

Aehyok

Source: http://www.cnblogs.com/aehyok/

Thank you for your reading, if you are interested in the content of my blog, it is advisable to point a recommendation, thank you for supporting:-O.

Sample Code Http://url.cn/S7Znij

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.