pdfsharp

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

纵饮孤独 提交于 2019-12-05 00:03:42
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. Kidquick Here's an approach that avoids hardcoding widths and allows for more flexible paper formats. Make sure to include the using MigraDoc.DocumentObjectModel; statement in your class. Document document = new Document(); Section section = document.AddSection(); section.PageSetup.PageFormat = PageFormat.A4; Table table = section.AddTable(); float sectionWidth = section.PageSetup.PageWidth -

How do you have a bulletted list in migradoc / pdfsharp

两盒软妹~` 提交于 2019-12-04 23:42:10
even after reading this forum post , its still quite confusing how to create a bulletted list using migradoc / pdfsharp. I basically want to display a list of items like this: Dodge Nissan Ford Chevy Here's a sample (a few lines added to the HelloWorld sample): // Add some text to the paragraph paragraph.AddFormattedText("Hello, World!", TextFormat.Italic); // Add Bulletlist begin Style style = document.AddStyle("MyBulletList", "Normal"); style.ParagraphFormat.LeftIndent = "0.5cm"; string[] items = "Dodge|Nissan|Ford|Chevy".Split('|'); for (int idx = 0; idx < items.Length; ++idx) { ListInfo

Printing PDFs with PDFSharp

为君一笑 提交于 2019-12-04 22:27:14
问题 I have the following code: using System; using System.Diagnostics; using System.IO; using PdfSharp.Pdf.Printing; namespace PrintPdfFile { class Program { [STAThread] static void Main(string[] args) { // Set Acrobat Reader EXE, e.g.: PdfFilePrinter.AdobeReaderPath = @"C:\\Documents and Settings\\mike.smith\\Desktop\\Adobe Reader 9.0.exe"; // -or- //PdfPrinter.AdobeReaderPath = @"C:\Program Files\Adobe\[...]\AcroRd32.exe"; //// Ony my computer (running a German version of Windows XP) it is here

MigraDoc C# Align left and right on same line

Deadly 提交于 2019-12-04 20:54:35
问题 I have a table with a cell where i want two texts, the first, aligned on left and the second aligned on the right, in the same cell, on the same line. I tried to reproduce this cell with MigraDoc without success. I only can add two texts aligned on left and right but not on same line. Here my code: Cell cellFooter1 = rowFooter.Cells[0]; Paragraph paraphTot = new Paragraph(); paraphTot.Format.Alignment = ParagraphAlignment.Left; paraphTot.AddText("Left text"); cellFooter1.Add(paraphTot);

PDFsharp page size and set margin issue c#

社会主义新天地 提交于 2019-12-04 08:07:12
I am converting an image to pdf using PDFsharp lib. I need to set margin & page size so I got a trick from this forum to set page size and margin. From here I got code which I used but getting error for two area. Here is code which I got. page = document.AddPage(); //page.Size = PdfSharp.PageSize.A4; XSize size = PageSizeConverter.ToSize(PdfSharp.PageSize.A4); if(page.Orientation == PageOrientation.Landscape) { page.Width = size.Height; page.Height = size.Width; } else { page.Width = size.Width; page.Height = size.Height; } // default unit in points 1 inch = 72 points page.TrimMargins.Top = 5;

pdfsharp - font embed?

孤街浪徒 提交于 2019-12-04 05:52:40
I am given a file that has some other language font. They can not download the font, so they want me to embed it in the pdf. Now, I only have PDF Reader, so I cant edit or create a pdf file. so I decided to quickly do it in C#.NET using PDFSharp library, but I just cant seem to figure out how to embed fonts using pdfSharp?! Also, it's only 1 file that I have to process, so if you know of a way to do it manually, then that would be great too. There are two ways to do this. For each font you want to embed like this: var options = new XPdfFontOptions(PdfFontEmbedding.Always); var font = new XFont

Does PDF file contain iref stream?

北城以北 提交于 2019-12-04 04:35:25
I still fight with read data from PDF file. I use PDFsharp, how can I check if file contains iref stream without use method Open. Method Open throws exception if file contains iref stream . There is a know workaround to permit you to open ALSO the pdf files that contains iref: you can find here the complete thread about that. Just to summarize the solution: download and include the iTextSharp 4.1.6 library paste the following code in a code file into your project: - using System; using System.IO; namespace PdfSharp.Pdf.IO { static public class CompatiblePdfReader { /// <summary> /// uses

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

冷暖自知 提交于 2019-12-04 03:47:14
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? 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 You can actually create an image, without saving it, using XImage.FromGdiPlusImage() : var image = XImage

How to check PDF pages for resolution (DPI) of embedded images?

独自空忆成欢 提交于 2019-12-03 23:29:00
问题 Is there any free library, that can be used to get resolution of images in DPI contained by PDF file? I've tried the following code, using PDFSharp but the DPI it returns is not correct. For example it shows 96dpi while it should be 150dpi: using (PdfDocument pdf = PdfReader.Open(sourcePdf)) { for (int i = 0; i < pdf.Pages.Count; i++) { XGraphics xGraphics = XGraphics.FromPdfPage(pdf.Pages[i]); float dpi = xGraphics.Graphics.DpiX; } } 回答1: You can use a command line tool to get the info you

PDFsharp save to MemoryStream

霸气de小男生 提交于 2019-12-03 05:33:42
问题 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 attach the PDF header settings when PDFsharp saves to memory? 回答1: If you think there is an issue with PdfDocument.Save, then please report this on the PDFsharp forum (but please be more specific with your error description). Your "solution" looks like