Category: Tutorials

How to Edit an Existing PDF Document

This sample shows how to open existing PDFm edit and re-save it using PDFMosaic library. C# : using PDFMosaic;using System; namespace EditAndSave{  class EditAndReSave  {    static void Main(string[] args)    {      PDFDocument document = new PDFDocument(“document.pdf”); // Open existing PDF document      PDFCanvas canvas = document.Pages[0].Canvas;       PDFFont font = new PDFFont(“Arial”, 16);      PDFBrush brush = new PDFSolidBrush();       canvas.DrawString(“The document was changed!!”, font, brush, 100, …

Continue reading

How to Create a New PDF Document

1. Start Visual Studio IDE. Create a new project or open existing one. 2. Add a reference to PDFMosaic.dll by opening the Add Reference dialog and selecting the PDFMosaic assembly from the list of the .NET assemblies.   C# : using PDFMosaic;using System; namespace GettingStarted{  class GettingStarted  {    static void Main()    {      LicenseManager.SetLicenseData(“demo@demo”, “demo”);       PDFDocument document = new PDFDocument();      PDFPage page …

Continue reading

How to Create a PDF with PDF Mosaic on a Web Server (ASP.NET)

You may use any Web server and any library to handle writing to an output stream. You can use to write binary data to the Response in ASP.NET. (Different libraries may provide different ways for writing out data) C# : using PDFMosaic;using System;using System.IO;using System.Web.UI; namespace CreatePDFonWebServer{  class CreatePDFonWebServer  {    static void Main(string[] args)    {      // Create pdf object      PDFDocument document …

Continue reading

How to Write Text in a PDF Document

This sample shows how to draw text on a canvas.To draw text on a canvas, use PDFCanvas.DrawString. C# : using PDFMosaic;using System.Drawing; namespace DrawText{  class DrawText  {    static void Main(string[] args)    {      PDFDocument document = new PDFDocument();      document.Pages.Add(new PDFPage(PDFPaperFormat.A4));      PDFCanvas canvas = document.Pages[0].Canvas;       PDFFont font = new PDFFont(“Arial”, 16);      PDFBrush brush = new PDFSolidBrush();       canvas.DrawString(“The test string”, font, brush, 100, 100);       PDFStringFormat sf …

Continue reading

How to Insert an Image into a PDF

This samples shows how to use images in your PDF documents.You can create an image from a file in GIF/TIFF/PNG/BMP/Jpeg formats, or a buffer of image bytes, or an System.Drawing.Image object. C# : using PDFMosaic;using System.Drawing; namespace DrawImage{  class DrawImage  {    static void Main(string[] args)    {      PDFDocument document = new PDFDocument();      document.Pages.Add(new PDFPage(PDFPaperFormat.A4));      PDFCanvas canvas = document.Pages[0].Canvas;      PDFImage image = new PDFImage(“..\\..\\two_pilots.bmp”);      canvas.DrawImage(image, 20, …

Continue reading

How To Transform Images Using PDF Mosaic Library

This sample shows how to use such methods as: SkewTransform – Skews the x axis by an angle alpha and the y axis by an angle beta. RotateTransform – Applies the specified rotation to the transformation matrix. ScaleTransform – Applies the specified scaling operation to the transformation matrix. TranslateTransform – Changes the origin of the coordinate system by prepending …

Continue reading

How To Add and Delete PDF Pages

This example demonstrates how to add and delete pages  to/from PDF document using PDF Mosaic Library.   C# : /*Description:This sample shows how to add and delete pages to/from PDF document */ using PDFMosaic;using System; namespace AddAndDeletePages{  class AddAndDeletePages  {    static void Main(string[] args)    {      PDFDocument document = new PDFDocument();       // Create font and brush for drawing on page      PDFFont font = …

Continue reading

How to Open an Existing PDF Document

This sample shows how to open an existing PDF and re-save it using PDFMosaic library. C# : using PDFMosaic; using System; namespace OpenAndReSave { class OpenAndReSave { static void Main(string[] args) { // Open existing pdf document PDFDocument document = new PDFDocument(“any_document.pdf”); // Open existing PDF document // Gets the number of pages in the …

Continue reading

How To Split PDF Document

