Giter VIP home page Giter VIP logo

pdffilewriter's Introduction

PdfFileWriterII

Version 2.0.0 2022/02/01

The PDF File Writer II C# class library allows you to create PDF files directly from your .NET application. The library shields you from the details of the PDF file structure. This version of the PDF File Writer library was developed using Visual Studio 2022.

Please note these settings of the PdfFileWriter library properties:

Target framework: .NET 6.0

Target OS: Windows

Platform target: Any CPU

Nullable: Disable

Implicit global using: checked

Documentation file: checked

Package license: SPDX License Expression

License expression CPOL-1.02

Require license acceptance: not-checked

The repository is made of Visual Studio 2022 solution with two projects. A C# class library project and a test or demo project. If you want to create PDF documents from your project, you need to include the library with your code or include all the library sources with your application.

This project is a major revision of the original PDF File Writer published at Code Project website. Most of the source code is very similar. However, the two libraries are not compatible. There were many changes to classes and methods naming and calling sequences. For further information of the original project visit PDF File Writer C# Class Library (Version 1.28.0)

The most significant change to the library is the addition of PDF Forms.

The folder Examples has a number of PDF files showing the power of this library. The test and demo program TestPdfFileWriter produces these PDF files. All the source code is included. If you are looking for a particular feature, look through these examples. Once you find a close match go to the relevant source code to see how it is done.

I am working on rewriting the original article at Code Project, but it is not ready for publication yet.

Hello PDF File Writer program

A very simple example of creating a PDF document with one line of text and one image.

// create PDF document
public void CreatePdfDocument()
  {
  // Create empty document
  using(PdfDocument Document = new PdfDocument(PaperType.Letter, false, UnitOfMeasure.Inch, "HelloPdfDocument.pdf"))
    {
    // Add new page
    PdfPage Page = new PdfPage(Document);

    // Add contents to page
    PdfContents Contents = new PdfContents(Page);

    // create font
    PdfFont ArialNormal = PdfFont.CreatePdfFont(Document, "Arial", FontStyle.Regular, true);
    PdfDrawTextCtrl TextCtrl = new PdfDrawTextCtrl(ArialNormal, 18.0);
				
    // draw text
    TextCtrl.Justify = TextJustify.Center;
    Contents.DrawText(TextCtrl, 4.5, 7, "Hello PDF Document");

    // load image
    PdfImage Image = new PdfImage(Document);
    Image.LoadImage("..\\..\\..\\HappyFace.jpg");

    // draw image
    PdfDrawCtrl DrawCtrl = new PdfDrawCtrl();
    DrawCtrl.Paint = DrawPaint.Fill;
    DrawCtrl.BackgroundTexture = Image;
    Contents.DrawGraphics(DrawCtrl, new PdfRectangle(3.5, 4.8, 5.5, 6.8));

    // create pdf file
    Document.CreateFile();
    }

  // start default PDF reader and display the file
  Process Proc = new Process();
  Proc.StartInfo = new ProcessStartInfo("HelloPdfDocument.pdf") { UseShellExecute = true };
  Proc.Start();
  }
  

pdffilewriter's People

Contributors

uzi-granot avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.