PDFsharp & MigraDoc Foundation

PDFsharp - A .NET library for processing PDF & MigraDoc Foundation - Creating documents on the fly
It is currently Thu Oct 29, 2020 10:58 pm

All times are UTC


Forum rules


Please read this before posting on this forum: Forum Rules



Post new topic Reply to topic  [ 2 posts ] 
Author Message
PostPosted: Thu Oct 15, 2020 5:22 am 
Offline

Joined: Thu Oct 15, 2020 5:16 am
Posts: 1
Hello,

I get no further on the subject.
How can I make a line span several pages?

My Code:

void FillTimeTableContent(int kw, EmployeeModel employee, Table table, Section section)
{
// Iterate the invoice items
Decimal totalExtendedTime = 0;
Decimal dailyExtendedTime = 0;

Color TableBorder = new Color(101, 130, 95);

DateTime date;
Paragraph paragraph = section.AddParagraph();

var orderDispoViews = GlobalConfig.Connection.GetOrderDispoViewWithCWAndEmp(kw, employee.id);
var props = orderDispoViews.Select(x => DateTime.Parse(x.startDate)).Distinct().OrderBy(x => x);
Row row;

foreach (var weekday in props)
{
int i = 0;

foreach (var orderDispo in orderDispoViews)
{
if (weekday == DateTime.Parse(orderDispo.startDate))
{
ICustomer customer = new PrivateCustomerModel();
customer = GlobalConfig.Connection.GetFilterBusinessCustomerWithQuoteName(orderDispo.idquote);
if (customer.Id == 0)
customer = GlobalConfig.Connection.GetFilterPrivateCustomerWithOrderId(orderDispo.id);

var targetObject = new TargetObjectModel();
targetObject = GlobalConfig.Connection.GetTargetObjectWithOrderId(orderDispo.id);

row = table.AddRow();
//row.KeepWith = 2;

if (i == 0)
{
int _mergeDown = orderDispoViews.Where(x => DateTime.Parse(x.startDate) == DateTime.Parse(orderDispo.startDate)).Count();
row.Cells[0].MergeDown = _mergeDown;
row.Cells[0].AddParagraph($"{weekday.ToString("dddd", new CultureInfo("de-DE"))},\n{weekday.ToString("dd.MM.yyyy", new CultureInfo("de-DE"))}");
row.Format.Font.Size = 8;
row.Cells[0].Format.Font.Bold = true;
}

if (customer.DisplayName.Contains('_'))
row.Cells[1].AddParagraph(customer.DisplayName.Substring(0, customer.DisplayName.IndexOf('_')));
else
row.Cells[1].AddParagraph(customer.DisplayName);
row.Format.Font.Size = 8;
row.Cells[1].Format.Alignment = ParagraphAlignment.Left;

row.Cells[2].AddParagraph(orderDispo.service);
row.Format.Font.Size = 8;
row.Cells[2].Format.Alignment = ParagraphAlignment.Left;

if (string.IsNullOrEmpty(targetObject.Description))
row.Cells[3].AddParagraph($"\n{targetObject.Street} {targetObject.HouseNumber}\n {targetObject.ZipCode} {targetObject.City}");
else
row.Cells[3].AddParagraph($"{targetObject.Description}\n{targetObject.Street} {targetObject.HouseNumber}\n {targetObject.ZipCode} {targetObject.City}");
row.Format.Font.Size = 8;
row.Cells[3].Format.Alignment = ParagraphAlignment.Left;

row.Cells[4].AddParagraph($"{orderDispo.startTime} - {orderDispo.endTime}");
row.Format.Font.Size = 8;
row.Cells[4].Format.Alignment = ParagraphAlignment.Left;

row.Cells[5].AddParagraph(orderDispo.times);
row.Format.Font.Size = 8;
row.Cells[5].Format.Alignment = ParagraphAlignment.Right;

var extendedTime = Decimal.Parse(orderDispo.times);

dailyExtendedTime += extendedTime;
i++;
}
}
table.SetEdge(0, table.Rows.Count-1, 8, 1, Edge.Box, MigraDoc.DocumentObjectModel.BorderStyle.Single, 1, TableBorder);

row = table.AddRow();
row.Cells[5].AddParagraph($"\n{dailyExtendedTime}");
row.Format.Font.Size = 8;
row.Format.Font.Bold = true;
row.Cells[5].Format.Alignment = ParagraphAlignment.Right;

totalExtendedTime += dailyExtendedTime;
dailyExtendedTime = 0;
}

row = table.AddRow();
row.Format.Font.Size = 8;
row.Format.Font.Bold = true;

row.Cells[0].AddParagraph($"\nGesamt");
row.Cells[0].MergeRight = 4;
row.Cells[0].Format.Alignment = ParagraphAlignment.Left;

row.Cells[5].AddParagraph($"\n{totalExtendedTime}");
row.Cells[5].Format.Alignment = ParagraphAlignment.Right;
}

public string saveFileInTemp(Document document, string _fileName)
{
document.UseCmykColor = true;

//const bool unicode = false;
//const PdfFontEmbedding embedding = PdfFontEmbedding.Always;

//PdfDocumentRenderer pdfRenderer = new PdfDocumentRenderer(unicode);
PdfDocumentRenderer pdfRenderer = new PdfDocumentRenderer(true, PdfSharp.Pdf.PdfFontEmbedding.Always);

// Associate the MigraDoc document with a renderer
pdfRenderer.Document = document;
// Layout and render document to PDF
pdfRenderer.RenderDocument();

//gibt es das temp-Verzeichnis???
string destPath = CreateOrOpenFile("temp");
deleteFiles(destPath);

//eindeutigen Filename
_fileName = GetUniqueFileName(destPath, _fileName);

_fileName = String.Concat(_fileName, ".pdf");
destPath = Path.Combine(destPath, _fileName);

// Save the document...
pdfRenderer.PdfDocument.Save(destPath);

Process.Start(destPath);

return destPath;
}

Many thanks for the help


Top
 Profile  
Reply with quote  
PostPosted: Thu Oct 15, 2020 8:58 am 
Offline
PDFsharp Expert
User avatar

Joined: Sat Mar 14, 2015 10:15 am
Posts: 580
Location: CCAA
MigraDoc table rows never have pagebreaks. When using tables, make sure no row is larger than a single page.
This may change in the future, but that's how it is now.

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


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

All times are UTC


Who is online

Users browsing this forum: No registered users and 24 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