This sample shows how to split multipage PDF document using PDF Mosaic library. C# : using PDFMosaic;using System; namespace SplitPDFDocument{  class SplitPDFDocument  {    static void Main(string[] args)    {      // Open pdf document      PDFDocument document = new PDFDocument(“multipage_document.pdf”);            for(int i = 0; i < document.Pages.Count; ++i)      {        // Generate split file name        string sFileName = “split_” + i.ToString() + “.pdf”;                // Create new pdf document        PDFDocument splitDocument = …

Continue reading

How To Copy Pages From One PDF Document Into Another PDF Document

This example shows how to extract pages from one PDF document (“Text.pdf”) and merge them with another existing document (“Images.pdf”) and then save them into “MergeDocument.pdf” document file. C# : using PDFMosaic; using System; namespace MergePDFs { class MergePDFs { static void Main(string[] args) { // Open the first document PDFDocument documentImages = new PDFDocument(“Images.pdf”); …

Continue reading

How To Extract Text From a Document in PDF Mosaic Library .NET

This sample shows how to extract text from a document. Use PDFPage.GetText() method to extract text in plain text format. C# : using PDFMosaic;using System.Drawing;using System.IO;using System.Diagnostics; namespace ExtractText{  class ExtractText  {    static void Main()    {      PDFDocument document = new PDFDocument(“..\\..\\residential.pdf”);       StreamWriter writer = new StreamWriter(“Document text.txt”);      for (int i = 0; i < document.Pages.Count; ++i)        writer.WriteLine(document.Pages[i].GetText());       writer.Close();       document.Save(“ExtractText.pdf”, true);      Process.Start(“Document text.txt”);    }  }} VB.NET …

Continue reading

How To Create Tables in PDF Mosaic Library .NET

This sample shows how to draw tables. C# : using PDFMosaic;using System.Drawing; namespace Tables{  class Tables  {    static void Main()    {      PDFDocument document = new PDFDocument();      document.Pages.Add(new PDFPage(PDFPaperFormat.A4));      PDFCanvas canvas = document.Pages[0].Canvas;       PDFTable table = new PDFTable();       for (int i = 0; i < 10; ++i)      {        table.Columns.Add(new PDFTableColumn((i + 1).ToString(), (i + 1).ToString()));      }      table.BackgroundColor = new PDFColorGray(123);      table.Columns[0].BackgroundColor = new PDFColorGray(123);       for (int i = …

Continue reading

How To Protect Your PDF Document With a Password.

This sample shows how to protect your PDF document with a password. There are two passwords types: a “user” and an “owner” password.PDFSecurity.OwnerPassword property is for an “owner” passwordand PDFSecurity.UserPassword property is for a “user” password. C# : using PDFMosaic;using System; namespace SetPassword{  class SetPassword  {    static void Main()    {      PDFDocument document = new PDFDocument();      document.Pages.Add(new PDFPage(PDFPaperFormat.A4));       document.Security.EncryptionAlgorithm = PDFEncryptionAlgorithm.el40bitRC4;      document.Security.UserPassword = …

Continue reading

How To Compress PDF Document Using .NET Library

