PDFsharp & MigraDoc Foundation
https://forum.pdfsharp.net/

Incorporate PDFSharp with MigraDoc
https://forum.pdfsharp.net/viewtopic.php?f=2&t=145
Page 1 of 1

Author:  neto_pf [ Tue May 22, 2007 3:26 pm ]
Post subject:  Incorporate PDFSharp with MigraDoc

I'm new in PDFSharp and I don't know how to insert a table in a existing pdf file which is in my disk.
In PDFSharp it's easy to do it, but in MigraDoc it isn't (or I don't saw anything), could someone help me with this problem.
I want to edit an exiting pdf file and put there one table, or could I put a MigraDoc Document inside a PDFDocument or vice versa?

Author:  Thomas Hoevel [ Tue May 22, 2007 3:38 pm ]
Post subject: 

You can use MigraDoc to create a new PDF file with the table, then use PDFsharp to add pages from that PDF file to your "old" PDF file.

Adding new pages is quite simple and several PDFsharp samples show the trick.

I hope this helps...

Author:  neto_pf [ Thu May 24, 2007 8:49 am ]
Post subject:  Incorporate PDFSharp with MigraDoc

Thank you Thomas for your help, but like I said I'm new in PDFSharp, thats why I will put another post, How do I add a Document in MigraDoc to PDFDocument in PDFSharp? This is my code:

Table table = new Table();
table.Borders.Width = 0.75;

Column column = table.AddColumn(Unit.FromCentimeter(2));
column.Format.Alignment = ParagraphAlignment.Center;

column = table.AddColumn(Unit.FromCentimeter(5));

Cell cell;
Row row = table.AddRow();
row.Shading.Color = Colors.PaleGoldenrod;
cell = row.Cells[0];
cell.AddParagraph("Itemus");
cell = row.Cells[1];
cell.AddParagraph("Descriptum");

row = table.AddRow();
cell = row.Cells[0];
cell.AddParagraph("1");
cell = row.Cells[1];
cell.AddParagraph(BlindText.ShortText);

row = table.AddRow();
cell = row.Cells[0];
cell.AddParagraph("2");
cell = row.Cells[1];
cell.AddParagraph(BlindText.Text);

table.SetEdge(0, 0, 2, 3, Edge.Box, BorderStyle.Single, 1.5, Colors.Black);

Document docTable = new Document();
docTable.LastSection.Add(table);


PdfDocument docPDF = PdfSharp.Pdf.IO.PdfReader.Open("c:\\test.pdf");
//this will not work, right?
docPDF.Pages.Add(docTable);

Can I add a MigraDoc Table to a XRect through the class XGraphics with the PDF?

Thank you for your help.

Author:  Thomas Hoevel [ Thu May 24, 2007 9:57 am ]
Post subject:  Re: Incorporate PDFSharp with MigraDoc

neto_pf wrote:
Can I add a MigraDoc Table to a XRect through the class XGraphics with the PDF?

You can use a PdfDocumentRenderer to create a PDF file from your MigraDoc document.
Pages from this newly created PDF file can be used with XGraphics. Samples like TwoPagesOnOne show you how to do this.
A more elegant way may come with future versions. Now you have to live with a temporary PDF file - this should be no performance issue however.

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