Here you can search through the pages of this Namespace, their attachments and the files uploaded to the system.
Note: the results will only display the items you have permissions to read.
^Up Next >>
This sample shows how to use Unicode text in PDFsharp. Languages based on Latin, Greek, or Cyrillic letters should all work with PDFsharp. You'll find code snippets for the following classes:
XPdfFontOptions XTextFormatter
PDF Output File
See the PDF file created by this sample: output.pdf (58 kB) Source Code
Drawing the text is quite easy (just like the Text Layout sample):
// Create new document
PdfDocument document = new PdfDocument();
// Set font encoding to unicode
XPdfFontOptions options = new XPdfFontOptions(PdfFontEncoding.Unicode, [...]
Questions and answers about PDFsharp See also: MigraDoc FAQs
Questions and answers about PDFsharp What is PDFsharp
PDFsharp is a .NET library for creating and modifying Adobe PDF documents programmatically. It is written in C# and can be used from any .NET language like VB.NET. Is PDFsharp based on or does it require other libraries or tools?
PDFsharp is newly designed and built from scratch in C#.
Neither Adobe's [...]
PDFsharp Articles
PDFsharp: First Steps explains the Hello World sample. Graphics introduces the XGraphics objects that PDFsharp applications use for drawing. Object Streams provides information about a PDF feature that PDFsharp versions prior to 1.50 did not support. Form Objects shows how to use the XForm class to efficiently draw items that appear more than once. PDFsharp 1.30 Folders explains the folders that come with the source code [...]
[...] unfinished. Below you'll find the list of tasks that have to be done.
We will provide information about PDFsharp 1.50 folders after the final version of PDFsharp 1.50 was released.
Currently, PDFsharp 1.50 is still under construction and folders and samples will be rearranged for the final version. Folders of PDFsharp 1.30 Brief description of the folders. F;"> Folder Description PDFsharp Root folder code contains the source code of PDFsharp [...]
PDFsharp cannot use PostScript fonts to draw text in a PDF file. Only TrueType fonts and OpenType fonts with TrueType outlines can be used with PDFsharp. PDFsharp can open and manipulate existing PDF documents that contain PostScript fonts. The restriction applies only to text created with PDFsharp. Background
The PostScript font technology was invented by Adobe in 1984. From 1990 to 2000 the Adobe Type Manager had to be installed to use PostScript fonts under Windows 3.x to Windows [...]
The development of PDFsharp started with .NET 1.1. PDFsharp used the graphics functions of GDI+, a graphics library from Microsoft encapsulated in the System.Drawing namespace . The XGraphics class of PDFsharp has functions for drawing graphics and text very similar to the System.Drawing.Graphics class . The advantage of this approach is that PDFsharp was able to draw text and graphics not only in PDF documents, but on WinForms windows and printers too. This allows creating preview [...]
[...] Next >>
This sample shows how to deal with PDF objects that are not (yet) covered by specialized PDFsharp classes (as an example it adds an OpenAction to an existing PDF file). PDF documents are based internally on objects like dictionaries, arrays, streams etc. This sample shows how to work directly on these underlying PDF objects. Use this functionality to achieve PDF features that are not yet implemented in PDFsharp. PDF Output File
See the PDF file created by this sample: output.pdf (90 kB)
Note: the OpenAction causes Adobe Reader [...]
[...] page, two lines, an ellipse, and the text "Hello, World!" written in its center. Nearly all samples of PDFsharp are written in C#. This is because C# is the language PDFsharp itself is written in and we, the developers of PDFsharp, choose C# as our favorite language. If you like to write your code in Visual Basic .NET or in any other .NET language, you can of cause use PDFsharp as well. Here is a similar C# version of Hello World . PDF Output File
See the PDF file created by this sample: [...]
With PDFsharp 1.50 beta we have started to make preview versions of compiled assemblies available via NuGet before releasing the complete source code with samples etc. With Visual Studio you can install the NuGet Package Manager to easily access NuGet packages. This work with VS 2012 Express and also with the Community Editions of VS 2013 and VS 2015.
Just open Visual Studio and go to "Tools" => "Extensions and Updates..." to install the NuGet Package Manager if you do not have it yet. To add PDFsharp or PDFsharp [...]
[...] available fonts. Note: When using the GDI build, you can use the XPrivateFontCollection class. As of PDFsharp 1.50 beta 2, the XPrivateFontCollection class is the recommended way for applications that use the GDI build of PDFsharp and that also use the screen preview or use the XGraphics class to draw on other contexts beside PDF files.
PDFsharp Sample: Private Fonts The method shown in this sample works for the WPF build, the Core build, and the Silverlight build. This method has one drawback: it is not compatible [...]
[...] as possible.
Start with our prepared Issue Submission Templates We have created one solution for PDFsharp and one solution for MigraDoc. Basically these are our Hello World samples. You can use them as a template to build your sample that allows us to replicate the issue you have found. Download the PDFsharp Issue Submission Template . Download the MigraDoc Issue Submission Template .
To get you started These solutions basically contain the PDFsharp Hello World sample or the MigraDoc Hello World sample [...]
[...] are two methods, but not all platforms support both methods. IFontResolver IFontResolver is new with PDFsharp 1.50.
It cannot be used with the GDI build of PDFsharp.
It cannot be used with the WPF build of PDFsharp if you want to use the DocumentPreview - fonts used with IFontResolver are not available in the preview.
For all other platforms (Silverlight, Windows Phone) this is the method of choice. XPrivateFontCollection XPrivateFontCollection is no longer supported and not recommended (as of PDFsharp [...]
[...] to ' ' This Wiki provides you with information about these libraries. If you are unfamiliar with PDFsharp and MigraDoc, please visit these page: PDFsharp and MigraDoc Homepage PDFsharp and MigraDoc Overview introduces PDFsharp and MigraDoc and lets you decide which tool you need
PDFsharp - A .NET library for processing PDF
Starting points [...]
[...] code needed to create the PDF file:
using System;
using System.Diagnostics;
using System.IO;
using PdfSharp;
using PdfSharp.Drawing;
using PdfSharp.Pdf;
using PdfSharp.Pdf.IO;
namespace HelloWorld
{
///
/// This sample is the obligatory Hello World program.
///
class Program
{
[...]
Both PDFsharp and MigraDoc provide a lot of AddXxx functions. Typically these functions return the newly created objects.
Once you’ve learned the basic principles it’s quite easy to work with. Intellisense helps a lot then. And the new help system that integrates with the Visual Studio online help will provide information about any class in PDFsharp and MigraDoc – simply by hitting F1. PDFsharp - Getting Started A good place to start is the Samples folder that comes with the source code. This wiki also shows [...]
[...] the same code with the GDI+ or WPF classes. There are the following general differences between the PDFsharp X classes and the classes from System.Drawing: All floating point values are of type double to prevent the tedious casting to float necessary in GDI+/ System.Drawing X graphics classes and functions supports only functionality available in PDFsharp In the WPF build of PDFsharp the X classes have nearly the same interface as in the GDI+ build, but are based internally on Windows Presentation Foundation. [...]
[...] export JPEG images from a PDF file. Note: This snippet shows how to export JPEG images from a PDF file. PDFsharp cannot convert PDF pages to JPEG files. This sample does not handle non-JPEG images. It does not (yet) handle JPEG images that have been flate-encoded. There are several different formats for non-JPEG images in PDF. Those are not supported by this simple sample and require several hours of coding, but this is left as an exercise to the reader. PDFsharp cannot render PDF pages - not to printers, not to bitmaps, not to JPEG files.
[...] have to be done.
We will provide information about MigraDoc 1.50 folders after the final version of PDFsharp 1.50 was released.
Currently, PDFsharp 1.50 is still under construction and folders and samples will be rearranged for the final version. Folders of MigraDoc Foundation 1.30 Brief description of the folders. F;"> Folder Description MigraDoc Root folder code contains the source code of MigraDoc foundation MigraDoc.DocumentObjectModel source code of document object model MigraDoc.Rendering source code of PDF rendering using [...]
[...] password). Note: that we will not explain nor give any tips how to crack a protected document with PDFsharp. PDF Output File
See the PDF file created by this sample: output.pdf (7 kB) Screen Shots Here is a sample screen shot: Source Code
This code shows how to unprotect a document to allow modification:
// Get a fresh copy of the sample PDF file.
// The passwords are 'user' and 'owner' in this sample.
const string filenameSource = "HelloWorld (protected).pdf";
const string filenameDest = "HelloWorld_tempfile.pdf";
File.Copy(Path.Combine("../../../../../PDFs/", [...]
[...] Images from Memory shows how you can use fileless images from resources or databases with MigraDoc. PDFsharp and MigraDoc Foundation Articles Supported Platforms and Technologies explains the available versions of PDFsharp. Working with NuGet Packages explains how to use versions of PDFsharp available on NuGet. Submitting Issue Reports explains how you can help us to locate and fix bugs. Help presents the Help Files that are available for download or online. Using Private Fonts explains how you [...]
Known issues Object Streams are a new feature of PDFsharp 1.50. There are no known issues as of PDFsharp 1.50 beta 3b, but if you encounter PDF files that cannot be read using this version please let us know. SQL Server 2008 Reporting Services may still cause problems: [...]
The samples are included in the PDFsharp source code package. So there is no need to copy and paste the code from this site (for some samples we only show snippets here). Desktop Samples
Hello World is the obligatory Hello World program. Hello World (VB) is the obligatory Hello World program written in Visual Basic .NET. Graphics shows some of the capabilities of the XGraphcis class. Annotations shows how to create annotations. Booklet shows how to produce a booklet by placing two pages of an existing document on one landscape orientated page [...]
^Up Next >>
This sample demonstrates how to mix MigraDoc and PDFsharp. PDF Output File
See the PDF file created by this sample: output.pdf (134 kB) Screen Shots Here is a sample screen shot (showing page 2 with 6 pages from MigraDoc, scaled down to fit on one page):
Source Code Creating the Document We create a PdfDocument , not a (MigraDoc) Document :
static void Main()
{
DateTime now = DateTime.Now;
string filename = "MixMigraDocAndPdfSharp.pdf";
filename = Guid.NewGuid().ToString("D").ToUpper() + ".pdf";
PdfDocument document = new PdfDocument();
[...]
PDFsharp requires the .NET Framework 2 and is written entirely in C#. It was developed with Visual Studio 2012 and Visual Studio 2013, but should run on any C# compiler. The MSBuild utility that comes with the .NET Framework should be able to compile the solutions that are included with PDFsharp. The WPF build of PDFsharp requires .NET Framework 3. We strongly [...]
[...] So what can you do if you want to use images from application resources, databases, or streams? With PDFsharp 1.50 beta 2, a new feature was added: MigraDoc now accepts filenames that contain BASE64-encoded images with the prefix "base64:". In this case, the filename does not refer to a file, the filename contains all the bits of the bitmap in an ASCII string with the BASE64 encoding. So the filename can be very long, depending on the size of the file. A byte array (byte[] in C#) can easily be converted to a filename.
If you have a stream, you can easily read it into [...]
Online Help NuDoq.org provides online help, based on the recent stable NuGet packages. PDFsharp documentation:
http://www.nudoq.org/#!/Projects/PDFsharp MigraDoc (and PDFsharp) documentation:
http://www.nudoq.org/#!/Projects/PDFsharp-MigraDoc-GDI [...]
Create Account for the PDFsharp Wiki We have plans to open this Wiki to the community and allow registered users to provide content. Please note: wait with creating accounts until we'll have prepared the framework for contributions from the community and finished the applicable rules of conduct.
Thank you for your interest and your patience. Do not create accounts without personal invitation (we will only activate users that have been invited to join).
To apply for an account for this Wiki, follow this link:
Apply for an account (if you have been personally invited [...]
[...] Guid.NewGuid().ToString("D").ToUpper());
s_document = new PdfDocument();
s_document.Info.Title = "PDFsharp XGraphic Sample";
s_document.Info.Author = "Stefan Lange";
s_document.Info.Subject = "Created with code snippets that show the use of graphical functions";
s_document.Info.Keywords = "PDFsharp, XGraphics";
// Create demonstration pages
new LinesAndCurves().DrawPage(s_document.AddPage());
new Shapes().DrawPage(s_document.AddPage());
new Paths().DrawPage(s_document.AddPage());
new Text().DrawPage(s_document.AddPage());
new [...]
[...] how to render PDF using the Ghostscript DLL gsdll32.dll . Note: This program has nothing to do with PDFsharp. PDFsharp [...]
[...] and your program will be readable and easy to maintain. Note: Consider using MigraDoc instead of PDFsharp for large documents. You can use many attributes to format text and you get the linebreaks and pagebreaks for free. PDF Output File
We do not have sample output yet. Screen Shots
We do not have screen shots yet. Source Code
The class LayoutHelper takes care of the line position and creates pages as needed:
public class LayoutHelper
{
private readonly PdfDocument _document;
private readonly XUnit _topPosition;
private readonly XUnit _bottomMargin;
[...]