pdfsharp

'PDFsharp cannot handle this PDF feature introduced with Acrobat 6' error while opening PDF file

為{幸葍}努か 提交于 2019-11-27 15:53:06
问题 I use PDFsharp (v1.32) for merging several PDF files. I open documents using this code: PdfDocument inputDocument = PdfReader.Open(pdfFilePath, PdfDocumentOpenMode.Import); And while opening one document (with PDF version 1.5 (Acrobat 6.x)) I receive an exception: An unhandled exception of type 'PdfSharp.Pdf.IO.PdfReaderException' occurred in PdfSharp.dll Additional information: Cannot handle iref streams. The current implementation of PDFsharp cannot handle this PDF feature introduced with

Overlay image onto PDF using PDFSharp

筅森魡賤 提交于 2019-11-27 15:52:49
问题 Can't seem to find much out there for this. I've a PDF, onto which I'd like to overlay an image of an electronic signature. Any suggestions on how to accomplish that using PDFSharp? Thanks 回答1: Try the following private void GeneratePDF(string filename, string imageLoc) { PdfDocument document = new PdfDocument(); // Create an empty page or load existing PdfPage page = document.AddPage(); // Get an XGraphics object for drawing XGraphics gfx = XGraphics.FromPdfPage(page); DrawImage(gfx,

PDFsharp: Is there a way to generate “Page X of Y” in the header of the page?

两盒软妹~` 提交于 2019-11-27 11:35:05
问题 It seems rather simple, but I can't find something like getPageCount() in the API. I can get it to return the current page, but not the total number of pages. Perhaps I'm missing it? I would like to somehow be able to print 'Page 1 of 9' at the top of every page, where '1' of course is the current page number. 回答1: With PDFsharp it's up to you. I presume you are using MigraDoc: With MigraDoc you can add a page header. Add paragraph.AddPageField() for the current page number and paragraph

WPF to XPS to PDF

我的未来我决定 提交于 2019-11-27 04:31:01
问题 I have implemented a report in standard WPF controls and have also implemented a DocumentPaginator to take these controls and convert them into a document for printing. I have also implemented some code which uses the document paginator to render the pages to images and write them out to a PDF using PDFSharp, however this does not allow for copying and pasting, also the image quality is questionable. I have experimented with the GhostXPS utility and was thinking of using it by saving out to

C# Extract text from PDF using PdfSharp

一世执手 提交于 2019-11-27 04:24:29
问题 Is there a possibility to extract plain text from a PDF-File with PdfSharp? I don't want to use iTextSharp because of its license. 回答1: Took Sergio's answer and made some extension methods. I also changed the accumulation of strings into an iterator. public static class PdfSharpExtensions { public static IEnumerable<string> ExtractText(this PdfPage page) { var content = ContentReader.ReadContent(page); var text = content.ExtractText(); return text; } public static IEnumerable<string>