PDFsharp & MigraDoc Foundation http://forum.pdfsharp.de/ |
|
Compatibility issue between versions 1.5 and 6.0 http://forum.pdfsharp.de/viewtopic.php?f=2&t=4541 |
Page 1 of 1 |
Author: | JSvak [ Thu Jan 25, 2024 9:26 am ] |
Post subject: | Compatibility issue between versions 1.5 and 6.0 |
Hello, I have upgraded PDFsharp-MigraDoc NuGet package from version 1.5 to 6.0.0 (latest stable) in an ASP.NET application. A piece of old code, which used to work before, always fails with the new version. Our code loads a PDF template document with some pictures and inserts more content into it. Rendering a table using DocumentRenderer crashes with a InvalidOperationException exception. I have isolated the issue. It's reproducible when I run this code in a console application in .NET8: Code: using FileStream templateFile = File.OpenRead("d:\\template.pdf"); PdfDocument templateDoc = PdfReader.Open(templateFile, PdfDocumentOpenMode.Modify); PdfPage page = templateDoc.Pages[0]; XGraphics gfx = XGraphics.FromPdfPage(page); Document doc = new(); Table table = doc.AddSection().AddTable(); table.AddColumn(Unit.FromCentimeter(5)); table.AddColumn(Unit.FromCentimeter(5)); table.AddColumn(Unit.FromCentimeter(5)); var row = table.AddRow(); row.Style = "Row"; row.Cells[0].AddParagraph("Cell1"); row.Cells[1].AddParagraph("Cell2"); row.Cells[2].AddParagraph("Cell3"); DocumentRenderer docRenderer = new(doc); docRenderer.PrepareDocument(); docRenderer.RenderObject(gfx, XUnit.FromCentimeter(1.0), XUnit.FromCentimeter(11.0), "12cm", table); Running it with PDFsharp-MigraDoc 6.0.0 or 6.1.0-preview-1 throws this exception: Code: Unhandled exception. System.InvalidOperationException: 'FieldInfos' must not be null here. at PdfSharp.Diagnostics.NRT.ThrowOnNull[TResult](String message) at MigraDoc.Rendering.FormattedCell.MigraDoc.Rendering.IAreaProvider.get_AreaFieldInfos() at MigraDoc.Rendering.TopDownFormatter.FormatOnAreas(XGraphics gfx, Boolean topLevel) at MigraDoc.Rendering.FormattedCell.Format(XGraphics gfx) at MigraDoc.Rendering.TableRenderer.FormatCells() at MigraDoc.Rendering.TableRenderer.InitFormat(Area area, FormatInfo previousFormatInfo) at MigraDoc.Rendering.TableRenderer.Format(Area area, FormatInfo previousFormatInfo) at MigraDoc.Rendering.DocumentRenderer.RenderObject(XGraphics graphics, XUnit xPosition, XUnit yPosition, XUnit width, DocumentObject documentObject) The same code works fine with PDFsharp-MigraDoc ver. 1.5 Is there a bug in the new version? Is there any better way to add a table into an existing document? |
Author: | TH-Soft [ Mon Jan 29, 2024 7:17 pm ] |
Post subject: | Re: Compatibility issue between versions 1.5 and 6.0 |
JSvak wrote: Is there a bug in the new version? I think it's a bug.Should be fixed with version 6.1.0-preview-2. |
Page 1 of 1 | All times are UTC |
Powered by phpBB® Forum Software © phpBB Group https://www.phpbb.com/ |