PDFsharp & MigraDoc Foundation

PDFsharp - A .NET library for processing PDF & MigraDoc Foundation - Creating documents on the fly
It is currently Thu Jul 11, 2024 10:22 am

All times are UTC


Forum rules


Please read this before posting on this forum: Forum Rules



Post new topic Reply to topic  [ 2 posts ] 
Author Message
 Post subject: Missing Something
PostPosted: Tue Jul 12, 2011 5:59 pm 
Offline
User avatar

Joined: Sat Jul 09, 2011 12:19 am
Posts: 2
I'm trying to add a table to an existing PDF Document.

Code:
           
            RingBuildDocument = new PdfDocument();
            RingBuildPage = RingBuildDocument.AddPage();
            RingBuildPage.Size = PageSize.A4;
            RingBuildPage.Orientation = PageOrientation.Landscape;
            #region Figure Out Size Of Ring Image
            double CircleRadius = (((2 * RingRadius * Math.PI) / RingStepCount) / 2.0);
            double MyRingRadius = RingRadius + (1 + RingLayerCount) * CircleRadius * 2.1 + CircleRadius/2.0;
            double MyRingDiamater = MyRingRadius*2.0;
            double PageMinSize = RingBuildPage.Width; if (RingBuildPage.Height < PageMinSize) PageMinSize = RingBuildPage.Height;
            PDFImgScale = PageMinSize / MyRingDiamater;
            #endregion
            XGraphics DrawingGfx = XGraphics.FromPdfPage(RingBuildPage);
            XFont DrawingFont = new XFont("Verdana", 10, XFontStyle.Bold);
            DrawingGfx.DrawString("Ring Builder Document (Date)", DrawingFont, XBrushes.Black, new XRect(0, 0, RingBuildPage.Width, RingBuildPage.Height), XStringFormats.TopLeft);
            BuildRing(DrawingGfx , RingRadius,RingStepCount,RingLayerCount);
            BuildPads(DrawingGfx, PadData, MyRingDiamater);
            BuildConnections(DrawingGfx, PadData, MyRingDiamater);
            //Watermark(RingBuildPage, DrawingGfx,"This is a Development Version");
            Document MigraDocument = new Document();
            MigraDocument.Info.Title = "PO Order Ring Build";
            MigraDocument.Info.Subject = "Ring Build XYZ.";
            MigraDocument.Info.Author = "Ring Builder Program";
            DefineStyles(MigraDocument);
            DefineContentSection(MigraDocument);
            BuildTables(MigraDocument);
            MigraDoc.Rendering.DocumentRenderer MigraDocRenderer = new MigraDoc.Rendering.DocumentRenderer(MigraDocument);
            //MigraDocRenderer.PrepareDocument();

            //MigraDocRenderer.RenderPage(DrawingGfx, 1);
           
            RingBuildDocument.Save(FilePath);
            Process MyPDFView = Process.Start(FilePath);


Now the main part works (It creates my drawing on a Single Page Document) Filling the right side (Landscape Orientation)
The "BuildTables" modifies the "Document" Correctly (It appears)
Code:

        public static void BuildTables(Document document)
        {
            document.AddSection();
            document.LastSection.AddParagraph("Simple Tables", "Heading2");
            Table table = new Table();
            table.Borders.Width = 0.75;

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

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

            Row row = table.AddRow();
            row.Shading.Color = Colors.LightCyan;
            Cell cell = row.Cells[0]; cell.AddParagraph("Purchace Order Number");                       
            cell = row.Cells[1]; cell.AddParagraph("Value");
            row = table.AddRow();
            cell = row.Cells[0]; cell.AddParagraph("Edited By");                   
            cell = row.Cells[1]; cell.AddParagraph("Value");
            row = table.AddRow();
            cell = row.Cells[0]; cell.AddParagraph("Date");                         
            cell = row.Cells[1]; cell.AddParagraph("Value");
            table.SetEdge(0, 0, 2, 3, Edge.Box, BorderStyle.Single, 1.5, Colors.Black);
            document.LastSection.Add(table);
        }


But when I Unremark the command "MigraDocRenderer.PrepareDocument();" (First set of code) I get the error.
Quote:
Could not load file or assembly 'PdfSharp-WPF, Version=1.31.1731.0, Culture=neutral, PublicKeyToken=f94615aa0424f9eb' or one of its dependencies. The located assembly's manifest definition does not match the assembly reference. (Exception from HRESULT: 0x80131040)


Code compiles fine, I'm guessing I'm missing a DLL or something though. (Usings Below)

Code:
using MigraDoc;
using MigraDoc.DocumentObjectModel;
using MigraDoc.DocumentObjectModel.Tables;
using MigraDoc.Rendering;
using PdfSharp;
using PdfSharp.Drawing;
using PdfSharp.Pdf;
using PdfSharp.Pdf.Advanced;


Dlls in Application Directory
286,720 MigraDoc.DocumentObjectModel-WPF.dll version 1.2.2961.0
151,552 MigraDoc.Rendering-WPF.dll version 1.2.2961.0
86,016 MigraDoc.RtfRendering-WPF.dll version 1.2.2961.0
632,320 PdfSharp-WPF.dll version 1.31.1789.0


Top
 Profile  
Reply with quote  
 Post subject: Re: Missing Something
PostPosted: Tue Jul 12, 2011 6:38 pm 
Offline
User avatar

Joined: Sat Jul 09, 2011 12:19 am
Posts: 2
Ok, changed the DLL's to the ones from PDFsharp-MigraDocFoundation-Assemblies-1_31.zip\GDI+ (All 5)
And that worked. (well stopped crashing)
I'm still not getting my Table Inserted into the PDF Document though.


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

All times are UTC


Who is online

Users browsing this forum: Bing [Bot], Google [Bot] and 26 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