PDFsharp & MigraDoc Foundation
http://forum.pdfsharp.de/

PDF sharp Code
http://forum.pdfsharp.de/viewtopic.php?f=2&t=4538
Page 1 of 1

Author:  siyakubeka [ Mon Jan 22, 2024 9:09 am ]
Post subject:  PDF sharp Code

I have a word document that is a contract. I wish to create a same document but it should be in PDF using PDF sharp or MigraDoc. In this document, I want to be bale to fill in the spaces with data from the database them print it in pdf. I have attached the word document.

This is what I have currently done:

string employerDay = txtEmployerDay.Text;
string employerMonth = txtEmployerMonth.Text;
string employerYear = txtEmployerYear.Text;
string employerPlace = txtEmployerPlace.Text;
string employerName = txtEmployerName.Text;
string employerSurname = txtEmployerSurname.Text;
//Get Days, Months and Years Assignee
string assigneeDay = txtAssigneeDay.Text;
string assigneeMonth = txtAssigneeMonth.Text;
string assigneeYear = txtAssigneeYear.Text;
string assigneePlace = txtAssignerPlace.Text;
string assigneeName = txtAssigneeName.Text;
string assgnerrSurname = txtAssigneeSurname.Text;
string nameAndSurname = txtNameSurname.Text;
string identityNumber = txtIdentityNo.Text;

// Create a new document
Document document = new Document();

// Add sections to the document
Section section = document.AddSection();

// Add a header to the section
HeaderFooter header = section.Headers.Primary;
Paragraph headerParagraph = header.AddParagraph();
headerParagraph.AddText("FIXED TERM CONTRACT");

section.AddParagraph();

// Create a paragraph above the table with specified style
Paragraph headingParagraph = section.AddParagraph();
headingParagraph.Format.LeftIndent = "14.2pt";
headingParagraph.Format.FirstLineIndent = "-14.2pt";
headingParagraph.Format.Alignment = ParagraphAlignment.Justify;
headingParagraph.Format.Font.Size = 6.5;
headingParagraph.Format.Font.Bold = true;
headingParagraph.Format.LineSpacing = 0;


Please assist

Author:  TH-Soft [ Tue Jan 23, 2024 8:35 am ]
Post subject:  Re: PDF sharp Code

siyakubeka wrote:
I have attached the word document.
Have you? Never mind, makes no difference.

The line "section.AddParagraph();" is a good start. Add more text this way.

See also:
https://pdfsharp.net/wiki/HelloMigraDoc-sample.ashx
https://pdfsharp.net/wiki/Invoice-sample.ashx

Page 1 of 1 All times are UTC
Powered by phpBB® Forum Software © phpBB Group
https://www.phpbb.com/