PDFsharp & MigraDoc Foundation https://forum.pdfsharp.net/ |
|
Missing Something https://forum.pdfsharp.net/viewtopic.php?f=2&t=1718 |
Page 1 of 1 |
Author: | PGP_Protector [ Tue Jul 12, 2011 5:59 pm ] |
Post subject: | Missing Something |
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 |
Author: | PGP_Protector [ Tue Jul 12, 2011 6:38 pm ] |
Post subject: | Re: Missing Something |
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. |
Page 1 of 1 | All times are UTC |
Powered by phpBB® Forum Software © phpBB Group https://www.phpbb.com/ |