简体   繁体   中英

Drawing on PDF file C#

I need to write a PDF file from my WPF app. I've seen some 3rd party libraries to create PDF files, but I couldn't find any that would allow me to write boxes, or any shape for the matter. Do I have to use some 2D library from .NET or is there any PDF library that provides that type of work?

This is what I need to draw:

I'll have a list of objects List<ObjX> list; that I'll use to fill each box. Think of it as a Personal Data list of all employees, for instance.

____________________________________
{header_img}

| Name: {name} | Surname: {surname}|

| Address : {address} | City: {cit}|
____________________________________

It's a very poor drawing, what I'll do is a bit more elaborated, including even images.

You probably want iTextSharp

You can find lots of help on how to use it by searching StackOverflow. :)

This is an answer to drawing a rectangle: Draw a rectangle in an iText pdf

Edit

Also, a search on "drawing shapes iTextSharp" gave me this link which looks quite detailed. http://www.mikesdotnetting.com/Article/88/iTextSharp-Drawing-shapes-and-Graphics

You will need to watch out for differences in version, since 1.4 and 1.5 are quite different.

You may want to take the approach that I did which is to generate your document entirely in WPF and then simply convert it to a bitmap image (very easy in WPF) and then add that bitmap image to a PDF document using iTextSharp. See this post for more details.

The main advantage to this approach is that you get a PDF that looks exactly like your WPF output. Plus, it takes very little code to make it work.

对我来说,最好的解决方案是使用PdfSharp和Migradoc, http: //www.pdfsharp.net/是免费的,您可以做任何事情。

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM