pdfsharp

MigraDoc: Setting font for a document

大城市里の小女人 提交于 2019-12-06 09:56:48
I'm wanting to use a different font with MigraDoc, but I'm having a hard time getting it to stick. Currently, I'm working with the following code: I have this as a class-wide variable: String tPdfFont = "MonospaceTyperwriter"; Then the MigraDoc code itself: Document tDoc = new Document(); MigraDoc.DocumentObjectModel.Style style = tDoc.Styles["Normal"]; style.Font.Name = tPdfFont; That particular font is installed on the machine, but it doesn't seem to work. I feel like I'm missing something terribly obvious or am just completley misunderstanding font usage. Make sure you write the font name

PDFsharp draws text under graphics

情到浓时终转凉″ 提交于 2019-12-06 06:08:18
I am using PDFsharp to generate a PDF document from scratch. I am trying to write text on top of a gradient filled rectangle. After generating the document, the gradient appears on top of the text rendering the text completely hidden. using (var document = new PdfDocument()) { var page = document.AddPage(); var graphics = XGraphics.FromPdfPage(page, XGraphicsPdfPageOptions.Append); graphics.SmoothingMode = XSmoothingMode.HighQuality; var bounds = new XRect(graphics.PageOrigin, graphics.PageSize); graphics.DrawRectangle( new XLinearGradientBrush( bounds, XColor.FromKnownColor(XKnownColor.Red),

How to get path of Properties.Resources.Image in .NET

旧巷老猫 提交于 2019-12-05 23:19:46
问题 I included an image as a resource following this post: How to create and use resources in .NET I am using PDFSharp library to create a PDF. The method to draw an image, requires the path of the image. How do I get the path of Properties.Resources.Image ? Or is there another way to do this? 回答1: The Properties.Resources.Image is in-memory resource. You can save Image to temp file and the get the path. var path = Path.GetTempPath(); Properties.Resources.logo.Save(path); Above uses Bitmap.Save

How to Define a PDF Outline Using MigraDoc

跟風遠走 提交于 2019-12-05 19:28:41
I noticed when using MigraDoc that if I add a paragraph with any of the heading styles (e.g., "Heading1"), an entry is automatically placed in the document outline. My question is, how can I add entries in the document outline without showing the text in the document? Here is an example of my code: var document = new Document(); var section = document.AddSection(); // The following line adds an entry to the document outline, but it also // adds a line of text to the current section. How can I add an // entry to the document outline without adding any text to the page? var paragraph = section

How to extract FlateDecoded Images from PDF with PDFSharp

天涯浪子 提交于 2019-12-05 16:58:11
how do I extract Images, which are FlateDecoded (such like PNG) out of a PDF-Document with PDFSharp? I found that comment in a Sample of PDFSharp: // TODO: You can put the code here that converts vom PDF internal image format to a // Windows bitmap // and use GDI+ to save it in PNG format. // [...] // Take a look at the file // PdfSharp.Pdf.Advanced/PdfImage.cs to see how we create the PDF image formats. Does anyone have a solution for this problem? Thanks for your replies. EDIT: Because I'm not able to answer on my own Question within 8 hours, I do it on that way: Thanks for your very fast

pdfSharp printing with page size

Deadly 提交于 2019-12-05 09:06:01
问题 I am using PdfSharp dll to print a pdf. This is the code that i am using. This works fine for me. PdfFilePrinter.AdobeReaderPath = "C:\\Program Files\\Adobe\\Reader 9.0\\Reader\\AcroRd32.exe"; PdfFilePrinter printer = new PdfFilePrinter("C:\\sample.pdf", "HP LaserJet P1007"); printer.Print(); As always!!!! "BUT" I am not able to apply page size like A4 to the above code. So is there any way that i can implement page size to the code here. Thanks in advance 回答1: PdfFilePrinter launches

C# PDFSharp: Examples of how to strip text from PDF?

左心房为你撑大大i 提交于 2019-12-05 07:50:14
I have a fairly simple task: I need to read a PDF file and write out its image contents while ignoring its text contents. So essentially I need to do the complement of "save as text". Ideally, I would prefer to avoid any sort of re-compression of the image contents but if it's not possible, it's ok too. Are the examples of how to do it? Thanks! Vive la déraison Extracting text from a PDF file with PDFsharp is not a simple task. It was discussed recently in this thread: https://stackoverflow.com/a/9161732/162529 Extracting text from a PDF with PdfSharp can actually be very easy, depending on

MigraDoc Bullet List (holes)

六眼飞鱼酱① 提交于 2019-12-05 07:26:59
In my Solution I am using bullet list in PDF files. It looks something like that: • Solcellepaneler kræver hverken autoriseret service eller tidskrævende vedligehold. • Solceller er støjfri, forurener ikke og har ingen bevægelige dele, hvilket mindsker service og vedligehold • Solceller kan integreres i bygningers arkitektur eller anvendes som bygningselement i form af tag, facader eller solafskærmning • Solceller har lang levetid, med en produktionsgaranti på hele 25 år • 10 kvadrameter solceller sparer ca. ½ ton CO2 om året What I want : • Solcellepaneler kræver hverken autoriseret service

How to set DPI (dots per inch) in PDFsharp

会有一股神秘感。 提交于 2019-12-05 06:01:01
Is there any way to set DPI (dots per inch) in case of PDFsharp? Thanks No, PDF files are vector files that have no DPI. If your question is about images stored in the PDFfile: PDFsharp stores images as they come. PDFsharp does not (yet) resize images to lower DPI to reduce the file size. Your application knows which image will be used where and at which size, so you should reduce the raster images to the DPI (*) you need before using them with PDFsharp. Please note that images will be included in the PDF only once, even if they are drawn several times - and they can be drawn at different size

How do I walk through tree of Pdf Objects in PDFSharp?

元气小坏坏 提交于 2019-12-05 04:28:59
I am trying to to walk though the tree of PdfItem objects in an existing PDF document using PDFSharp in c#. I want to create a hierarchy of all the objects as I go along -- similar to what the "PDF Explorer" example does -- but I want it to be a tree instead of a flat list of all the objects. The root node is document.Internals.Catalog. And I want to to walk down through all the document.Internals.Catalog.Elements until I have visited every element. One of the problems I run into is that there are circular references in the tree and I can't figure out how to detect them. Any code samples out