Ultimate PDF Component for .NET http://www.pdfcomponent.net How to use PDF Component in C#, VB.NET and ASP.NET posterous.com Wed, 09 Feb 2011 10:13:00 -0800 Adding and removing a new page http://www.pdfcomponent.net/adding-and-removing-a-new-page http://www.pdfcomponent.net/adding-and-removing-a-new-page

Creating a page 


Firstly, you need to load an existing document by using the PdfImportedDocument class and then add a new page to the loaded document by calling doc.Pages.Add method. The following example illustrates how to do that.

C#

PdfImportedDocument lDoc = new PdfImportedDocument("myfile.pdf"); PdfPage page = lDoc.Pages.Add() as PdfPage; // Use the predefined fonts to draw the text. PdfFont font = new PdfStandardFont(PdfFontFamily.Helvetica, 10.0f, PdfFontStyle.Regular); PdfGraphics g = page.Graphics; g.DrawString("My Text", font, PdfBrushes.Black, PointF.Empty); lDoc.Save("AddNewPages.pdf"); lDoc.Close();

VB.NET

Dim lDoc As New PdfImportedDocument("myfile.pdf") Dim page As PdfPage = TryCast(lDoc.Pages.Add(), PdfPage) ' Use the predefined fonts to draw the text. Dim font As PdfFont = New PdfStandardFont(PdfFontFamily.Helvetica, 10.0F, PdfFontStyle.Regular) Dim g As PdfGraphics = page.Graphics g.DrawString("My Text", font, PdfBrushes.Black, PointF.Empty) lDoc.Save("AddNewPages.pdf") lDoc.Close()

Removing a page 


You can also remove pages from the existing PDF document by using the Remove or RemoveAt methods of the PdfImportedPageCollection class.


The following code example illustrates this.

C#:

PdfImportedDocument lDoc = new PdfImportedDocument("myfile.pdf"); // Remove the first page. lDoc.Pages.RemoveAt(0); lDoc.Pages.Remove(lDoc.Pages[0]); lDoc.Save("AddNewPages.pdf"); lDoc.Close();

VB.NET

Dim lDoc As New PdfImportedDocument("myfile.pdf") ' Remove the first page. lDoc.Pages.RemoveAt(0) lDoc.Pages.Remove(lDoc.Pages(0)) lDoc.Save("AddNewPages.pdf") lDoc.Close()

Permalink | Leave a comment  »

]]>
http://files.posterous.com/user_profile_pics/1901417/Logo.jpg http://posterous.com/users/5AqhTle47UWJ ATP Incorporated ATP Inc ATP Incorporated
Mon, 16 Aug 2010 00:49:00 -0700 ComponentSoft Introduces Ultimate PDF for .NET http://www.pdfcomponent.net/componentsoft-introduces-ultimate-pdf-for-net http://www.pdfcomponent.net/componentsoft-introduces-ultimate-pdf-for-net

Ultimate PDF for .NET is a 100%-managed PDF document component that helps you to add PDF capabilities in your .NET applications. With a few lines of code, you can create a complex PDF document from scratch or load an existing PDF file. In addition to the ease-of-use and flexibility, Ultimate PDF component also offers many features including: drawing text, image, tables and other shapes, compression, hyperlinks, security and custom fonts. PDF files created using the Ultimate PDF component are compatible with all versions of Adobe Acrobat and the free version of Acrobat Viewer from Adobe.

Sample Usage - Drawing a string

C#

const PdfFontStyle fontStyle = PdfFontStyle.Regular; const float fontSize = 12.0f; // Create a new PDF document. This object represents the PDF document. PdfDocument pdfDoc = new PdfDocument(); // Add a page to the document PdfPage page = pdfDoc.Pages.Add(); // Use the predefined fonts to draw the text. PdfFont font = new PdfStandardFont(PdfFontFamily.Helvetica, fontSize, fontStyle); // Draw the string at the specified coordinates. page.Graphics.DrawString("Hello World", font, PdfBrushes.Black, 0, 0); // Save the PDF document to disk. pdfDoc.Save("HelloWorld.pdf"); // Use the following code to stream the document to the browser. // pdfDoc.Save("HelloWorld.pdf", Response, // HttpResponseType.OpenInsideBrowser); // Response is an HttpResponse object. // Close the document. pdfDoc.Close();

VB.NET

Const fontStyle As PdfFontStyle = PdfFontStyle.Regular Const fontSize As Single = 12.0F ' Create a new PDF document. This object represents the PDF document. Dim pdfDoc As New PdfDocument() ' Add a page to the document Dim page As PdfPage = pdfDoc.Pages.Add() ' Use the predefined fonts to draw the text. Dim font As PdfFont = New PdfStandardFont(PdfFontFamily.Helvetica, fontSize, fontStyle) ' Draw the string at the specified coordinates. page.Graphics.DrawString("Hello World", font, PdfBrushes.Black, 0, 0) ' Save the PDF document to disk. pdfDoc.Save("HelloWorld.pdf") ' Use the following code to stream the document to the browser. ' pdfDoc.Save("HelloWorld.pdf", Response, ' HttpResponseType.OpenInsideBrowser); ' Response is an HttpResponse object. ' Close the document. pdfDoc.Close()

Supports many .NET Platforms

Ultimate PDF Component for .NET supports the following platforms:

  • Windows Forms
  • Web Forms
  • Web Services

In addition, it is also possible to use the component in PowerShell - Microsoft’s new command console and scripting language.

Ultimate PDF is fully compatible with Visual Studio 2005 and Visual Studio 2008, as well as upcomming release of Visual Studio 2010. As a benefit, you are always up-to-date with Microsoft's Technologies when using our products.

Flexibility

The PDF component can be used with a wide variety of programming languages and different types of development environments. As it was written in 100% managed Visual C#, it is fully supported by languages such as Visual Basic, Visual C#, J#, Managed C++, Borland C# Builder, and Delphi.

Fully Documented

We know that no product can be complete without comprehensive documentation. This is why the Ultimate PDF for .NET product includes a Developer's Guide and a complete Technical Reference which documents every property, method and event supported by the component. A context-sensitive online help is included with the product which can be accessed directly from within the development environment.

Lots of complete PDF samples in VB.NET, C#, and ASP.NET

In addition to the fully documented Developer's Guide and a complete Technical Reference, Ultimate PDF component also includes a number of samples with full source code which help you to become familiar with the features of the component and provide code which you can re-use in your own applications.

Royalty-free and Unlimited Server Deployment

All ComponentSoft products include royalty-free distributation, for unlimited site deployment. It means applications built using the Ultimate PDF component can be redistributed to as many end-users as needed without additional royalties or runtime licensing fees.

Permalink | Leave a comment  »

]]>
http://files.posterous.com/user_profile_pics/1901417/Logo.jpg http://posterous.com/users/5AqhTle47UWJ ATP Incorporated ATP Inc ATP Incorporated