PDFsharp & MigraDoc Foundation

PDFsharp - A .NET library for processing PDF & MigraDoc Foundation - Creating documents on the fly
It is currently Tue Mar 19, 2024 7:26 am

All times are UTC


Forum rules


Please read this before posting on this forum: Forum Rules



Post new topic Reply to topic  [ 3 posts ] 
Author Message
PostPosted: Fri Apr 28, 2023 7:30 am 
Offline

Joined: Fri Apr 28, 2023 7:07 am
Posts: 2
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;


Attachments:
File comment: RDDDL file
prob.zip [553 Bytes]
Downloaded 120 times
Top
 Profile  
Reply with quote  
PostPosted: Fri Apr 28, 2023 7:42 am 
Offline
PDFsharp Expert
User avatar

Joined: Sat Mar 14, 2015 10:15 am
Posts: 905
Location: CCAA
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.

_________________
Best regards
Thomas
(Freelance Software Developer with several years of MigraDoc/PDFsharp experience)


Top
 Profile  
Reply with quote  
PostPosted: Fri Apr 28, 2023 7:58 am 
Offline

Joined: Fri Apr 28, 2023 7:07 am
Posts: 2
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.


Top
 Profile  
Reply with quote  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 3 posts ] 

All times are UTC


Who is online

Users browsing this forum: Google [Bot] and 52 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
cron
Privacy Policy, Data Protection Declaration, Impressum
Powered by phpBB® Forum Software © phpBB Group