Create and manipulate PDF Documents - 100% .NET

xiaoxiao2021-03-06  97

REL = "stylesheet" type = text / css href = "http://www.codeproject.com/styles/global.css">

............................ ...CRIPLILE, TELEGEM. TECHNOLOGY.

Introduction

TallPDF.NET and PDFKit.NET are 100% .NET components written entirely in C # for creating, manipulating and reading PDF documents and PDF forms.The focus is to ease the task of integrating our component in a larger application. Th is is done by Providing a highly intuitive object model and supporting main stream technologies such xml / xsl and ado.net.

Download Evaluations: TallPDF.NET 2.0; Pdfkit.net 1.0 (Fully functional, does not expire)

View Demos Online: Create Invoice on The Fly; Create Business Card on The Fly

TallPDF.NET 2.0

TallPDF.NET is a 100% managed .NET component for dynamically creating documents from scratch. This component is typically deployed as part of an ASP.NET application that generates dynamic PDF from a data source or user input. However, it is just as well Possible to integrate tallpdf.net in a deskpdf.net is a highly intuitive object model consisting of classes like document, section, paragraph, table, footer, etc.

You can create documents either programmatically or from XML. When generating PDF from XML, classes are represented by elements and properties by attributes or child elements. You typically write an XSL file to transate your own specific XML documents to the TallPDF.NET XML format. Using the non-cached forward-only characteristics of the XmlReader class, you can pipeline these steps and achieve extremely low memory consumption, completely independent of document size. This makes TallPDF.NET an excellent solution for generating both small and very large documents.Features

PDF Featuresbookmarks; document properties; internal cross-references; external cross-references Text Formattingtext color; single and double strike-through; single and double underline; sub- and superscript; left, right and center alignment; justification; hyperlinking Page Layoutvertical alignment; relative positioning (flow layout); absolute positioning (grid layout); mix grid and flow layout; keep-with-next constraints; do-not-break constraints Tablescolspan; vertical and horizontal cell alignment; nest tables; fit-to-content; borders; backgrounds; repeat one or more header rows Generationdeclarative or event-driven; flash-out pages while generating; from XML using the forward-only XmlReader class; from ADO.NET using a forward-only database cursorImagesBMP, GIF, JPEG, TIFF , PNG, DCT (JPG) and Flate compressiom; multipage TIFF; from file, memory or System.Drawing.BitmapDocument Layoutdivide a document into sections; assign headers and footer to each section; standard page size; dist inguish between first, middle, last, odd and even headers / footersFonts14 standard PDF fonts; TrueType subset embedding; Unicode; support for Japanese, Cyrillic, Hebrew, Arabic, etc.Encryptionweak and strong passwords; restrict privileges such as allow print / copyDrawinglines, Rectangles, Ellipses, Pies, Arcs, Images, Text, Brushes and Pens, Draw Inside Relative, Draw ON Entire Page As a canvasgenerate PDF ProgramMAASgenerate

.

<% @ Page language = "c #"%>

<% @ Import namespace = "TallComponents.pdf.Layout"%>

<%

// Create a new instance of the tallpdf.net document Document

Document doc = new document (); // add a section to the document

Section section = new section ();

Doc.sections.add (section);

// Add a text paragraph to the section

TextParagraph TextParagraph = new textparagraph ();

Section.Paragraphs.Add (TextParagram);

// Add a piece of text to the text paragraph

Fragment fragment = new fragment ();

TextParaGraph.fragments.Add (Fragment);

Fragment.text = "Hello World!";

// stream out the pdf Directly to the Browser

Doc.write (response);

%>

Generate PDF from XML

The central idea of ​​TallPDF.NET is that you can build an instance of the TallPDF DOM and that you can save that instance to PDF. Instead of building a DOM instance programmatically, you can also load it from XML. There is no difference between a Dom Instance Loaded from XML and One That Has Been Constructed ProgramMAAMATILY.

The Following Code Sample Show a Typical XML File and how it it is converted to pdf.

// Create An XMLDocument and load it

XMLDocument XML = New XmLDocument ();

Xml.Load ("TOPDF.XML");

// Create a PDF Document and Initialize It from XML

Document Document =

New Document (); Document

.Read (xml.documentelement);

// stream out the pdf to file

