PDFsharp & MigraDoc Foundation https://forum.pdfsharp.net/ |
|
Deleted column in table https://forum.pdfsharp.net/viewtopic.php?f=2&t=4605 |
Page 1 of 1 |
Author: | viking [ Tue Jun 11, 2024 12:33 pm ] |
Post subject: | Deleted column in table |
It is posible deleted column in created table? |
Author: | TH-Soft [ Tue Jun 11, 2024 1:18 pm ] |
Post subject: | Re: Deleted column in table |
It is possible to delete a column from a MigraDoc table. |
Author: | viking [ Tue Jun 11, 2024 6:01 pm ] |
Post subject: | Re: Deleted column in table |
Sorry, is it possible to delete a column from a MigraDoc table, which method to use? |
Author: | TH-Soft [ Wed Jun 12, 2024 6:41 am ] |
Post subject: | Re: Deleted column in table |
The MigraDoc "Table" class has a "Columns" property that provides the "RemoveObjectAt" method. Index is 0-based. |
Author: | viking [ Wed Jun 12, 2024 7:57 am ] |
Post subject: | Re: Deleted column in table |
When I use "RemoveObjectAt" method, pdfRenderer.RenderDocument(); calls Exception: Code: System.NullReferenceException HResult=0x80004003 Message=Object reference not set to an instance of an object. Source=MigraDoc.DocumentObjectModel StackTrace: at MigraDoc.DocumentObjectModel.Visitors.VisitorBase.VisitParagraph(Paragraph paragraph) at MigraDoc.DocumentObjectModel.Paragraph.MigraDoc.DocumentObjectModel.Visitors.IVisitable.AcceptVisitor(DocumentObjectVisitor visitor, Boolean visitChildren) at MigraDoc.DocumentObjectModel.DocumentElements.MigraDoc.DocumentObjectModel.Visitors.IVisitable.AcceptVisitor(DocumentObjectVisitor visitor, Boolean visitChildren) at MigraDoc.DocumentObjectModel.Tables.Cell.MigraDoc.DocumentObjectModel.Visitors.IVisitable.AcceptVisitor(DocumentObjectVisitor visitor, Boolean visitChildren) at MigraDoc.DocumentObjectModel.Tables.Row.MigraDoc.DocumentObjectModel.Visitors.IVisitable.AcceptVisitor(DocumentObjectVisitor visitor, Boolean visitChildren) at MigraDoc.DocumentObjectModel.Tables.Rows.MigraDoc.DocumentObjectModel.Visitors.IVisitable.AcceptVisitor(DocumentObjectVisitor visitor, Boolean visitChildren) at MigraDoc.DocumentObjectModel.Tables.Table.MigraDoc.DocumentObjectModel.Visitors.IVisitable.AcceptVisitor(DocumentObjectVisitor visitor, Boolean visitChildren) at MigraDoc.DocumentObjectModel.DocumentElements.MigraDoc.DocumentObjectModel.Visitors.IVisitable.AcceptVisitor(DocumentObjectVisitor visitor, Boolean visitChildren) at MigraDoc.DocumentObjectModel.Section.MigraDoc.DocumentObjectModel.Visitors.IVisitable.AcceptVisitor(DocumentObjectVisitor visitor, Boolean visitChildren) at MigraDoc.DocumentObjectModel.Sections.MigraDoc.DocumentObjectModel.Visitors.IVisitable.AcceptVisitor(DocumentObjectVisitor visitor, Boolean visitChildren) at MigraDoc.DocumentObjectModel.Document.MigraDoc.DocumentObjectModel.Visitors.IVisitable.AcceptVisitor(DocumentObjectVisitor visitor, Boolean visitChildren) at MigraDoc.DocumentObjectModel.Visitors.VisitorBase.Visit(DocumentObject documentObject) at MigraDoc.Rendering.DocumentRenderer.PrepareDocument() at MigraDoc.Rendering.PdfDocumentRenderer.PrepareDocumentRenderer(Boolean prepareCompletely) at MigraDoc.Rendering.PdfDocumentRenderer.PrepareRenderPages() at MigraDoc.Rendering.PdfDocumentRenderer.RenderDocument() My method: Code: public static void TabelWithBorderTest() { var document = new Document(); // Add a section to the document. var section = document.AddSection(); Table table = section.AddTable(); table.Borders.Width = 0.25; table.Rows.LeftIndent = 0; // Before you can add a row, you must define the columns Column column = table.AddColumn("7cm"); column.Format.Alignment = ParagraphAlignment.Left; // table.AddColumn("8cm"); // Row row = table.AddRow(); row.Cells[0].AddParagraph("Text 1"); // row.Cells[1].AddParagraph("Text 2"); table.Columns.RemoveObjectAt(0); // // Create a renderer for the MigraDoc document. var pdfRenderer = new PdfDocumentRenderer(false) { Document = document }; // Associate the MigraDoc document with a renderer. // Layout and render document to PDF. pdfRenderer.RenderDocument(); // Save the document... const string filename = "Table.pdf"; pdfRenderer.PdfDocument.Save(filename); // ...and start a viewer. Process.Start(filename); } Any ideas? |
Author: | TH-Soft [ Wed Jun 12, 2024 8:29 am ] |
Post subject: | Re: Deleted column in table |
viking wrote: Any ideas? I have no idea why you add a column and then delete it again, but it should work.Are you using 6.1.0 final? See also: https://docs.pdfsharp.net/General/Issue-Reporting.html |
Author: | viking [ Wed Jun 12, 2024 10:11 am ] |
Post subject: | Re: Deleted column in table |
I use 6.1.0 final. I have table in two variants. I create first all columns, next delete selected. |
Author: | viking [ Thu Jun 13, 2024 8:05 am ] | ||
Post subject: | Re: Deleted column in table | ||
When I create all columns but I dont use AddParagraph(); program is correct Example: Code: Table table = section.AddTable(); table.AddColumn("7cm"); table.AddColumn("7cm"); Row row = table.AddRow(); table.Rows[0].Cells[0].AddParagraph("Text 1"); table.Columns.RemoveObjectAt(1); If I use AddParagraph(); calls Exception in attach my project.
|
Page 1 of 1 | All times are UTC |
Powered by phpBB® Forum Software © phpBB Group https://www.phpbb.com/ |