PDFsharp & MigraDoc Foundation

PDFsharp - A .NET library for processing PDF & MigraDoc Foundation - Creating documents on the fly
It is currently Thu Mar 28, 2024 12:33 pm

All times are UTC


Forum rules


Please read this before posting on this forum: Forum Rules



Post new topic Reply to topic  [ 4 posts ] 
Author Message
PostPosted: Tue May 22, 2007 3:26 pm 
Offline

Joined: Tue May 22, 2007 3:17 pm
Posts: 2
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?


Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: Tue May 22, 2007 3:38 pm 
Offline
PDFsharp Guru
User avatar

Joined: Mon Oct 16, 2006 8:16 am
Posts: 3095
Location: Cologne, Germany
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...

_________________
Regards
Thomas Hoevel
PDFsharp Team


Top
 Profile  
Reply with quote  
PostPosted: Thu May 24, 2007 8:49 am 
Offline

Joined: Tue May 22, 2007 3:17 pm
Posts: 2
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.


Top
 Profile  
Reply with quote  
PostPosted: Thu May 24, 2007 9:57 am 
Offline
PDFsharp Guru
User avatar

Joined: Mon Oct 16, 2006 8:16 am
Posts: 3095
Location: Cologne, Germany
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.

_________________
Regards
Thomas Hoevel
PDFsharp Team


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

All times are UTC


Who is online

Users browsing this forum: Baidu [Spider] and 125 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