Questions tagged [pdfsharp]

PDFsharp - A .NET library for processing PDF (create, merge, split, or modify PDF files). For questions related to using the PDFsharp library on any platform and with any programming language.

PDFsharp is the Open Source .NET library that easily creates and processes PDF documents on the fly from any .NET language. The same drawing routines can be used to create PDF documents, draw on the screen, or send output to any printer.

PDFsharp’s outstanding features

Here are just a few highlights:

  • Creates PDF documents on the fly from any .NET language
  • Easy to understand object model to compose documents
  • Newly designed from scratch and written entirely in C#
  • One source code for drawing on a PDF page as well as in a window or on the printer
  • Modify, merge, and split existing PDF files
  • Images with transparency (color mask, monochrome mask, alpha mask)
  • Font embedding and subsetting
  • The graphical implementation based either on GDI+ or WPF

PDFsharp Resources

Questions

Use this tag for all questions that relate to using the PDFsharp library.

MigraDoc is a different library from the same authors. MigraDoc includes PDFsharp and uses PDFsharp to create PDF files. Not all questions about MigraDoc justify the PDFsharp tag.
It is less confusing for people trying to answer your questions when you use the tag that corresponds to the API you are using (either or ). Simply look at the namespace of the objects you are using.

For questions about the HTML Renderer for PDF using PdfSharp use the tag.

Related Tags

, ,

Orthography

The name of the library is PDFsharp. When used for namespaces the name is written as PdfSharp following C# naming conventions. So unless you are referring to a namespace, the recommended writing is PDFsharp.

886 questions
64
votes
4 answers

C# Extract text from PDF using PdfSharp

Is there a possibility to extract plain text from a PDF-File with PdfSharp? I don't want to use iTextSharp because of its license.
der_chirurg
  • 1,475
  • 2
  • 16
  • 26
49
votes
5 answers

PDFsharp save to MemoryStream

I want to save a PdfSharp.Pdf.PdfDocument by its Save method to a Stream, but it doesn't attach the PDF header settings to it. So when I read back the Stream and return it to the user, he see that the PDF file is invalid. Is there a solution to…
misnyo
  • 1,707
  • 3
  • 16
  • 17
35
votes
2 answers

PDFsharp Line Break

I am trying to get new line but if I use \n it does not work. Any way to have new line by adding something to string like \r\n (which also does not work) gfx.DrawString("Project No \n" + textBoxProjNumber.Text, fontUnder, XBrushes.Black, 230,…
Afnan Bashir
  • 7,319
  • 20
  • 76
  • 138
35
votes
5 answers

PDFsharp: Is there a way to generate "Page X of Y" in the header of the page?

It seems rather simple, but I can't find something like getPageCount() in the API. I can get it to return the current page, but not the total number of pages. Perhaps I'm missing it? I would like to somehow be able to print 'Page 1 of 9' at the top…
mkautzm
  • 1,086
  • 2
  • 18
  • 34
32
votes
6 answers

PDFSharp filling in form fields

I would like to fill in form fields in a premade PDF doc, but I'm receiving a Null Refrence error with AcroForm when running. string fileN4 = TextBox1.Text + " LOG.pdf"; File.Copy(Path.Combine(textBox4.Text + "\\", fileN4), …
user770344
  • 473
  • 2
  • 8
  • 16
31
votes
1 answer

How to export PDF page as an image using PDFsharp .NET library?

How to export a PDF page as an image using PDFsharp .NET library, for pixel level manipulation? For example, something like, System.Drawing.BitMap.GetPixel() I am trying to find out empty area (all white, or of any colour) inside a PDF document, to…
vi.su.
  • 685
  • 2
  • 9
  • 19
28
votes
6 answers

How to add PDFsharp lib in C#?

I am new to C#.net, I downloaded PDFsharp lib. But how to add this lib to our project? My project is to create a PDF file. Please provide me step by step instructions. After unziping it has 32 folders. I tried by coping it in my project folder, but…
Royson
  • 2,851
  • 13
  • 36
  • 50
27
votes
3 answers

Overlay image onto PDF using PDFSharp

Can't seem to find much out there for this. I've a PDF, onto which I'd like to overlay an image of an electronic signature. Any suggestions on how to accomplish that using PDFSharp? Thanks
user948060
  • 953
  • 3
  • 12
  • 25
26
votes
1 answer

PDFsharp edit a pdf file

Environment - PDFsharp Library, Visual Studio 2012 and C# as the language. I am trying to: read Test1.pdf (Width = 17 inches, Height – 11 inches) with 1 page add some text to it save it as another file (Test2.pdf) I am able to do all the…
Yuvi Dagar
  • 649
  • 2
  • 11
  • 20
25
votes
11 answers

Generate PDF based on HTML code (iTextSharp, PDFSharp?)

Does the library PDFSharp can - like iTextSharp - generate PDF files *take into account HTML formatting *? (bold (strong), spacing (br), etc.) Previously I used iTextSharp and roughly handled in such a way (code below): string encodingMetaTag =…
TomashUfx
  • 251
  • 1
  • 3
  • 5
24
votes
3 answers

Combining multiple PDFs using PDFSharp

I am trying to combine multiple PDFs into a single PDF. The PDFs come from SSRS, from some LocalReports that I processed. I am using PDFSharp, because it is already used through out the project. However, the outputDocument.addPage(page) methods…
Pierre-Olivier Goulet
  • 968
  • 2
  • 11
  • 18
23
votes
3 answers

How to size a table to the page width in MigraDoc?

I am trying to resize a table automatically to full width of the page. That table should have 2 columns, 50% width each. How can I achieve this? I tried LeftIndent and RightIndent properties with no luck.
jstuardo
  • 3,901
  • 14
  • 61
  • 136
23
votes
1 answer

MigraDoc - Bold certain text in a paragraph

In MigraDoc, if I have a paragraph, how can I only bold some text in the paragraph, not the entire paragraph. Edit: Below is the typical code I would use to add a bolded paragraph. var paragraph = section.AddParagraph("This…
contactmatt
  • 18,116
  • 40
  • 128
  • 186
22
votes
2 answers

PDFsharp Documentation

Is it possible to find good documentation for the PDFsharp library? I searched on Google but I didn't find any reference documentation. I don't know how XGraphics.RotateAtTransform and XGraphics.TranslateTransform work.
Albirex
  • 283
  • 1
  • 2
  • 13
20
votes
1 answer

How to Set the Background Color of a Cell in a MigraDoc Table

I have a MigraDoc table where I specify a row height of 0.75cm, and the text is vertically-aligned in the middle of the cell. When I set cell.Format.Shading.Color to something non-white, there is still a portion of the cell near the border that is…
Jeff G
  • 4,470
  • 2
  • 41
  • 76
1
2 3
59 60