pdf links

PDF Rendering
Convert PDF to Image (.NET)
Convert PDF to image on Android (Xamarin)
Convert PDF to image on iOS (Xamarin)
Convert PDF to image in Windows Store apps (.NET)
Convert PDF to image in Windows Phone apps (.NET)
PDF to image in Universal Windows Store apps (.NET)
Free PDF Viewer control for Windows Forms (.NET)
How to integrate PDF Viewer control in WPF app (.NET)
Creating WPF PDF Viewer supporting bookmarks (.NET)
Cross-platform PDF Viewer using GTK# (MONO)
Silverlight PDF viewer control (Silverlight 5)
Multithreaded PDF rendering (.NET)
Convert pdf to image in Silverlight app (C# sample)
How to set fallback fonts for PDF rendering (C#)
Avoiding the out-of-memory exception on rendering (C#)
PDF viewer single page application (WebAPI, AngularJS)
PDF viewer control for Windows 10 universal applications
Use custom ICC profile for CMYK to RGB conversion
PDF layers - separate images, text, annotations, graphics

PDF Forms Creation PDF Security
Conversion to PDF/A
Other topics
PDF Document Manipulation PDF Content Generation
Fixed and Flow layout document API (.NET)
Creation of grids and tables in PDF (C# sample)
How to create interactive documents using Actions (C# sample)
Text flow effects in PDF (C# sample)
How to generate ordered and bulleted lists in PDF (C# sample)
Convert HTML to PDF using flow layout API (C# sample)
How to use custom fonts for PDF generation (.NET)
Create document with differently sized pages (C#)
Create PDF documents using MONO (C#/MONO/Windows/OSX)
How to use background images for content elements (C#/PDF Kit/FlowLayout)
Add transparent images to PDF document (C#)
Draw round rect borders in PDF documents(C#)
ICC color profiles and and ICC based colors in PDF (C#)
How to use bidirectional and right to left text in PDF (C#)
Create PDF documents from XML templates (C# sample)
How to resize PDF pages and use custom stamps (C#)
Add header and footer to PDF page (.NET sample)
How to use clipping mask for drawing on PDF page
Fill graphics path with gradient brushes in PDF (Shadings)
Apitron PDF Kit and Rasterizer engine settings
Add layers to PDF page (optional content, C# sample)
How to create free text annotation with custom appearance
PDF Content Extraction PDF Navigation
PDF to TIFF conversion
Contact us if you have a PDF related question and we'll cover it in our blog.

2014-12-25

Create, read, edit and sign PDF documents using single .NET component. (C# samples)

If you need a PDF .NET component providing easy-to-use and clean API then it’s time to take a look at the Apitron PDF Kit for .NET. This product is designed to help you on a way with creation, manipulation, and all kind of processing related to PDF documents. These files can be of different origin: created using all possible versions of the PDF specification and various optimization techniques, e.g. linearized or tagged PDFs.  They can also be password-protected or digitally signed, so simply speaking - everything created according to PDF specification can be processed using our component.

Apitron PDF Kit for .NET is a fully managed .NET library that supports literally all features defined for PDF by Adobe, assemblies are available for any .NET framework version starting from 2.0 and it also works on Mono and Xamarin.  Xamarin Studio + Apitron PDF Kit can be used to create PDF processing apps running on OS X for example. Futhermore it's possible to create apps for iOS and Android using Xamarin.iOS and Xamarin.Android. Files created using this component can be viewed on all platforms and devices where a decent PDF viewer exists (and furthermore we have own viewer and rasterizer components as well).

Using this component you’ll be able to:


  • Extract, modify and add graphics (text, images, drawings)
  • Split or merge PDF documents
  • Fill or create PDF forms
  • Add or remove document fields
  • Examine resources within a document - fonts, embedded files
  • Digitally sign and check existing signatures on PDF documents
  • Search for specific text
  • Protect document with a password, edit its permissions
  • Work with navigation objects, e.g. create bookmarks or links
  • Control viewer settings for PDF file
  • Use full support for annotations
  • Use full support for PDF actions
  • Use all fonts defined by specification
  • Use various supported colorspaces and color profiles, e.g. you may draw in RGB, CMYK, gray, or whatever colorspace you like.
  • Save files to other “subtypes” of PDF – Linearized or PDF/a for example. If you require a specific functionality and are unsure about whether it is supported, please review our online help you contact support so we'll be able to handle this.
  • Use Fixed layout API, implemented to be 100% PDF specification compatible, it unlocks full power of the PDF for you. Any complex PDF creation or manipulation task can be completed instantly.
  • Use Flow layout API, a styles-driven content generation API similar to HTML+CSS provides you with ability to create stunning documents, reports, bills, catalogs and more in minutes. Compact and easy to use, supports creation of XML templates and much more.
  •  Create cross-platform PDF processing apps targeting Windows, iOS, Android, OS X and other systems .NET/MONO implementation exists for.

This list is rather incomplete but it gives an idea of component's capabilities. It’s also worth mentioning that we provide first-class support and response within 24h is guaranteed.

Component’s package contains many beautiful samples for both Fixed and Flow layout APIs and can be downloaded here. There are samples showing how to sign the document, draw something on PDF page, generate simple report using grid, set document password and more. Whenever you have a need, all developer guides and component's documentation are available online on our website.

Below I’m going to show you a simple “Hello world” PDF creation sample:

The code


/// <summary>
/// "Hello World" PDF generation sample, flow layout.
/// </summary>       
class Program
{
    static void Main(string[] args)
    {
        ResourceManager resourceManager = new ResourceManager();
           
        // create document and set margin
        FlowDocument document = new FlowDocument() { Margin = new Thickness(5)};

        document.Add(new TextBlock("Hello world with Apitron PDF Kit for .NET!") { Font = new Font(StandardFonts.Helvetica,20)});
         
        string fileName = "HelloWorld.pdf";

        // save and open
        using (Stream stream = File.Create(fileName))
        {
            document.Write(stream, resourceManager, new PageBoundary(Boundaries.A4));
        }

        Process.Start(fileName);
    }
}


Result


Generated "Hello world" PDF


Similar sample demonstrating Fixed layout API

The code


/// <summary>
/// This sample shows how to draw a simple rect on PDF page.
/// </summary>
class Program
{
    private static void Main(string[] args)
    {
        string fileName = "rectangle.pdf";

        // open and load the file
        using (FileStream fs = new FileStream(fileName, FileMode.Create))
        {
            // this object represents a fixed PDF document
            FixedDocument document = new FixedDocument();
            Page page = new Page(new PageBoundary(Boundaries.A4));

            // create colorspace resource
            string rgbID = "CS_RGB";
            document.ResourceManager.RegisterResource(new RgbColorSpace(rgbID));

            // set fill color
            page.Content.SetNonStrokingColorSpace(rgbID);
            page.Content.SetNonStrokingColor(0.33, 0.66, 0.33);
               
            // define the rectangle
            FixedLayout.Content.Path path = new FixedLayout.Content.Path();
               
            path.AppendRectangle(200, 300, 200, 200);
            page.Content.FillAndStrokePath(path);

            // add page to the document and save
            document.Pages.Add(page);
                            
            document.Save(fs);
        }

        // preview document
        Process.Start(fileName);
    }       
}



Result


Generated PDF

We’ll continue to cover our API by providing more samples in upcoming posts, stay tuned!  Lots of samples are available already in our download package. Should you have any questions just let us know and we’ll be happy to help you. 

No comments:

Post a Comment