FileStream file = new filestream ("out.pdf", filemode.create;

Document.write (file);

Use xsl to transform any xml document to PDF

The Following Code Sample Shows How The Use An Xsl To Transform An EXISTING XML TO PDF:

// load the xml

XMLDocument XML = New XmLDocument ();

Xml.Load ("DATA.XML");

// load the xsl

Xsltransform XSL = New xsltransform ();

XSL.Load ("Transform.xsl");

// transform the xml using the xsl

XmlReader Reader = xsl.transform (XML, NULL);

// Create a new pdf document and initialize if from the transformed XML

Document Document = New Document ();

Document.read (Reader);

// stream out the pdf to file

FileStream file = new filestream ("out.pdf", filemode.create;

Document.write (file);

Pdfkit.net 1.0

PDFKit.NET allows you to split, append, stamp, encrypt PDF documents and fill PDF forms. PDFKit.NET is a 100% managed .NET component for manipulating PDF documents and forms on the fly. This component is typically deployed as part of an ASP.NET application, however, it is just as well possible to integrate PDFKit.NET in a desktop application. Central to PDF.NET is a highly intuitive object model consisting of classes like Pages, Page, Overlay, Underlay, Shapes and Fields.

FEATURES

Split and Appendcreate a new document; get single or multiple pages from an existing PDF document; combine existing and new page to cretae a new documentForm filling (multiline) text fields, check boxes, radio button, list boxes and combo boxes, read position and size of fields, flatten, remove or preserve fieldsSecurity / Encryption40 and 128 bit encryption; consume encrypted documents; set user and owner password; set user privileges such as allow print / copyStampingmultiline text (alignment, justification, multiple fonts, etc); hyperlinks; primitive shapes such as Line, Pie, Rectangle, Image; position, rotate and scale shapesGeneralwrite to disk, memory or directly to an HTTP response; read from disk or memory; constant, low memory consumption, independent of document size

Filling PDF Forms

.................................................. ...CRIPLILE, APPLIED ECOLOGY.

A field is represented by the Field class. You can query the field for its type (text box, radio button, etc), its position and size and various attributes such as 'multiline' and 'read-only'. If a field represents A Selection Control Such As a Combo Box or Radio Button Group, You Can Also Enumerate The Options. Finally You Can Fill A Field by Setting ITS Value Property and Flatten IT by Setting The Flatten Property.

// Open an existing PDF Form

FILESTREAM FILE = New FileStream ("form.pdf", filemode.open, fileaccess.read;

Document Document = New Document (New BinaryReader (File);

// Retrieve Field

Page Page = document.pages [0];

Field Field = Page.fields ["Lastname"];

/// Fill Out Field and Flatten IT

Field.Value = "john smith";

Field.flatten = true;

// stream the filled pdf form directly to the Browser

Response.ContentType = "Application / PDF";

Document.write (New BinaryWriter (response.outputStream);

Stamping PDF Documents

PDFKit.NET allows you to open an existing PDF document and retrieve each page by index A page is represented by a Page class This class exposes 2 layers:... An overlay and an underlay You can draw on each of these layers by adding shapes To it. pdfkit.net provides a large set of primitive shapes such as line, pie, rectangle, text, image (bmp, jpeg, etc.). Each Shape can be located Anywhere on the page, rotated by any angle and scaled.

// Open an existing PDF Document

FILESTREAM FILE = New FileStream ("in.pdf", filemode.open, fileaccess.read; Document Document = New Document (New BinaryReader (File);

// Stamp Blue Verdana Text over Existing Content

Textshape text = New Textshape (10, 300, "John Smith",

Font.TrueType ("Verdana.ttf"), 10, Color.Blue;

Page.overlay.add (text);

// stream the filled pdf form directly to the Browser

Response.ContentType = "Application / PDF";

Document.write (New BinaryWriter (response.outputStream);

Splitting and combining pdf docuuments / pages

After You Have Opened A Pages from It and Use The To Build A New Document. You CAN Append Pages That Originate from Different Documents.

// Open existing documents

FileStream file1 = new filestream ("x.pdf", filemode.open, fileaccess.read;

Document Source1 = New Document (New BinaryReader (File1));

FileStream file2 = new filestream ("y.pdf", filemode.open, fileaccess.read;

Document Source2 = New Document (New BinaryReader (file2));

// Create a new, EMPTY Document

Document Target = New Document ();

// Append Pages from the existing documents

Target.pages.Append (Source1.pages [4]);

Target.pages.Append (Source2.pages [30]);

Target.pages.Append (Source1.pages [45]);

Target.pages.Append (Source2.pages [230]);

// stream the New Pdf Document Directly to the Browser

Response.ContentType = "Application / PDF";

Target.write (New BinaryWriter);

About Frank REM

转载请注明原文地址:https://www.9cbs.com/read-95996.html

New Post(0)