pdfsharp

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

血红的双手。 提交于 2019-11-29 01:22:50
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 Acrobat 6. What can I do with it? I need to merge all files, I cannot just skip it. I tried to find

Keep table in one piece MigraDoc / PDFsharp

倖福魔咒の 提交于 2019-11-29 00:57:48
问题 I am using PDFsharp / MigraDoc to write tables and charts to PDF files. This worked great so far, however MigraDoc will always split my tables (vertically) when it should move the whole table to the next page in the document. How do I make sure the table will stay in one piece? Table class of MigraDoc.DocumentObjectModel.Tables has a bool KeepTogether property however it seems to have no effect (either set to true or false). Is there a way to do it manually? Is there any way to "measure" the

Export PDF to JPG(s) in C# [closed]

做~自己de王妃 提交于 2019-11-28 23:37:29
I need to save a one page pdf document as an image for a thumbnail on a website. I've been messing around with PDFSharp and have had no luck. I have tried this: http://www.pdfsharp.net/wiki/ExportImages-sample.ashx?AspxAutoDetectCookieSupport=1 but all it does is extract the embedded images in the PDF file which is not the desired result. Ideas on how to do this? Anyone know a good library that can handle this? Edit: Please let me know why this is such a bad question. If anyone has a good solution to this it would be a great resource for many other people. Especially since google searches come

PDFsharp Line Break

此生再无相见时 提交于 2019-11-28 22:54:07
I am trying to get new line but if I use \n it does not help any way to have new line by adding something to string like \r\n (does not work) gfx.DrawString("Project No \n" + textBoxProjNumber.Text, fontUnder, XBrushes.Black, 230, 95); does not work. Have you tried the XTextFormatter class? See here: http://www.pdfsharp.net/wiki/TextLayout-sample.ashx Code snippet: PdfDocument document = new PdfDocument(); PdfPage page = document.AddPage(); XGraphics gfx = XGraphics.FromPdfPage(page); XFont font = new XFont("Times New Roman", 10, XFontStyle.Bold); XTextFormatter tf = new XTextFormatter(gfx);

C# Extract text from PDF using PdfSharp

旧巷老猫 提交于 2019-11-28 20:08:08
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. 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> ExtractText(this CObject cObject) { if (cObject is COperator) { var cOperator = cObject as COperator; if (cOperator

Generate PDF based on HTML code (iTextSharp, PDFSharp?)

眉间皱痕 提交于 2019-11-28 18:49:19
Does the library PDFSharp can - like iTextSharp - generate PDF files * take into account HTML formatting * ? (bold (strong), spacing (br), etc.) Previously I used iTextSharp and roughly handled in such a way (code below): string encodingMetaTag = "<meta http-equiv=\"Content-Type\" content=\"text/html; charset=utf-8\" />"; string htmlCode = "text <div> <b> bold </ b> or <u> underlined </ u> <div/>"; var sr = new StringReader (encodingMetaTag + htmlCode); var pdfDoc = new Document (PageSize.A4, 10f, 10f, 10f, 0f); var = new HTMLWorker htmlparser (pdfDoc); PdfWriter.GetInstance (pdfDoc,

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

微笑、不失礼 提交于 2019-11-28 18:40:31
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. 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.AddNumPagesField() for the total page count. Sample that uses AddPageField Code snippet from the sample: //

MigraDoc - imbricated / nested tables?

时光怂恿深爱的人放手 提交于 2019-11-28 08:18:32
问题 I would like to add a table inside another table (inside a specific cell). I can't find a way to add a Table object to a Cell object. Is that simply impossible? Alternatively, I may merge some cells, but I can't find any sample in MigraDoc website with cells merging. Here is my code : Table parentTable = new Table(); parentTable.AddColumn(Unit.FromCentimeter(9)); Row parentRow = parentTable.AddRow(); Cell parentCell = parentRow.Cells[0]; Table currentTable = new Table(); currentTable

WPF to XPS to PDF

时光怂恿深爱的人放手 提交于 2019-11-27 21:25:35
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 an XPS document and then using GhostXPS to convert it to a PDF, this was promising, however the current

How to use private fonts in PDFSharp

徘徊边缘 提交于 2019-11-27 19:00:33
问题 I am trying to add text to a PDF document using private, i.e. not installed on the system, TrueType fonts and having trouble. I am using PDFSharp + MigraDoc WPF version 1.32.2608.0 from NuGet. I have found numerous items on the forum and on StackOverFlow. The latest is this stackoverflow article which refers to this example on the PdfSharp site. However this example contains the code: this.fontFamilies.Add(key, fontFamily); on line 22, but I cannot find any reference to fontFamilies in