Tuesday, 5 August 2014

Easy way for taking data in pdf file from Visual Stdio


                                                                                                                                           Next

Work with Spire.PDF for creating and writing PDF files on any .NET applications
Introduction
Spire.PDF  is a professional PDF .NET library which is  designed for .NET developers in order to create, read, write, convert and print PDF Files from any .NET Platform fast and with a high quality performance in this way of user for taking data in PDF file. And in present lot of Big organization  using this product.
This software support  C#, VB.NET,ASP.NET, AND ASP.NET MVC
Platform: Microsoft visual studio 2010 Express.
Why we use Spire.PDF

Spire.PDF is very useful software for reading, writing and editing a dot net file without using any other software. Sometimes we have huge data in our project which we would like to save in pdf format and for this we have to use some external software. Spire.PDF solves such problems. It helps to convert the dot net file to PDF file on one click.

How to Install this Spire.PDF

Step(1): First download this software from this link.
Step(2): After download double click on software After that this window will open.
Here click on next



Step(3): In next step accept the terms and condition and click on next after that a window will open where you select a feature.
If you are using a free version then this window will  open



Otherwise this window will open


Step(4): After click on next it will ask for install and this window will open

Step(5): After that install this software and use this software.

How to use this product with code.
For using this feature we have to use libraries as shown below.
using Spire.Pdf;
using Spire.Pdf.Graphics;
using Spire.Pdf.Graphics.Fonts;

These namespace are used for graphics.
Convert Text file to PDF format in C# .net
Converting a text file to PDF is very difficult in dot net. In organization they convert this text file to PDF format by using other external software.
But this is very difficult for users. For removing this problem, Spire.Pdf  make it very simple. Only we have to use some code for this.
Go to the below link and download the software.
Step(1):- First of all open your visual studio and select a console application.


Step(2):- Add library

This are some libraries which we have to use for generate PDF files
using Spire.Pdf;
using Spire.Pdf.Graphics;
using Spire.Pdf.Graphics.Fonts;

Step(3):- Code

using System.Drawing;
using System.Drawing.Text;
using Spire.Pdf;
using Spire.Pdf.Graphics;
using Spire.Pdf.Graphics.Fonts;
using System.IO;


namespace ConvertTextFile_to_pdfFile
{
    class TextFile
    {
        static void Main(string[] args)
        {
            PdfDocument PDF = new PdfDocument();
            DrawText(PDF.Sections.Add());
            PDF.SaveToFile("pdfFile.pdf");
            PDF.Close();
            System.Diagnostics.Process.Start("pdfFile.pdf");
        }

        private static void WriteTextFile(PdfSection section)
        {
            string text = File.ReadAllText(@"..\..\test.txt");
            PdfPageBase page = section.Pages.Add();
            PdfFont font = new PdfFont(PdfFontFamily.Helvetica, 11);
            PdfStringFormat format = new PdfStringFormat();
            format.LineSpacing = 20f;
            float pageWidth = page.Canvas.ClientSize.Width;
            PdfBrush brush = PdfBrushes.LightSeaGreen;
            float y = 30;
            PdfStringLayouter textLayouter = new PdfStringLayouter();
            PdfStringLayoutResult result
                = textLayouter.Layout(text, font, format, new                         SizeF(pageWidth, 0));

            foreach (LineInfo line in result.Lines)
            {
                page.Canvas.DrawString(line.Text, font, brush, 0, y, format);
                y = y + result.LineHeight;
            }
        }
    }
}


Step(4):-  Image of PDF

No comments:

Post a Comment

C# program Selection Sorting

Selection sort is a straightforward sorting algorithm. This algorithm search for the smallest number in the elements array and then swap i...