pdfsharp

Page truncate in right side for landscape orientation with trimmargins using PdfSharp

耗尽温柔 提交于 2020-02-14 17:08:49
问题 I am talking about PdfSharp. Portrait orientation works well with margin or without margin. But In case of landscape orientation, page truncate in right side once I set any margin using TrimMargins. I have tried same thing on sample code of pdfSharp and having same problem!! Look pdf rendered well for following code page = document.AddPage(); page.Size = PdfSharp.PageSize.A4; page.Orientation = PageOrientation.Landscape; gfx = XGraphics.FromPdfPage(page); gfx.DrawString("A4 (landscape)", font

MigraDoc/PDFsharp throwing Exceptions with Chinese YaHei font

风格不统一 提交于 2020-02-08 10:25:31
问题 Recently after moving our Website from Windows Server 2008 to Server 2016, we started facing problems exporting PDF documents from our C# code that uses MigraDoc/PDFsharp library. Problem can also be reproduced on windows 10. Exactly same code works just fine on Windows 7 or, as mentioned earlier, any server OS prior to Server 2016. Previously we were getting this exception: Error while parsing an OpenType font. InnerException: InvalidOperationException: Font has no usable platform or

MigraDoc/PDFsharp throwing Exceptions with Chinese YaHei font

二次信任 提交于 2020-02-08 10:24:28
问题 Recently after moving our Website from Windows Server 2008 to Server 2016, we started facing problems exporting PDF documents from our C# code that uses MigraDoc/PDFsharp library. Problem can also be reproduced on windows 10. Exactly same code works just fine on Windows 7 or, as mentioned earlier, any server OS prior to Server 2016. Previously we were getting this exception: Error while parsing an OpenType font. InnerException: InvalidOperationException: Font has no usable platform or

PDFSharp filling in form fields

会有一股神秘感。 提交于 2020-01-22 08:44:08
问题 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), Path.Combine(Directory.GetCurrentDirectory(), fileN4), true); // Open the file PdfDocument document = PdfReader.Open(fileN4, PdfDocumentOpenMode.Modify); PdfTextField currentField = (PdfTextField)(document.AcroForm.Fields["<CASENUM>"]); //const string caseName = TextBox1

Error merging two PDF files using PDFsharp

浪尽此生 提交于 2020-01-17 05:06:34
问题 I am getting a problem when merging two files. If I try to have the AddPage(from.Pages[i]); in a separate void function I get An object reference is required for the non-static field, method, or property It relates to CopyPages(one, outPdf); CopyPages(two, outPdf); If I make it a static void it will run but the console displays an error stating that it "can not save a PDF with no pages" static void Main(string[] args) { PdfDocument one = new PdfDocument("1.pdf"); PdfDocument two = new

How to run a C# winform in an XNA C# project

只愿长相守 提交于 2020-01-17 04:07:14
问题 I am trying to use the PDFsharp library in an XNA game. The example code I am trying to get to work is: static void Main() { Renderer renderer = new Renderer(); PreviewForm form = new PreviewForm(); form.RenderEvent = new PagePreview.RenderEvent(renderer.Render); Application.Run(form); } But I don't know how to get this to run in XNA. Is it possible to pass the graphics that are passed to the winform to the XNA graphics engine instead? 回答1: update 2 It appears that the original links to MSDN

Page number resets when new section starts - MigraDoc

冷暖自知 提交于 2020-01-15 05:34:12
问题 I am using MigraDoc to create a PDF. As per my requirement, I have to add different headers according to the contents of the page\section. I am able to achieve it by adding new section and defining new header for every section. Till here, it works fine. In footer, I am showing page numbers using "AddPageField". But I realized that whenever a new section starts, page field reset to 1. Is there any way that footer continues the page count across all sections? If I use only one section

MigraDoc table with rounded corners

一笑奈何 提交于 2020-01-15 03:40:10
问题 How can I set rounded corners for a table? I'm using c# and MigraDoc. MigraDoc.DocumentObjectModel.Tables.Table myTable = section.AddTable(); myTable.Borders.Visible = true; MigraDoc.DocumentObjectModel.Tables.Column myColumn = myTable.AddColumn(); MigraDoc.DocumentObjectModel.Tables.Row myRow = myTable.AddRow(); myRow[0].AddParagraph("Some text"); 回答1: PdfSharp can do it. Not sure about MigraDoc. http://www.nudoq.org/#!/Packages/PDFsharp-MigraDoc-GDI/PdfSharp/XGraphicsPath/M

PDFsharp on Azure with Custom Fonts

时光毁灭记忆、已成空白 提交于 2020-01-14 03:08:13
问题 I am using a webapp on azure to create a PDF using PDFsharp 1.32. As it is a Azure webapp I cannot install fonts. Therefore I am using the following with embedded font options: var globalFontCollection = XPrivateFontCollection.Global; _fontBytes = File.ReadAllBytes(_pathToFont); globalFontCollection.AddFont(_fontBytes, _fontName); However this does not work. There is no error just acts as if the font is not known and falls back to the default. If I install the font it works so I know the rest

Calculate text height based on available width and font?

自作多情 提交于 2020-01-10 01:03:08
问题 We are creating PDF documents on the fly from the database using PDFsharp. I need to know the best way to calculate the height of the text area based on the font used and the available width. I need to know the height so I can process page breaks when required. 回答1: In .NET you can call Graphics.MeasureString to find out how large the drawn text is going to be. Right, but when using PDFsharp you call XGraphics.MeasureString. 回答2: The PdfSharp.Drawing.XGraphics object has a MeasureString