PDFsharp & MigraDoc Foundation

PDFsharp - A .NET library for processing PDF & MigraDoc Foundation - Creating documents on the fly
It is currently Thu Apr 18, 2024 12:53 am

All times are UTC


Forum rules


Please read this before posting on this forum: Forum Rules



Post new topic Reply to topic  [ 6 posts ] 
Author Message
 Post subject: My first Pdf ( Help ! )
PostPosted: Thu Jan 12, 2017 1:17 pm 
Offline

Joined: Thu Jan 12, 2017 1:07 pm
Posts: 3
This is my code part.

Code:
            MigraDoc.DocumentObjectModel.Tables.Table table = new MigraDoc.DocumentObjectModel.Tables.Table();
            table.Borders.Width = 0.5;
            table.Format.PageBreakBefore = true;
            ControlCollection a = pnlDebitorInfo.Controls;
            List<Label> c = a.OfType<Label>().ToList();
       
           
            Row row = null;
            Cell cell = null;
            for (int i = 0; i < c.Count; i++)
            {
                var col = table.AddColumn(MigraDoc.DocumentObjectModel.Unit.FromCentimeter(3));
                col.Format.Alignment = MigraDoc.DocumentObjectModel.ParagraphAlignment.Center;
                col.Format.PageBreakBefore = true;
            }
            row = table.AddRow();
            for (int i = 0; i < c.Count; i++)
            {
                cell = row.Cells[i];
                cell.AddParagraph(c[i].ID.Remove(0, 3) + " : ");
                cell.Format.PageBreakBefore = true;
            }

            row = table.AddRow();
            for (int i = 0; i < c.Count; i++)
            {
                cell = row.Cells[i];
                cell.AddParagraph(c[i].Text);
            }
            doc.LastSection.Add(table);
            PdfDocumentRenderer docRend=new MigraDoc.Rendering.PdfDocumentRenderer(false);
           
            docRend.Document = doc;
            docRend.RenderDocument();


Attachment:
image.png
image.png [ 28.6 KiB | Viewed 6550 times ]


I will generate this two tables in ASP.NET .I need help cell text width and table fit in a PDF Page.

Thank you for helping :)


Top
 Profile  
Reply with quote  
PostPosted: Thu Jan 12, 2017 2:28 pm 
Offline
PDFsharp Guru
User avatar

Joined: Mon Oct 16, 2006 8:16 am
Posts: 3096
Location: Cologne, Germany
Hi!

You can attach images to forum posts. No need to link to image hosters that hide the image amongst dozens of ads.

tabutcu_55 wrote:
I will generate this two tables in ASP.NET .I need help cell text width and table fit in a PDF Page.
I need help to understand what you need.

There are 21 cm in an A4 page. You define how much goes to left margin and right margin and how you assign the remainder to the columns you need.

_________________
Regards
Thomas Hoevel
PDFsharp Team


Top
 Profile  
Reply with quote  
PostPosted: Thu Jan 12, 2017 6:55 pm 
Offline

Joined: Thu Jan 12, 2017 1:07 pm
Posts: 3
I am sorry for pictures.
Hi !

You can see my columns I have 10 ten columns maybe later 12 and the width of colums is big.
For me is the important thing is when I have later mre columns as yet i will not update my pdf class.
it should go to next line when the width is finish for A4 or I create different table but i can not find samples about tables.

And the another problem is the width of colums it goes out cell the text.Cell lenght is longer then column header how i can set it auto

I am sorry again for the pictures and for my english.I am a software engineer in the last class and I am working in a great place. I need it for my job.
Thank you for your helping.


Top
 Profile  
Reply with quote  
PostPosted: Fri Jan 13, 2017 8:46 am 
Offline
PDFsharp Expert
User avatar

Joined: Sat Mar 14, 2015 10:15 am
Posts: 913
Location: CCAA
Text in cells breaks to the next line automatically. Opportunities for linebreaks are blanks, hyphens and soft hyphens. If you have long "words" without blanks or hyphens, insert soft hyphens where you would allow linebreaks.
No linebreaks when you test with text like "Qweqweqweqweqweqweqweqweqweqweqweqweqweqwe". Use realistic text like "Qweqwe qwe qweqwe qwe qweqweqwe qwe qwe qweqwe qwe qweqweqwe qwe qweqweqwe" or "Lorem ipsum ..." for testing.

There is no "Auto" for column widths. You must specify the width for every column.

You can set the page to Landscape to have more space for columns.
If the PDF is primarily for on-screen usage, you can even increase the page width to make room for more columns.
That's what we do in some applications.

Samples with tables:
http://pdfsharp.net/wiki/Invoice-sample.ashx
http://pdfsharp.net/wiki/HelloMigraDoc-sample.ashx

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


Top
 Profile  
Reply with quote  
PostPosted: Mon Jan 16, 2017 7:33 am 
Offline

Joined: Thu Jan 12, 2017 1:07 pm
Posts: 3
Hi again :)

I am thank you first for you helping.

I make up with HtmlRenderer Demo Winform and I have one problem .. :)

Code:
 PdfGenerateConfig config = new PdfGenerateConfig { PageSize = PageSize.A4, PageOrientation = PageOrientation.Landscape};
            config.SetMargins(20);

            var doc = PdfGenerator.GeneratePdf(stringBuilder.ToString(), config);


How can I set the pages auto.I attach the picture

Thank you.


Attachments:
File comment: This is the fail for paging.
bbbb.png
bbbb.png [ 22.83 KiB | Viewed 6538 times ]
Top
 Profile  
Reply with quote  
PostPosted: Mon Jan 16, 2017 10:58 am 
Offline
PDFsharp Guru
User avatar

Joined: Mon Oct 16, 2006 8:16 am
Posts: 3096
Location: Cologne, Germany
tabutcu_55 wrote:
I make up with HtmlRenderer Demo Winform and I have one problem .. :)
HtmlRenderer is not part of PDFsharp. I cannot help you with that problem and I know no-one who can help.

_________________
Regards
Thomas Hoevel
PDFsharp Team


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

All times are UTC


Who is online

Users browsing this forum: Google [Bot] and 69 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:  
Privacy Policy, Data Protection Declaration, Impressum
Powered by phpBB® Forum Software © phpBB Group