This sample shows how to create PDF documents with different compressions using PDFMosaic library. Theare are 2 type of corpessions: PDFCompression.None and PDFCompression.Flate. All PDF documents are created with PDFCompression.Flate by default.   PDFDocument document = new PDFDocument(); PDFPage page = new PDFPage(PDFPaperFormat.A4); PDFFont font = new PDFFont(PDFStandardFont.Helvetica, 11); PDFBrush brush = new PDFSolidBrush(); page.Canvas.DrawString(“Lorem …

Continue reading

How to manipulate primitives to clip drawing objects

This sample shows how to use current graphics path as a clip region of a canvas.When a clip region is set on a canvas, any part of a drawn object (including text and images) that lay outside the clip region will not be visible.   C# : using PDFMosaic;using System.Drawing;using System; namespace Clipping{  class Clipping  {    static void …

Continue reading

How to draw simple elements, such as a line and cubic Bezier curves

This sample shows how to draw straight lines and cubic Bezier curves.All drawing in a PDF document is done using methods and properties of PDFCanvas class.   C# : using PDFMosaic;using System.Drawing; namespace LinesAndCurves{  class LinesAndCurves  {    static void Main(string[] args)    {      PDFDocument document = new PDFDocument();      document.Pages.Add(new PDFPage(PDFPaperFormat.A4));      PDFCanvas canvas = document.Pages[0].Canvas;       PDFFont font = new PDFFont(PDFStandardFont.Helvetica, 8, false, false);      PDFSolidPen penCurve …

Continue reading

How To Draw Circles And Ellipses In PDF Documents Using PDF Mosaic .NET

This sample shows how to draw circles and ellipses, and how to use such operations as path, clipping.   using PDFMosaic; using System; using System.Drawing; namespace CirclesEllipses { class CirclesEllipses { static void Main() { PDFDocument document = new PDFDocument(); document.Pages.Add(new PDFPage(PDFPaperFormat.A4)); PDFCanvas canvas = document.Pages[0].Canvas; PDFPath path = new PDFPath(); path.AddEllipse(50, 50, document.Pages[0].Width – …

Continue reading

How To Draw Lines And Curves

This sample shows how to draw straight lines and cubic Bezier curves. All drawing in a PDF document is done using methods and properties of PDFCanvas class. C# : using PDFMosaic; using System.Drawing; namespace LinesAndCurves { class LinesAndCurves { static void Main() { PDFDocument document = new PDFDocument(); document.Pages.Add(new PDFPage(PDFPaperFormat.A4)); PDFCanvas canvas = document.Pages[0].Canvas; PDFFont …

Continue reading

How To Draw Polygons Graphics Figure in PDF Mosaic .NET

This sample shows how to draw polygons graphics figure in PDF Mosaic .NET. C# : using PDFMosaic;using System.Drawing;using System; namespace Polygon{  class Polygon  {    static void Main()    {      PDFDocument document = new PDFDocument();      document.Pages.Add(new PDFPage(PDFPaperFormat.A4));      PDFCanvas canvas = document.Pages[0].Canvas;       PointF start = new PointF(0, 0);      PointF[] points = new PointF[5];            points[0].X = 113;      points[0].Y = 283;      points[1].X = 70;      points[1].Y = 156;      points[2].X = 180;      points[2].Y = 70;      points[3].X = …

Continue reading

How To Draw Rectangles In PDF Documents Using PDF Mosaic .NET

This sample shows how to draw rectangles on a canvas using semi-transparentcolors.Use PDFPen.Opacity and/or PDFSolidBrush.Opacity properties tomake current pen or brush color semi-transparent. Opacity valueranges from 0 (fully transparent) to 100 (fully opaque).   using PDFMosaic; using System.Drawing; using System; namespace RectanglesAndTransparency { class RectanglesAndTransparency { static void Main() { PDFDocument document = new PDFDocument(); …

Continue reading

How To Draw Pies In PDF Documents Using PDF Mosaic .NET

This example shows how to draw pies and change the coordinate system of the canvas in PDF document.   using PDFMosaic; using System.Drawing; using System; namespace PieAndTranslate { class RectanglesAndTransparency { static void Main() { PDFDocument document = new PDFDocument(); document.Pages.Add(new PDFPage(PDFPaperFormat.A4)); PDFCanvas canvas = document.Pages[0].Canvas; PDFDeviceColor red = new PDFColorRGB(255, 0, 0); PDFDeviceColor green …

Continue reading

How To Use Blend Modes in PDF Mosaic .NET

This sample shows how to customize a way in which semi-transparent objects will blend on a canvas. C# : using PDFMosaic;using System.Drawing; namespace BlendMode{  class BlendMode  {    static void Main()    {      PDFDocument document = new PDFDocument();      document.Pages.Add(new PDFPage(PDFPaperFormat.A4));      PDFCanvas canvas = document.Pages[0].Canvas;       PDFDeviceColor red = new PDFColorRGB(255, 0, 0);      PDFDeviceColor green = new PDFColorRGB(0, 255, 0);      PDFDeviceColor blue = new PDFColorRGB(0, 0, 255);      PDFSolidBrush brushRed …

Continue reading

How To Create and Use Graphics Templates in PDF Mosaic .NET Library

This sample shows how to create and use graphics templates in PDFMosaic library. C# : using PDFMosaic;using System; namespace Template{  class Template  {    static void Main()    {      PDFDocument document = new PDFDocument();      PDFGraphicsTemplate template = new PDFGraphicsTemplate(500, 800);       PDFFont font = new PDFFont(PDFStandardFont.Helvetica, 16);      PDFSolidBrush brush = new PDFSolidBrush(new PDFColorRGB(255, 0, 0));       template.DrawRectangle(brush, 100, 50, 300, 30);      brush.Color = new PDFColorRGB(0, 0, 0);      template.DrawString(“Template”, …

Continue reading

How To Create CMYK Color Space in PDF and Draw Rounded Rectangles Using PDF .NET Mosaic

This sample shows how to create an CMYK color space and then create and use a color with that color space. C# : using PDFMosaic;using System.Drawing;using System; namespace CMYKColorSpace{ class CMYKColorSpace { static void Main() {  PDFDocument document = new PDFDocument();  document.Pages.Add(new PDFPage(PDFPaperFormat.A4));  PDFCanvas canvas = document.Pages[0].Canvas;   Random rnd = new Random();    for(int i = …

Continue reading

How To Create RGB Color Space in PDF and Draw Rectangles Using PDF .NET Mosaic

This sample shows how to create an RGB color space and then create and use a color with that color space. C# : using PDFMosaic;using System.Drawing;using System; namespace RGBColorSpace{ class RGBColorSpace {  static void Main()  {   PDFDocument document = new PDFDocument();   document.Pages.Add(new PDFPage(PDFPaperFormat.A4));   PDFCanvas canvas = document.Pages[0].Canvas;    Random rnd = new Random();      for(int i = 0; i < 5; ++i)   {    PDFColorRGB colorRGB = new …

Continue reading

How To Create Gray Color Space in PDF and Draw Graphics Elements using PDF .NET Mosaic

This sample shows how to create gray color space and then create and use a color with that color space. C# : using PDFMosaic; using System.Drawing; using System; namespace GrayColorSpace { class GrayColorSpace { static void Main() { PDFDocument document = new PDFDocument(); document.Pages.Add(new PDFPage(PDFPaperFormat.A4)); PDFCanvas canvas = document.Pages[0].Canvas; Random rnd = new Random(); for(int …

Continue reading

How to Load an ICC Profile into PDF Document Using PDF Mosaic .NET Library

This sample shows how to load an ICC profile and then create and use a color with that color profile. In addition to device-dependent colors PDFMosaic library can also use colors with associated color profiles. C# : using PDFMosaic;using System.Drawing;using System; namespace ColorProfiles{  class ColorProfiles  {    static void Main()    {      PDFDocument document = new PDFDocument();      document.Pages.Add(new PDFPage(PDFPaperFormat.A4));      PDFCanvas canvas = document.Pages[0].Canvas;       PDFICCBased …

Continue reading

How To Save And Restore Graphics State

This sample shows how to save and restore graphics state using PDFCanvas.SaveGraphicsState and PdfCanvas.RestoreGraphicsState methods. C# : using PDFMosaic; using System.Drawing; using System; namespace GraphicsState { class GraphicssState { static void Main() { PDFDocument document = new PDFDocument(); document.Pages.Add(new PDFPage(PDFPaperFormat.A4)); PDFCanvas canvas = document.Pages[0].Canvas; canvas.SaveGraphicsState(); PDFPath path = new PDFPath(); path.AddCircle(100, 100, 50); canvas.SetClip(path); canvas.DrawRectangle(new PDFSolidBrush(new …

Continue reading

How To Use Current Graphics Path As a Clip

This sample shows how to use current graphics path as a clip region of a canvas. When a clip region is set on a canvas, any part of a drawn object (including text and images) that lay outside the clip region will not be visible. C# : using PDFMosaic;using System.Drawing;using System; namespace Clipping{  class Clipping  {    static void …

Continue reading

How To Create Graphics in PDF Document Using Patterns in PDF Mosaic .NET

This sample shows how to use colored and uncolored tiling patterns. C# : using PDFMosaic;using System.Drawing; namespace Patterns{  class Patterns  {    static void Main()    {      PDFDocument document = new PDFDocument();      document.Pages.Add(new PDFPage(PDFPaperFormat.A4));      PDFCanvas canvas = document.Pages[0].Canvas;       PDFColorRGB red = new PDFColorRGB(255, 0, 0);      PDFColorRGB green = new PDFColorRGB(0, 255, 0);      PDFColorRGB blue = new PDFColorRGB(0, 0, 255);      PDFSolidPen pen = new PDFSolidPen();       PDFColoredTilingBrush tillingbrush = …

Continue reading

How To Create PDF with Unicode and CJK Support

This sample shows how to create PDF Document in .NET with Unicode and CJK fonts. C#:   using PDFMosaic; using System.Drawing; namespace Fonts { class Fonts { static void Main() { PDFDocument document = new PDFDocument(); document.Pages.Add(new PDFPage(PDFPaperFormat.A4)); PDFCanvas canvas = document.Pages[0].Canvas; PDFBrush brush = new PDFSolidBrush(); PDFFont font = new PDFFont(“Arial”, 12); canvas.DrawString(“English — …

Continue reading

How To Draw Text On a Canvas in PDF Mosaic Library .NET

This sample shows how to draw text on a canvas. To draw text on a canvas, use PDFCanvas.DrawString. C# : using PDFMosaic;using System.Drawing; namespace DrawText{  class DrawText  {    static void Main()    {      PDFDocument document = new PDFDocument();      document.Pages.Add(new PDFPage(PDFPaperFormat.A4));      PDFCanvas canvas = document.Pages[0].Canvas;       PDFFont font = new PDFFont(“Arial”, 16);      PDFBrush brush = new PDFSolidBrush();       canvas.DrawString(“The test string”, font, brush, 100, 100);       PDFStringFormat sf …

Continue reading

How To Use Fonts in PDF Mosaic Library .NET

This sample shows how to use fonts in PDFMosaic library. C# : using PDFMosaic;using System.Drawing; namespace Fonts{  class Fonts  {    static void Main()    {      PDFDocument document = new PDFDocument();      document.Pages.Add(new PDFPage(PDFPaperFormat.A4));      PDFCanvas canvas = document.Pages[0].Canvas;       PDFBrush brush = new PDFSolidBrush();       PDFFont systemFont = new PDFFont(“Arial”, 12);      canvas.DrawString(“The system font.”, systemFont, brush, 10, 60);       PDFFont standardFont = new PDFFont(PDFStandardFont.TimesItalic, 12);      canvas.DrawString(“The standard font.”, standardFont, brush, …

Continue reading

How To Increase Or Decrease The Size Of a Text Line Using Horizontal Scaling in PDF Mosaic Library .NET

This sample shows how to increase or decrease the size of a text line using horizontal scaling. The PDFStringFormat.Scaling property specifies horizontal scaling to use when drawing text. The horizontal scaling adjusts the width of glyphs by stretching or compressing them in the horizontal direction. C# : using PDFMosaic;using System.Drawing; namespace HorizontalScaling{  class HorizontalScaling  {    static void Main()    {      PDFDocument …

Continue reading

How To Specify Text Rendering Mode in PDF Mosaic Library .NET

This sample shows how to specify text rendering mode. C# : using PDFMosaic;using System.Drawing; namespace RenderingMode{  class RenderingMode  {    static void Main()    {      PDFDocument document = new PDFDocument();      document.Pages.Add(new PDFPage(PDFPaperFormat.A4));      PDFCanvas canvas = document.Pages[0].Canvas;       PDFFont font = new PDFFont(“Arial”, 24);      PDFBrush brush = new PDFSolidBrush(new PDFColorRGB(123, 123, 123));      PDFPen pen = new PDFSolidPen(new PDFColorRGB(0, 255, 0));       string text = “Text rendering mode”;       canvas.DrawString(text, font, …

Continue reading

How To Change Text Rise in PDF Mosaic Library .NET

This sample shows how to adjust baseline of text (useful for drawing superscripts or subscripts) using PDFStringFormat.Rise property. Text rise specifies the distance to move the baseline up or down from its default location. C# : using PDFMosaic;using System.Drawing; namespace TextRise{  class TextRise  {    static void Main()    {      PDFDocument document = new PDFDocument();      document.Pages.Add(new PDFPage(PDFPaperFormat.A4));      PDFCanvas canvas = document.Pages[0].Canvas;       PDFFont font = …

Continue reading

How To Change Word Spacing in PDF Mosaic Library .NET

This sample shows how to change word spacing using PDFStringFormat.WordSpacing property. Word spacing defines a distance between adjacent words in a line of text. C# : using PDFMosaic;using System.Drawing; namespace WordSpacing{  class WordSpacing  {    static void Main()    {      PDFDocument document = new PDFDocument();      document.Pages.Add(new PDFPage(PDFPaperFormat.A4));      PDFCanvas canvas = document.Pages[0].Canvas;       PDFFont font = new PDFFont(“Arial”, 16);      PDFBrush brush = new PDFSolidBrush();      PDFStringFormat sf = new …

Continue reading

How To Change Character Spacing in PDF Mosaic Library .NET

This sample shows how to change character spacing using PDFStringFormat.CharacterSpacing property. Character spacing defines a distance between adjacent characters in a line of text. C# : using PDFMosaic;using System.Drawing; namespace CharacterSpacing{  class CharacterSpacing  {    static void Main()    {      PDFDocument document = new PDFDocument();      document.Pages.Add(new PDFPage(PDFPaperFormat.A4));      PDFCanvas canvas = document.Pages[0].Canvas;       PDFFont font = new PDFFont(“Arial”, 16);      PDFBrush brush = new PDFSolidBrush();       PDFStringFormat sf = …

Continue reading

How To Create CJK PDF Document in .NET

This sample shows how to create cjk PDF Document in .NET C# : using PDFMosaic;using System.Drawing; namespace DrawText{ class DrawText {  static void Main()  {   PDFDocument document = new PDFDocument();   document.Pages.Add(new PDFPage(PDFPaperFormat.A4));   PDFCanvas canvas = document.Pages[0].Canvas;    PDFFont font = new PDFFont(“MingLiU”, 14);    PDFBrush brush = new PDFSolidBrush();    canvas.DrawString(“?????????”, font, brush, 20, 20);   canvas.DrawString(“?????????”, font, brush, 20, 40);    document.Save(“CJKText.pdf”, true);  } }} VB.NET : Imports PDFMosaicImports …

Continue reading

How To Create Multi-language PDF Document in .NET

This sample shows how To Create Multi-language PDF Document in .NET C# : using PDFMosaic;using System.Drawing; namespace DrawText{  class DrawText  {    static void Main()    {      PDFDocument document = new PDFDocument();      document.Pages.Add(new PDFPage(PDFPaperFormat.A4));      PDFCanvas canvas = document.Pages[0].Canvas;       PDFFont font = new PDFFont(“Arial”, 10);      PDFFont font1 = new PDFFont(“Sylfaen”, 10);      PDFFont font2 = new PDFFont(“Vrinda”, 10);      PDFFont font3 = new PDFFont(“Shruti”, 10);      PDFFont font4 = new PDFFont(“Tunga”, 10);      PDFFont font5 …

Continue reading

How To Add Type1 Font In PDF Document Generated by .NET Library PDF Mosaic

This example demonstrates how to add and use type1 font. C# : using PDFMosaic;using System.Drawing; namespace Type1Fonts{  class Type1Fonts  {    static void Main()    {      PDFDocument document = new PDFDocument();      document.Pages.Add(new PDFPage(PDFPaperFormat.A4));      PDFCanvas canvas = document.Pages[0].Canvas;       PDFBrush brush = new PDFSolidBrush();       PDFFont fontType1 = new PDFFont(“AGReverence”, 12);      canvas.DrawString(“The Type1 font.”, fontType1, brush, 10, 60);       document.Save(“Type1Fonts.pdf”, true);    }  }} VB.NET : Imports PDFMosaicImports System.Drawing Module Type1Fonts  Sub Main()        Dim …

Continue reading

How To Use Fonts (TrueType, OpenType, Type1) For Writing Text In .NET Library PDF Mosaic

This sample shows how to use fonts in PDFMosaic library. PDF Mosaic Library .NET provides several ways to add fonts to PDF document. You can: load font from file; add font using its name (the library looks for fonts installed in system); use built-in PDF fonts. Class PDFFont represents a font in the PDF document. …

Continue reading

How To Load OpenType Font using PDF Mosaic .NET Library

The example demonstares how to write text using OpenType Font with help of PDF Mosaic .NET Library. C# : using PDFMosaic;using System.Drawing; namespace OpenTypeFont{  class Fonts  {    static void Main()    {      PDFDocument document = new PDFDocument();      document.Pages.Add(new PDFPage(PDFPaperFormat.A4));      PDFCanvas canvas = document.Pages[0].Canvas;       PDFBrush brush = new PDFSolidBrush();       PDFFont fontFromFile = PDFFont.FromFile(“c:\\fummel.otf”, 12);      canvas.DrawString(“opentype Font from file.”, fontFromFile, brush, 10, 120);       document.Save(“OpenTypeFont.pdf”, true);    }  }} VB.NET …

Continue reading

How To Load Font From Filename (TTF) To Use In PDF Document Generated by .NET Library PDF Mosaic

This sample shows how to add and use text font from file. C# : /*Description:This sample shows how to use fonts in PDFMosaic library.*/using PDFMosaic;using System.Drawing; namespace FontFromFile{  class Fonts  {    static void Main()    {      PDFDocument document = new PDFDocument();      document.Pages.Add(new PDFPage(PDFPaperFormat.A4));      PDFCanvas canvas = document.Pages[0].Canvas;       PDFBrush brush = new PDFSolidBrush();            // load font from filename      PDFFont fontFromFile = PDFFont.FromFile(“..\\..\\arial.ttf”, 12);      canvas.DrawString(“Font from file.”, fontFromFile, …

Continue reading

How To Use Standard Built-in Fonts For Writing Text In PDF documents

This example demonstrates how to use built-in “standard” fonts for text in PDF. The enum PDFStandardFont specifies the standard PDF font families. C# : using PDFMosaic;using System;using System.Drawing; namespace StandardFonts{  class StandardFonts  {    static void Main()    {      PDFDocument document = new PDFDocument();      document.Pages.Add(new PDFPage(PDFPaperFormat.A4));      PDFCanvas canvas = document.Pages[0].Canvas;       PDFBrush brush = new PDFSolidBrush();       int dy = 10;      foreach(PDFStandardFont standardFont in Enum.GetValues(typeof(PDFStandardFont)))      {          PDFFont …

Continue reading

How to Submit and Reset Form Actions

This sample shows how to use Submit-Form and Reset-Form actions. A Submit-Form action (PDFSubmitFormAction class) transmits the names and values of associated controls to a specified uniform resource identifier (URI), presumably the address of a Web server that will process them and send back a response. A Reset-Form action (PDFResetFormAction class) resets associated controls to …

Continue reading

How to Create Fillable PDF Forms

This sample shows how to use buttons, editboxes, checkboxes, comboboxes in your PDF document. C# : using PDFMosaic;using System; namespace PDFForm{  class PDFForm  {    static void Main(string[] args)    {      PDFDocument doc = new PDFDocument();      PDFPage page = new PDFPage(PDFPaperFormat.A4);       PDFPushButton button = new PDFPushButton(10, 40, 100, 30, “btn1”);      button.Caption = “Button”;      page.Annotations.Add(button);       PDFCheckBox checkBox = new PDFCheckBox(10, 100, 20, 20, “checkBox”);      checkBox.Checked = true;      page.Annotations.Add(checkBox); …

Continue reading

How To Add Custom Page Thumbnails To PDF In PDF Mosaic .NET Library

A PDF document can define thumbnail images representing the contents of its pages in the miniature form. A viewer application can display these images on the screen, allowing the user to navigate to a page by clicking its thumbnail image. To add custom page thumbnail in your pdf files use ‘Thumbnail’ property of ‘PDFPage’ class. …

Continue reading

How To Specify PDF Viewer Application Preferences

This sample shows how to specify a PDF viewer application preferences using PDFDocument.ViewerPreferences property. A PDF viewer application preferences specify the way the document is to be displayed on the screen. There are the following supported viewer preferences: HideToolbar – gets or sets a value indicating whether to hide the viewer applications toolbars when. HideMenubar …

Continue reading

How To Set PDF Options For Displaying In PDF Viewer Application

This sample shows how to instruct a PDF viewer to display the document in certain mode.PDFDocument.PageMode property specifies which additional panels should be shown in a PDF viewer application. There are the following options: None – neither document outline nor thumbnail images visible. Outlines – document outline visible. Thumbnail – thumbnail images visible. FullScreen – …

Continue reading