PDFsharp & MigraDoc Foundation http://forum.pdfsharp.de/ |
|
New page if page is filled http://forum.pdfsharp.de/viewtopic.php?f=2&t=1584 |
Page 1 of 1 |
Author: | Afnan [ Wed Mar 16, 2011 11:08 am ] |
Post subject: | New page if page is filled |
Hi there i had been sucessfully using this great library PDF Sharp.now i wanted to play with some dynamic Stuff so people recomended to switch to Migradoc I did and like its paragraph feature.Now the problem is that when i add long paragraph then new page is not added instead of that there is incomplete text shown(incomplete in sense that text overflows) and i have added a image at the bottom for footer look.how can i do that i enter dynamic text (variable length ) and it just adds the required Number of pages. My code so far is Code: XFont font = new XFont("Times New Roman", 12, XFontStyle.Bold);
XFont fontReg = new XFont("Times New Roman", 12, XFontStyle.Regular); // HACKĀ² gfx.MUH = PdfFontEncoding.Unicode; gfx.MFEH = PdfFontEmbedding.Default; string appPath = System.IO.Path.GetDirectoryName(System.Windows.Forms.Application.ExecutablePath); XImage image = XImage.FromFile(appPath + "/header.png"); gfx.DrawImage(image, 0, 0); //Civil Stamp gfx.DrawImage(XImage.FromFile(appPath + "/cStamp.png"), 370, 380); gfx.DrawImage(XImage.FromFile(appPath + "/Sp.png"), 230, 380); CoverPageHeader(); Document doc = new Document(); MigraDoc.DocumentObjectModel.Section sec = doc.AddSection(); // Add a single paragraph with some text and format information. MigraDoc.DocumentObjectModel.Paragraph para = sec.AddParagraph(); para.Format.Alignment = ParagraphAlignment.Left; para.Format.Font.Name = "Times New Roman"; para.Format.Font.Size = 12; para.Format.Font.Color = MigraDoc.DocumentObjectModel.Colors.Black; para.AddText("We are pleased to present the attached Document Please review the Agreement and, if acceptable, " + "sign one copy and return it to us. We will sign the copy of the agreement and return one for " + "your records."); para.AddLineBreak(); para.AddLineBreak(); para.AddText(longlongtextString); para.AddLineBreak(); para.AddLineBreak(); para.AddText("Sincerely,"); MigraDoc.Rendering.DocumentRenderer docRenderer = new DocumentRenderer(doc); docRenderer.PrepareDocument(); // Render the paragraph. You can render tables or shapes the same way. docRenderer.RenderObject(gfx, XUnit.FromCentimeter(0.7), XUnit.FromCentimeter(9), "18cm", para); gfx.DrawString("Kelly Turbin PhD., P.E.-SECB", font, XBrushes.Black, 20, 500); gfx.DrawString("Principal", font, XBrushes.Black, 20, 520); gfx.DrawString("Project No " + textBoxProjNumber.Text, fontReg, XBrushes.Black, 20,785); gfx.DrawImage(XImage.FromFile(appPath + "/AccB.png"), 20, 700); gfx.DrawImage(XImage.FromFile(appPath + "/ScreenMagic.png"), 100, 690); gfx.DrawImage(XImage.FromFile(appPath + "/Footer.png"), 220, 750); } |
Author: | Thomas Hoevel [ Wed Mar 16, 2011 12:22 pm ] |
Post subject: | Re: New page if page is filled |
Hi, Afnan, Don't use RenderObject, instead use RenderDocument and pages will be created automatically as needed. Sample code here: http://www.pdfsharp.net/wiki/HelloMigraDoc-sample.ashx |
Author: | Afnan [ Wed Mar 16, 2011 12:29 pm ] |
Post subject: | Re: New page if page is filled |
if i change the last lines of the code then nothing is seen in pdf Code: PdfDocumentRenderer renderer = new PdfDocumentRenderer(true, PdfSharp.Pdf.PdfFontEmbedding.Always);
renderer.Document = doc; renderer.RenderDocument(); |
Author: | Thomas Hoevel [ Wed Mar 16, 2011 1:16 pm ] |
Post subject: | Re: New page if page is filled |
I'd go the other way: I'd start with the Hello World sample and change the CreateDocument() method. |
Page 1 of 1 | All times are UTC |
Powered by phpBB® Forum Software © phpBB Group https://www.phpbb.com/ |