PDFsharp & MigraDoc Foundation https://forum.pdfsharp.net/ |
|
Migradoc table cell problem with TextFrame https://forum.pdfsharp.net/viewtopic.php?f=2&t=4433 |
Page 1 of 1 |
Author: | marc_al [ Fri Apr 28, 2023 7:30 am ] | ||
Post subject: | Migradoc table cell problem with TextFrame | ||
Hello, I am doping tests to see if Migradoc can be useful for me and I have seen a problem while doing my tests. The idea would be to read a RDLC document and convert it to PDF without the reportviewer. I create a table and in a cell I want to have some texts at specific locations. (TextFrames). The problem is that the locations of the texts are ignored. If I don't set the WrapFormat there is the first text and on the next line the second line. With the WrapFormat both texts are exactly in the same place. Can you please tell me what I do wrong? I use the PDFSharp-Migradoc-gdi version 1.50.5147 (preview 2 had the same problem) in a desktop application c#6 (not WPF) What I would expect is that the Left And Top properties are used. Changing the relative Horizontal and Vertical didn't help either. The problem is with the pdf file too. I can also zip the project if you want. Thank you Marc Here is my code (simple project) Code: System.Text.Encoding.RegisterProvider(System.Text.CodePagesEncodingProvider.Instance);
Document document = new Document(); var Sec = document.AddSection(); var tb = Sec.AddTable(); tb.AddColumn(MigraDoc.DocumentObjectModel.Unit.FromCentimeter(4)); tb.AddColumn(MigraDoc.DocumentObjectModel.Unit.FromCentimeter(12)); var NewRow = tb.AddRow(); NewRow.Height = MigraDoc.DocumentObjectModel.Unit.FromCentimeter(5); NewRow.Cells[0].AddParagraph().AddText("TEST COL1"); var TF1 = NewRow.Cells[1].AddTextFrame(); TF1.Left = MigraDoc.DocumentObjectModel.Unit.FromCentimeter(0); TF1.Top = MigraDoc.DocumentObjectModel.Unit.FromCentimeter(0); TF1.Width = MigraDoc.DocumentObjectModel.Unit.FromCentimeter(4); TF1.Height = MigraDoc.DocumentObjectModel.Unit.FromCentimeter(1); TF1.RelativeHorizontal = MigraDoc.DocumentObjectModel.Shapes.RelativeHorizontal.Column ; TF1.RelativeVertical = MigraDoc.DocumentObjectModel.Shapes.RelativeVertical.Paragraph; TF1.AddParagraph().AddText("C2Part1"); TF1.WrapFormat.Style = MigraDoc.DocumentObjectModel.Shapes.WrapStyle.Through; var TF2 = NewRow.Cells[1].AddTextFrame(); TF2.Left = MigraDoc.DocumentObjectModel.Unit.FromCentimeter(8); TF2.Top = MigraDoc.DocumentObjectModel.Unit.FromCentimeter(0.5); TF2.Width = MigraDoc.DocumentObjectModel.Unit.FromCentimeter(4); TF2.Height = MigraDoc.DocumentObjectModel.Unit.FromCentimeter(1); TF2.RelativeHorizontal = MigraDoc.DocumentObjectModel.Shapes.RelativeHorizontal.Column; TF2.RelativeVertical = MigraDoc.DocumentObjectModel.Shapes.RelativeVertical.Paragraph ; TF2.AddParagraph().AddText("C2Part2"); TF2.WrapFormat.Style = MigraDoc.DocumentObjectModel.Shapes.WrapStyle.Through; PdfDocumentRenderer pdfRenderer = new PdfDocumentRenderer(true); pdfRenderer.Document = document; pdfRenderer.RenderDocument(); pdfRenderer.Save("tstdoc.pdf"); docPrev.Document = document;
|
Author: | TH-Soft [ Fri Apr 28, 2023 7:42 am ] |
Post subject: | Re: Migradoc table cell problem with TextFrame |
TextFrames are tricky. I would try to use tables only for the task. You can have two rows in the second column and use MergeDown=1 to have only 1 cell in the left column. IMHO this will give you more flexibility with respect to linebreaks. Is that an option for you? Tables in table cells are also possible with a trick, but it is better to work with just a single table. |
Author: | marc_al [ Fri Apr 28, 2023 7:58 am ] |
Post subject: | Re: Migradoc table cell problem with TextFrame |
Hello, It is a good idea. I need to analyze every controls to put in the cell to create a table in the second cell (that could have multiple rows / columns). Using a table in the first cell will be simpler (I think) than making one big table where I need to merge a lot of cells. You talked about a trick to do it? I guess you mean that i need to add a TextFrame in the cell (location 0,0....) and add a table in the textframe? Thank you for the idea. |
Page 1 of 1 | All times are UTC |
Powered by phpBB® Forum Software © phpBB Group https://www.phpbb.com/ |