pdfsharp

PDFSharp filling in form fields

|▌冷眼眸甩不掉的悲伤 提交于 2019-12-03 02:38:34
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.Text; PdfString caseNamePdfStr = new PdfString(caseName); //set the value of this field currentField

PDFsharp save to MemoryStream

不打扰是莪最后的温柔 提交于 2019-12-02 20:08:18
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? 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 a hack to me. "pdfRenderer.Save" calls "PdfDocument.Save" internally. Whatever the problem is - your

Programmatically print to a PDF printer [closed]

会有一股神秘感。 提交于 2019-12-02 02:57:41
I am looking for a free open source .Net based, preferably C# , pdf printer such as CutePDF's Custom PDF Writer with programmatic access that will allow me to save a xps document to a pdf format. I have found many alternatives that are capable of converting xps documents to pdf formats, but they are not open source. I was curious to know if anyone is aware of an open source library that will allow me to accomplish this. For any of you out there attempting to convert XPS to PDF using an open source means, I was able to successfully do so using PDFSharp version 1.31 . It successfully upgraded to

PDFsharp generates blank page in Azure, but works locally

你。 提交于 2019-12-02 00:36:01
问题 This works in an ASP.NET MVC application when run locally, but not when deployed on Azure: Document doc = new Document(); Section section = doc.AddSection(); section.AddParagraph("Some text to go into a PDF"); PdfDocumentRenderer pdfRenderer = new PdfDocumentRenderer(false, PdfFontEmbedding.Always); pdfRenderer.Document = doc; pdfRenderer.RenderDocument(); System.IO.MemoryStream stream = new System.IO.MemoryStream(); pdfRenderer.PdfDocument.Save(stream, false); Byte[] documentBytes = stream

PDFSharp private fonts for azure 1.50

大城市里の小女人 提交于 2019-12-01 21:40:40
I have downloaded and installed PDFSharp 1.5 and I am having trouble using private fonts. I have created in testing a pdf creator and it works great. When I load it into Azure it gives me the error can't load font. Did research and found out that they do not have any loaded fonts so I must use private font. I can only find examples of the older 1.3 version and the methods are changed to new ones. Can somebody show me a simple example using the new version of PDFSharp? Thanks John This is for PdfSharp 1.5 beta3b. Here is a complete and fixed example based on links from other answers, and other

PDFsharp generates blank page in Azure, but works locally

匆匆过客 提交于 2019-12-01 20:37:45
This works in an ASP.NET MVC application when run locally, but not when deployed on Azure: Document doc = new Document(); Section section = doc.AddSection(); section.AddParagraph("Some text to go into a PDF"); PdfDocumentRenderer pdfRenderer = new PdfDocumentRenderer(false, PdfFontEmbedding.Always); pdfRenderer.Document = doc; pdfRenderer.RenderDocument(); System.IO.MemoryStream stream = new System.IO.MemoryStream(); pdfRenderer.PdfDocument.Save(stream, false); Byte[] documentBytes = stream.ToArray(); return File(documentBytes, "application/pdf"); Locally, I get a nice PDF. On Azure, I get a

PDFsharp add private/installed font

蓝咒 提交于 2019-12-01 08:38:38
I want to apply Trade gothic font to my pdf text using PDFsharp, I have installed the font and use below line of code to apply XPdfFontOptions options = new XPdfFontOptions(PdfFontEncoding.Unicode, PdfFontEmbedding.Always); // var options = new XPdfFontOptions(PdfFontEmbedding.Always); XFont font = new XFont("TRADE GOTHIC BOLD CONDENSED NO. 20", 20, XFontStyle.Bold, options); But it does not work!!. Also I wanted to know in production I'm using Windows server 2008, is there a way I can dynamically add this font in production server even it is not there? As suggested I followed the pdfsharp

Alter PDF - Text repositioning

自闭症网瘾萝莉.ら 提交于 2019-12-01 06:26:02
Is there any way to shift / move the text inside existing pdf page to some other position ? Like there is some text at area x=100, y=100, w=100, h=100 and i want to move it to x=50, y=200, w=100, h=100. I did a lot of research and it seems iTextSharp cannot do that. PDFSharp claims that it can be done but i could not find any examples. One way is to make a bitmap of specific area of the text i want to shift, draw white rectangle over that area and insert bitmap at new location. I don't want to use this solution as i work with large pdf files with more than 1K pages where each page has to be

Combining PDFs with PDFSharp losing form fields

99封情书 提交于 2019-11-30 17:41:38
问题 I am attempting to concatenate two created PDF files to a new PDF using PDFSharp and this code (which I found here): // Open the output document PdfDocument outputDocument = new PdfDocument(); // Iterate files foreach (string file in files) { // Open the document to import pages from it. PdfDocument inputDocument = PdfReader.Open(file, PdfDocumentOpenMode.Import); // Iterate pages int count = inputDocument.PageCount; for (int idx = 0; idx < count; idx++) { // Get the page from the external

How do I display a PDF using PdfSharp in ASP.Net MVC?

二次信任 提交于 2019-11-30 13:46:16
We're making an ASP.Net MVC app that needs to be able to generate a PDF and display it to the screen or save it somewhere easy for the user to access. We're using PdfSharp to generate the document. Once it's finished, how do we let the user save the document or open it up in a reader? I'm especially confused because the PDF is generated server-side but we want it to show up client-side. Here is the MVC controller to create the report that we have written so far: public class ReportController : ApiController { private static readonly string filename = "report.pdf"; [HttpGet] public void