PDFsharp & MigraDoc Foundation

PDFsharp - A .NET library for processing PDF & MigraDoc Foundation - Creating documents on the fly
It is currently Sun Jun 30, 2024 8:24 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: Wed Mar 16, 2011 11:08 am 
Offline

Joined: Thu Dec 09, 2010 9:44 pm
Posts: 3
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);

        }


Top
 Profile  
Reply with quote  
PostPosted: Wed Mar 16, 2011 12:22 pm 
Offline
PDFsharp Guru
User avatar

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

_________________
Regards
Thomas Hoevel
PDFsharp Team


Top
 Profile  
Reply with quote  
PostPosted: Wed Mar 16, 2011 12:29 pm 
Offline

Joined: Thu Dec 09, 2010 9:44 pm
Posts: 3
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();


Top
 Profile  
Reply with quote  
PostPosted: Wed Mar 16, 2011 1:16 pm 
Offline
PDFsharp Guru
User avatar

Joined: Mon Oct 16, 2006 8:16 am
Posts: 3100
Location: Cologne, Germany
I'd go the other way: I'd start with the Hello World sample and change the CreateDocument() method.

_________________
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: No registered users and 73 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