public void OnePage ( int Cols, int Rows ) { // Add new page PdfPage Page = new PdfPage(Document); // Add contents to page PdfContents Contents = new PdfContents(Page); double Left = CenterX - 0.5 * Cols; double Right = CenterX + 0.5 * Cols; double Top = CenterY + 0.5 * Rows; double Bottom = CenterY - 0.5 * Rows; Contents.DrawText(ArialFont, FontSize, CenterX, Top + Descent + 0.2, TextJustify.Center, Cols == Rows ? "Square" : "Rectangle"); // save state Contents.SaveGraphicsState(); Contents.SetLineWidth(0.1); Contents.SetColorStroking(Color.Black); Contents.SetColorNonStroking(Color.LightBlue); Contents.DrawRectangle(Left, Bottom, Cols, Rows, PaintOp.CloseFillStroke); Contents.RestoreGraphicsState(); Contents.SaveGraphicsState(); Contents.SetLineWidth(0.04); for (int Row = 0; Row <= Rows; Row++) { Contents.DrawLine(Left - 0.25, Bottom + Row, Right, Bottom + Row); Contents.DrawText(ArialFont, FontSize, Left - 0.35, Bottom + Row - Descent, TextJustify.Right, Row.ToString()); } for (int Col = 0; Col <= Cols; Col++) { Contents.DrawLine(Left + Col, Bottom - 0.25, Left + Col, Top); Contents.DrawText(ArialFont, FontSize, Left + Col, Bottom - 0.25 - FontHeight, TextJustify.Center, Col.ToString()); } for (int Index = 0; Index < Rows * Cols; Index++) { int Row = Index / Cols; int Col = Index % Cols; Contents.DrawText(ArialFont, FontSize, Left + 0.5 + Col, Top - 0.5 - Descent - Row, TextJustify.Center, (Index + 1).ToString()); } Contents.DrawText(ArialFont, FontSize, CenterX, Bottom - 1.0, TextJustify.Center, "Area"); Contents.DrawText(ArialFont, FontSize, CenterX, Bottom - 1.4, TextJustify.Center, string.Format("{0} X {1} = {2}", Rows, Cols, Rows * Cols)); // restore graphics state Contents.RestoreGraphicsState(); return; }
//////////////////////////////////////////////////////////////////// // Create charting examples PDF document //////////////////////////////////////////////////////////////////// public void Test ( Boolean Debug, String FileName ) { // Step 1: Create empty document // Arguments: page width: 8.5”, page height: 11”, Unit of measure: inches // Return value: PdfDocument main class Document = new PdfDocument(PaperType.Letter, false, UnitOfMeasure.Inch, FileName); // Debug property // By default it is set to false. Use it for debugging only. // If this flag is set, PDF objects will not be compressed, font and images will be replaced // by text place holder. You can view the file with a text editor but you cannot open it with PDF reader. Document.Debug = Debug; // for encryption test // Document.SetEncryption("Password", Permission.All & ~Permission.Print); ArialNormal = new PdfFont(Document, "Arial", FontStyle.Regular, true); Comic = new PdfFont(Document, "Comic Sans MS", FontStyle.Bold, true); // Step 3: Add new page Page = new PdfPage(Document); // Step 4:Add contents to page PdfContents Contents = new PdfContents(Page); // save graphics state Contents.SaveGraphicsState(); // Draw frame around the page // Set line width to 0.02" Contents.SetLineWidth(0.02); // set frame color dark blue Contents.SetColorStroking(Color.DarkBlue); Contents.SetColorNonStroking(Color.FromArgb(240, 250, 250)); // rectangle position: x=1.0", y=1.0", width=6.5", height=9.0" Contents.DrawRectangle(1.0, 1.0, 6.5, 9.0, PaintOp.CloseFillStroke); Contents.DrawLine(1.0, 8.5, 7.5, 8.5); Contents.DrawLine(1.0, 6.0, 7.5, 6.0); Contents.DrawLine(1.0, 3.5, 7.5, 3.5); // page heading Contents.DrawText(Comic, 40.0, 4.25, 9.25, TextJustify.Center, 0.02, Color.FromArgb(128, 0, 255), Color.FromArgb(255, 0, 128), "PDF FILE WRITER"); // change nonstroking (fill) color to purple Contents.SetColorNonStroking(Color.Purple); // Draw second line of heading text // arguments: Handwriting font, Font size 30 point, Position X=4.25", Y=9.0" // Text Justify: Center (text center will be at X position) Contents.DrawText(Comic, 30.0, 4.25, 8.75, TextJustify.Center, "Media Example"); // create embedded media file Example1(); Example2(); // restore graphics sate (non stroking color will be restored to default) Contents.RestoreGraphicsState(); // create the PDF file Document.CreateFile(); // start default PDF reader and display the file Process Proc = new Process(); Proc.StartInfo = new ProcessStartInfo(FileName); Proc.Start(); // exit return; }
//////////////////////////////////////////////////////////////////// // Draw example of order form //////////////////////////////////////////////////////////////////// private void DrawBookOrderForm() { // Define constants to make the code readable const Double Left = 4.35; const Double Top = 4.65; const Double Bottom = 1.1; const Double Right = 7.4; const Double FontSize = 9.0; const Double MarginHor = 0.04; const Double MarginVer = 0.04; const Double FrameWidth = 0.015; const Double GridWidth = 0.01; // column widths Double ColWidthPrice = ArialNormal.TextWidth(FontSize, "9999.99") + 2.0 * MarginHor; Double ColWidthQty = ArialNormal.TextWidth(FontSize, "Qty") + 2.0 * MarginHor; Double ColWidthDesc = Right - Left - FrameWidth - 3 * GridWidth - 2 * ColWidthPrice - ColWidthQty; // define table PdfTable Table = new PdfTable(Page, Contents, ArialNormal, FontSize); Table.TableArea = new PdfRectangle(Left, Bottom, Right, Top); Table.SetColumnWidth(new Double[] { ColWidthDesc, ColWidthPrice, ColWidthQty, ColWidthPrice }); // define borders Table.Borders.SetAllBorders(FrameWidth, GridWidth); // margin PdfRectangle Margin = new PdfRectangle(MarginHor, MarginVer); // default header style Table.DefaultHeaderStyle.Margin = Margin; Table.DefaultHeaderStyle.BackgroundColor = Color.FromArgb(255, 196, 255); Table.DefaultHeaderStyle.Alignment = ContentAlignment.MiddleRight; // private header style for description Table.Header[0].Style = Table.HeaderStyle; Table.Header[0].Style.Alignment = ContentAlignment.MiddleLeft; // table heading Table.Header[0].Value = "Description"; Table.Header[1].Value = "Price"; Table.Header[2].Value = "Qty"; Table.Header[3].Value = "Total"; // default style Table.DefaultCellStyle.Margin = Margin; // description column style Table.Cell[0].Style = Table.CellStyle; Table.Cell[0].Style.MultiLineText = true; // qty column style Table.Cell[2].Style = Table.CellStyle; Table.Cell[2].Style.Alignment = ContentAlignment.BottomRight; Table.DefaultCellStyle.Format = "#,##0.00"; Table.DefaultCellStyle.Alignment = ContentAlignment.BottomRight; Contents.DrawText(ArialBold, FontSize, 0.5 * (Left + Right), Top + MarginVer + Table.DefaultCellStyle.FontDescent, TextJustify.Center, DrawStyle.Normal, Color.Purple, "Example of PdfTable support"); // reset order total Double Total = 0; // loop for all items in the order // Order class is a atabase simulation for this example foreach (Order Book in Order.OrderList) { Table.Cell[0].Value = Book.Title + ". By: " + Book.Authors; Table.Cell[1].Value = Book.Price; Table.Cell[2].Value = Book.Qty; Table.Cell[3].Value = Book.Total; Table.DrawRow(); // accumulate total Total += Book.Total; } Table.Close(); // save graphics state Contents.SaveGraphicsState(); // form line width 0.01" Contents.SetLineWidth(FrameWidth); Contents.SetLineCap(PdfLineCap.Square); // draw total before tax Double[] ColumnPosition = Table.ColumnPosition; Double TotalDesc = ColumnPosition[3] - MarginHor; Double TotalValue = ColumnPosition[4] - MarginHor; Double PosY = Table.RowTopPosition - 2.0 * MarginVer - Table.DefaultCellStyle.FontAscent; Contents.DrawText(ArialNormal, FontSize, TotalDesc, PosY, TextJustify.Right, "Total before tax"); Contents.DrawText(ArialNormal, FontSize, TotalValue, PosY, TextJustify.Right, Total.ToString("#.00")); // draw tax (Ontario Canada HST) PosY -= Table.DefaultCellStyle.FontLineSpacing; Contents.DrawText(ArialNormal, FontSize, TotalDesc, PosY, TextJustify.Right, "Tax (13%)"); Double Tax = Math.Round(0.13 * Total, 2, MidpointRounding.AwayFromZero); Contents.DrawText(ArialNormal, FontSize, TotalValue, PosY, TextJustify.Right, Tax.ToString("#.00")); // draw total line PosY -= Table.DefaultCellStyle.FontDescent + 0.5 * MarginVer; Contents.DrawLine(ColumnPosition[3], PosY, ColumnPosition[4], PosY); // draw final total PosY -= Table.DefaultCellStyle.FontAscent + 0.5 * MarginVer; Contents.DrawText(ArialNormal, FontSize, TotalDesc, PosY, TextJustify.Right, "Total payable"); Total += Tax; Contents.DrawText(ArialNormal, FontSize, TotalValue, PosY, TextJustify.Right, Total.ToString("#.00")); PosY -= Table.DefaultCellStyle.FontDescent + MarginVer; Contents.DrawLine(ColumnPosition[0], Table.RowTopPosition, ColumnPosition[0], PosY); Contents.DrawLine(ColumnPosition[0], PosY, ColumnPosition[4], PosY); Contents.DrawLine(ColumnPosition[4], Table.RowTopPosition, ColumnPosition[4], PosY); // restore graphics state Contents.RestoreGraphicsState(); return; }
//////////////////////////////////////////////////////////////////// // Draw example of order form //////////////////////////////////////////////////////////////////// private void DrawBookOrderForm ( PdfContents Contents ) { // Order form simulation // Define constants to make the code readable // Define constants const Double Width = 3.05; const Double Height = 3.65; const Double Margin = 0.04; const Double FontSize = 9.0; Double LineSpacing = ArialNormal.LineSpacing(FontSize); Double Descent = ArialNormal.Descent(FontSize); Double ColWidth1 = ArialNormal.TextWidth(FontSize, "9999.99") + 2 * Margin; Double ColWidth2 = ArialNormal.TextWidth(FontSize, "Qty") + 2 * Margin; Double Col4LinePosX = Width - ColWidth1; Double Col3LinePosX = Col4LinePosX - ColWidth2; Double Col2LinePosX = Col3LinePosX - ColWidth1; Double Col1TextPosX = Margin; Double Col2TextPosX = Col3LinePosX - Margin; Double Col3TextPosX = Col4LinePosX - Margin; Double Col4TextPosX = Width - Margin; // save graphics state Contents.SaveGraphicsState(); // form line width 0.01" Contents.SetLineWidth(0.01); // Initial vertical position for contents Double PosY1 = Height - LineSpacing - 2 * Margin; // bottom of the contents area of the form Double PosY2 = 2 * Margin + 3 * LineSpacing; // shift origin, bottom left of the form to X=4.35" and Y=1.1" Contents.Translate(4.35, 1.1); // draw outline rectangle Contents.DrawRectangle(0.0, 0.0, Width, Height, PaintOp.CloseStroke); // draw two horizontal lines. under table heading and above total Contents.DrawLine(0, PosY1, Width, PosY1); Contents.DrawLine(0, PosY2, Width, PosY2); // draw three vertical lines separating the columns Contents.DrawLine(Col2LinePosX, Height, Col2LinePosX, PosY2); Contents.DrawLine(Col3LinePosX, Height, Col3LinePosX, PosY2); Contents.DrawLine(Col4LinePosX, Height, Col4LinePosX, 0); // draw table heading Double PosY = PosY1 + Margin + Descent; Contents.DrawText(ArialNormal, FontSize, Col1TextPosX, PosY, "Description"); Contents.DrawText(ArialNormal, FontSize, Col2TextPosX, PosY, TextJustify.Right, "Price"); Contents.DrawText(ArialNormal, FontSize, Col3TextPosX, PosY, TextJustify.Right, "Qty"); Contents.DrawText(ArialNormal, FontSize, Col4TextPosX, PosY, TextJustify.Right, "Total"); // reset order total Double Total = 0; // define text box for book title and author TextBox Box = new TextBox(Col2LinePosX - 2 * Margin); // initial vertical position PosY = PosY1 - Margin; // loop for all items in the order // Order class is a atabase simulation for this example foreach (Order Book in Order.OrderList) { // clear the text box Box.Clear(); // add book title and authors to the box Box.AddText(ArialNormal, FontSize, Book.Title); Box.AddText(ArialNormal, FontSize, ". By: "); Box.AddText(ArialNormal, FontSize, Book.Authors); // draw the title and authors. // on exit, PosY will be for next line Contents.DrawText(Col1TextPosX, ref PosY, PosY2, 0, Box); // move PosY up to allow drawing cost on the same line as the last text line of the box PosY += Descent; // draw price quantity and item's total Contents.DrawText(ArialNormal, FontSize, Col2TextPosX, PosY, TextJustify.Right, Book.Price.ToString("#.00")); Contents.DrawText(ArialNormal, FontSize, Col3TextPosX, PosY, TextJustify.Right, Book.Qty.ToString()); Contents.DrawText(ArialNormal, FontSize, Col4TextPosX, PosY, TextJustify.Right, Book.Total.ToString("#.00")); // update PosY for next item PosY -= Descent + 0.5 * LineSpacing; // accumulate total Total += Book.Total; } // draw total before tax PosY = PosY2 - Margin - ArialNormal.Ascent(FontSize); Contents.DrawText(ArialNormal, FontSize, Col3TextPosX, PosY, TextJustify.Right, "Total before tax"); Contents.DrawText(ArialNormal, FontSize, Col4TextPosX, PosY, TextJustify.Right, Total.ToString("#.00")); // draw tax (Ontario Canada HST) PosY -= LineSpacing; Contents.DrawText(ArialNormal, FontSize, Col3TextPosX, PosY, TextJustify.Right, "Tax (13%)"); Double Tax = Math.Round(0.13 * Total, 2, MidpointRounding.AwayFromZero); Contents.DrawText(ArialNormal, FontSize, Col4TextPosX, PosY, TextJustify.Right, Tax.ToString("#.00")); // draw final total PosY -= LineSpacing; Contents.DrawText(ArialNormal, FontSize, Col3TextPosX, PosY, TextJustify.Right, "Total payable"); Total += Tax; Contents.DrawText(ArialNormal, FontSize, Col4TextPosX, PosY, TextJustify.Right, Total.ToString("#.00")); // restore graphics state Contents.RestoreGraphicsState(); return; }
/// <summary> /// ovde se samo popunjavaju odgovarajuce vrednosti na osnovu sadrzaja odgorvarajuceg XML fajla /// samo ide DrawText u ovoj metodi /// </summary> public void CreatePagesContents() { int pagenumber = (_sumReport.Records.Count + numOfRemarks) / numOfRowPerPage + 1; int ordNumber = 1; int currNumberOfRemark = 0; int ii = 72; for (int i = 0; i < pagenumber; i++) { Contents = AddPageToDocument(1); for (int j = 0; j < numOfRowPerPage; j++) { if (rows.Count == i * numOfRowPerPage + j) { break; } if (rows[i * numOfRowPerPage + j] == true) { Contents.DrawLine(0.75, 0.1 * (ii - 2 * j), 0.75, 0.1 * (ii - 2 * j - 2)); Contents.DrawLine(1.45 + 0.2125, 0.1 * (ii - 2 * j), 1.45 + 0.2125, 0.1 * (ii - 2 * j - 2)); Contents.DrawLine(2.15 + 2 * 0.2125, 0.1 * (ii - 2 * j), 2.15 + 2 * 0.2125, 0.1 * (ii - 2 * j - 2)); //Contents.DrawLine(3.8, 0.1 * (ii - 2 * j), 3.8, 0.1 * (ii - 2 * j - 2)); Contents.DrawLine(4.5 - 0.7125, 0.1 * (ii - 2 * j), 4.5 - 0.7125, 0.1 * (ii - 2 * j - 2)); Contents.DrawLine(4.6, 0.1 * (ii - 2 * j), 4.6, 0.1 * (ii - 2 * j - 2)); Contents.DrawLine(5.2, 0.1 * (ii - 2 * j), 5.2, 0.1 * (ii - 2 * j - 2)); Contents.DrawLine(5.9 + 0.00, 0.1 * (ii - 2 * j), 5.9 + 0.00, 0.1 * (ii - 2 * j - 2)); Contents.DrawLine(6.6 + 2 * 0.00, 0.1 * (ii - 2 * j), 6.6 + 2 * 0.00, 0.1 * (ii - 2 * j - 2)); Contents.DrawLine(7.3 + 3 * 0.00, 0.1 * (ii - 2 * j), 7.3 + 3 * 0.00, 0.1 * (ii - 2 * j - 2)); Contents.DrawLine(8.0 + 4 * 0.00, 0.1 * (ii - 2 * j), 8.0 + 4 * 0.00, 0.1 * (ii - 2 * j - 2)); //Contents.DrawLine(8.7, 0.1 * (ii - 2 * j), 8.7, 0.1 * (ii - 2 * j - 2)); Contents.DrawLine(8.5, 0.1 * (ii - 2 * j), 8.5, 0.1 * (ii - 2 * j - 2)); Contents.DrawLine(10.2, 0.1 * (ii - 2 * j), 10.2, 0.1 * (ii - 2 * j - 2)); Contents.DrawLine(9.60, 0.1 * (ii - 2 * j), 9.60, 0.1 * (ii - 2 * j - 2)); Contents.DrawLine(9.0, 0.1 * (ii - 2 * j), 9.0, 0.1 * (ii - 2 * j - 2)); Contents.DrawText(ArialNormal, 8, 0.50 + 0.01, 0.1 * (ii - 2 * j - 2) + 0.05, TextJustify.Left, ordNumber.ToString()); //Contents.DrawText(ArialNormal, 8, 0.80 + 0.01, 0.1 * (ii - 2 * j - 2) + 0.05, TextJustify.Left, _sumReport.Records[i * numOfRowPerPage + j - currNumberOfRemark].PolazniKvalitet); Contents.DrawText(ArialNormal, 8, 0.80 + 0.01, 0.1 * (ii - 2 * j - 2) + 0.05, TextJustify.Left, _sumReport.Records[i * numOfRowPerPage + j - currNumberOfRemark].BrUzorka); //Contents.DrawText(ArialNormal, 8, 1.50 + 0.2125 + 0.01, 0.1 * (ii - 2 * j - 2) + 0.05, TextJustify.Left, _sumReport.Records[i * numOfRowPerPage + j - currNumberOfRemark].NazivnaDebljina); Contents.DrawText(ArialNormal, 8, 1.50 + 0.2125 + 0.01, 0.1 * (ii - 2 * j - 2) + 0.05, TextJustify.Left, _sumReport.Records[i * numOfRowPerPage + j - currNumberOfRemark].Sarza); //Contents.DrawText(ArialNormal, 8, 2.15 + 0.01, 0.1 * (ii - 2 * j - 2) + 0.05, TextJustify.Left, _sumReport.Records[i * numOfRowPerPage + j - currNumberOfRemark].Ispitivac); //Contents.DrawText(ArialNormal, 8, 2.20 + 2 * 0.2125 + 0.01, 0.1 * (ii - 2 * j - 2) + 0.05, TextJustify.Left, _sumReport.Records[i * numOfRowPerPage + j - currNumberOfRemark].BrUzorka); Contents.DrawText(ArialNormal, 8, 2.20 + 2 * 0.2125 + 0.01, 0.1 * (ii - 2 * j - 2) + 0.05, TextJustify.Left, _sumReport.Records[i * numOfRowPerPage + j - currNumberOfRemark].PolazniKvalitet); //Contents.DrawText(ArialNormal, 8, 4.55 - 0.7425 + 0.01, 0.1 * (ii - 2 * j - 2) + 0.05, TextJustify.Left, _sumReport.Records[i * numOfRowPerPage + j - currNumberOfRemark].Sarza); Contents.DrawText(ArialNormal, 8, 4.55 - 0.7425 + 0.01, 0.1 * (ii - 2 * j - 2) + 0.05, TextJustify.Left, _sumReport.Records[i * numOfRowPerPage + j - currNumberOfRemark].NazivnaDebljina); Contents.DrawText(ArialNormal, 8, 7.35 /*4.65*/ + 0.01, 0.1 * (ii - 2 * j - 2) + 0.05, TextJustify.Left, _sumReport.Records[i * numOfRowPerPage + j - currNumberOfRemark].Rm); Contents.DrawText(ArialNormal, 8, 4.65 /*5.25*/ + 0.01, 0.1 * (ii - 2 * j - 2) + 0.05, TextJustify.Left, _sumReport.Records[i * numOfRowPerPage + j - currNumberOfRemark].Rp02); Contents.DrawText(ArialNormal, 8, 5.25 /*5.95*/ + 0.00 + 0.01, 0.1 * (ii - 2 * j - 2) + 0.05, TextJustify.Left, _sumReport.Records[i * numOfRowPerPage + j - currNumberOfRemark].Rt05); Contents.DrawText(ArialNormal, 8, 5.95 /*6.65*/ + 2 * 0.00 + 0.01, 0.1 * (ii - 2 * j - 2) + 0.05, TextJustify.Left, _sumReport.Records[i * numOfRowPerPage + j - currNumberOfRemark].ReL); Contents.DrawText(ArialNormal, 8, 6.65 /*7.35*/ + 3 * 0.00 + 0.01, 0.1 * (ii - 2 * j - 2) + 0.05, TextJustify.Left, _sumReport.Records[i * numOfRowPerPage + j - currNumberOfRemark].ReH); Contents.DrawText(ArialNormal, 8, 8.05 + 4 * 0.00 + 0.01, 0.1 * (ii - 2 * j - 2) + 0.05, TextJustify.Left, _sumReport.Records[i * numOfRowPerPage + j - currNumberOfRemark].A); //Contents.DrawText(ArialNormal, 8, 8.7 + 0.01, 0.1 * (ii - 2 * j - 2) + 0.05, TextJustify.Left, _sumReport.Records[i * numOfRowPerPage + j - currNumberOfRemark].At); Contents.DrawText(ArialNormal, 8, 10.25, 0.1 * (ii - 2 * j - 2) + 0.05, TextJustify.Left, _sumReport.Records[i * numOfRowPerPage + j - currNumberOfRemark].N); Contents.DrawText(ArialNormal, 8, 8.55 + 0.01, 0.1 * (ii - 2 * j - 2) + 0.05, TextJustify.Left, _sumReport.Records[i * numOfRowPerPage + j - currNumberOfRemark].Z); if (_sumReport.Records[i * numOfRowPerPage + j - currNumberOfRemark].BrUzorka.EndsWith("/1") == true) { Contents.DrawText(ArialNormal, 8, 9.05, 0.1 * (ii - 2 * j - 2) + 0.05, TextJustify.Left, KV(_sumReport.Records[i * numOfRowPerPage + j - currNumberOfRemark].BrzbIzvestaja, _sumReport.Records[i * numOfRowPerPage + j - currNumberOfRemark].BrUzorka)); Contents.DrawText(ArialNormal, 8, 9.65, 0.1 * (ii - 2 * j - 2) + 0.05, TextJustify.Left, KU(_sumReport.Records[i * numOfRowPerPage + j - currNumberOfRemark].BrzbIzvestaja, _sumReport.Records[i * numOfRowPerPage + j - currNumberOfRemark].BrUzorka)); } ordNumber++; } else { Contents.DrawText(ArialBold, 8, 0.45 + 0.01, 0.1 * (ii - 2 * j - 2) + 0.05, TextJustify.Left, "Napomena za br. uzorka " + _sumReport.Records[i * numOfRowPerPage + j - currNumberOfRemark - 1].BrUzorka + ":" + _sumReport.Records[i * numOfRowPerPage + j - currNumberOfRemark - 1].Napomena); currNumberOfRemark++; } ////rest of vertical lines //for (int ii = 72; ii >= 6; ) //{ // BaseContents.DrawLine(0.75, 0.1 * ii, 0.75, 0.1 * (ii - 2)); // BaseContents.DrawLine(1.45, 0.1 * ii, 1.45, 0.1 * (ii - 2)); // BaseContents.DrawLine(2.15, 0.1 * ii, 2.15, 0.1 * (ii - 2)); // BaseContents.DrawLine(3.8, 0.1 * ii, 3.8, 0.1 * (ii - 2)); // BaseContents.DrawLine(4.5, 0.1 * ii, 4.5, 0.1 * (ii - 2)); // BaseContents.DrawLine(5.2, 0.1 * ii, 5.2, 0.1 * (ii - 2)); // BaseContents.DrawLine(5.9, 0.1 * ii, 5.9, 0.1 * (ii - 2)); // BaseContents.DrawLine(6.6, 0.1 * ii, 6.6, 0.1 * (ii - 2)); // BaseContents.DrawLine(7.3, 0.1 * ii, 7.3, 0.1 * (ii - 2)); // BaseContents.DrawLine(8.0, 0.1 * ii, 8.0, 0.1 * (ii - 2)); // BaseContents.DrawLine(8.7, 0.1 * ii, 8.7, 0.1 * (ii - 2)); // BaseContents.DrawLine(9.4, 0.1 * ii, 9.4, 0.1 * (ii - 2)); // BaseContents.DrawLine(10.1, 0.1 * ii, 10.1, 0.1 * (ii - 2)); // i = i - 2; //} } } //Contents.DrawText(ArialBold, 14, 0.05 * PageWidth, PageHeight - Margin - (HeadingHeight - ArialBold.CapHeight(24)) / 2, TextJustify.Left, "IZVEŠTAJ O ISPITIVANJU MEHANIČKIH OSOBINA"); }
//////////////////////////////////////////////////////////////////// // create base contents for all pages //////////////////////////////////////////////////////////////////// /// <summary> /// ovde se kreira naslov svake strane, zaglavlje tabele kao i same ivice tabela /// </summary> public void CreateBaseContents() { // create unattached contents BaseContents = new PdfContents(Document); // save graphics state BaseContents.SaveGraphicsState(); // restore graphics state BaseContents.RestoreGraphicsState(); BaseContents.DrawText(ArialBold, 14, 0.5 * PageWidth, 11.5, TextJustify.Center, "IZVEŠTAJ O ISPITIVANJU MEHANIČKIH OSOBINA"); //draw logo PdfImage Image2 = new PdfImage(Document, System.Environment.CurrentDirectory + "\\logoLjig.png"); //BaseContents.DrawImage(Image1, 0.95, p1.Y - 3.8, ImageSize.Width - 1, ImageSize.Height); BaseContents.DrawImage(Image2, 8.5, 7.7, 1.4, 0.7); BaseContents.DrawText(ArialNormal, 8, 0.48, 7.85, TextJustify.Left, "BR. ZB. IZVEŠTAJA "); BaseContents.DrawLine(1.6, 8.0, 2.3, 8.0); BaseContents.DrawLine(1.6, 7.8, 2.3, 7.8); BaseContents.DrawLine(1.6, 8.0, 1.6, 7.8); BaseContents.DrawLine(2.3, 8.0, 2.3, 7.8); BaseContents.DrawText(ArialNormal, 8, 1.6, 7.85, TextJustify.Left, _sumReport.Records[0].BrzbIzvestaja); //horizontal lines BaseContents.DrawLine(0.45, 7.6, 10.8, 7.6); //BaseContents.DrawLine(0.45, 7.4, 10.8, 7.4); BaseContents.DrawLine(0.45, 7.2, 10.8, 7.2); BaseContents.DrawLine(0.45, 7.0, 10.8, 7.0); BaseContents.DrawLine(0.45, 6.8, 10.8, 6.8); BaseContents.DrawLine(0.45, 6.6, 10.8, 6.6); BaseContents.DrawLine(0.45, 6.4, 10.8, 6.4); BaseContents.DrawLine(0.45, 6.2, 10.8, 6.2); BaseContents.DrawLine(0.45, 6.0, 10.8, 6.0); BaseContents.DrawLine(0.45, 5.8, 10.8, 5.8); BaseContents.DrawLine(0.45, 5.6, 10.8, 5.6); BaseContents.DrawLine(0.45, 5.4, 10.8, 5.4); BaseContents.DrawLine(0.45, 5.2, 10.8, 5.2); BaseContents.DrawLine(0.45, 5.0, 10.8, 5.0); BaseContents.DrawLine(0.45, 4.8, 10.8, 4.8); BaseContents.DrawLine(0.45, 4.6, 10.8, 4.6); BaseContents.DrawLine(0.45, 4.4, 10.8, 4.4); BaseContents.DrawLine(0.45, 4.2, 10.8, 4.2); BaseContents.DrawLine(0.45, 4.0, 10.8, 4.0); BaseContents.DrawLine(0.45, 3.8, 10.8, 3.8); BaseContents.DrawLine(0.45, 3.6, 10.8, 3.6); BaseContents.DrawLine(0.45, 3.4, 10.8, 3.4); BaseContents.DrawLine(0.45, 3.2, 10.8, 3.2); BaseContents.DrawLine(0.45, 3.0, 10.8, 3.0); BaseContents.DrawLine(0.45, 2.8, 10.8, 2.8); BaseContents.DrawLine(0.45, 2.6, 10.8, 2.6); BaseContents.DrawLine(0.45, 2.4, 10.8, 2.4); BaseContents.DrawLine(0.45, 2.2, 10.8, 2.2); BaseContents.DrawLine(0.45, 2.0, 10.8, 2.0); BaseContents.DrawLine(0.45, 1.8, 10.8, 1.8); BaseContents.DrawLine(0.45, 1.6, 10.8, 1.6); BaseContents.DrawLine(0.45, 1.4, 10.8, 1.4); BaseContents.DrawLine(0.45, 1.2, 10.8, 1.2); //BaseContents.DrawLine(0.45, 1.0, 10.8, 1.0);//31st row //BaseContents.DrawLine(0.45, 0.8, 10.8, 0.8);//32nd row //BaseContents.DrawLine(0.45, 0.6, 10.8, 0.6);//33th row //BaseContents.DrawLine(0.45, 0.4, 10.8, 0.4);//34th row //vertical two lines //BaseContents.DrawLine(0.45, 7.6, 0.45, 0.4);//this is for 34 rows per page //BaseContents.DrawLine(10.8, 7.6, 10.8, 0.4); BaseContents.DrawLine(0.45, 7.6, 0.45, 1.2); BaseContents.DrawLine(10.8, 7.6, 10.8, 1.2); //header BaseContents.DrawLine(0.75, 7.6, 0.75, 7.2); BaseContents.DrawText(ArialNormal, 8, 0.48, 7.42, TextJustify.Left, "RED."); BaseContents.DrawText(ArialNormal, 8, 0.48, 7.24, TextJustify.Left, "BR."); BaseContents.DrawLine(1.45 + 0.2125, 7.6, 1.45 + 0.2125, 7.2); BaseContents.DrawText(ArialNormal, 8, 1.00, 7.42, TextJustify.Left, "BROJ" /*"POLAZNI"*/); BaseContents.DrawText(ArialNormal, 8, 1.00, 7.24, TextJustify.Left, "UZORKA" /*"KVALITET"*/); BaseContents.DrawLine(2.15 + 2 * 0.2125, 7.6, 2.15 + 2 * 0.2125, 7.2); BaseContents.DrawText(ArialNormal, 8, 1.95, 7.32, TextJustify.Left, "ŠARŽA" /*"NAZIVNA"*/); //BaseContents.DrawText(ArialNormal, 8, 1.75, 7.24, TextJustify.Left, "DEBLJINA"); //BaseContents.DrawLine(3.8, 7.6, 3.8, 7.2); //BaseContents.DrawText(ArialNormal, 8, 2.67, 7.42, TextJustify.Left, "ISPITIVAČ"); BaseContents.DrawLine(4.5 - 0.7125, 7.6, 4.5 - 0.7125, 7.2); BaseContents.DrawText(ArialNormal, 8, 2.95, 7.42, TextJustify.Left, "POLAZNI" /*"BROJ"*/); BaseContents.DrawText(ArialNormal, 8, 2.95, 7.24, TextJustify.Left, "KVALITET" /*"UZORKA"*/); BaseContents.DrawLine(4.6, 7.6, 4.6, 7.2); BaseContents.DrawText(ArialNormal, 8, 3.95, 7.42, TextJustify.Left, "NAZIVNA" /*"ŠARŽA"*/); BaseContents.DrawText(ArialNormal, 8, 3.95, 7.24, TextJustify.Left, "DEBLJINA" /*"ŠARŽA"*/); //BaseContents.DrawLine(8.5, 7.6, 8.5, 7.2);//vertical line na kraju mehanicko tehnickih osobina BaseContents.DrawLine(8.5, 7.4, 8.5, 7.2); // samo za A ne za sve jel smo dodali Z BaseContents.DrawLine(4.6, 7.4, 9.4, 7.4); //horizontal line BaseContents.DrawText(ArialNormal, 8.5, 6.0, 7.45, TextJustify.Left, "MEHANIČKO-TEHNIČKE OSOBINE"); BaseContents.DrawText(ArialNormal, 8, 7.45 /*4.65*/, 7.24, TextJustify.Left, "Rm[MPa]"); BaseContents.DrawLine(5.2 + 0.00, 7.4, 5.2 + 0.00, 7.2); BaseContents.DrawText(ArialNormal, 8, 4.65 /*5.28*/, 7.24, TextJustify.Left, "R"); BaseContents.DrawText(ArialNormal, 6.5, 4.73 /*5.36*/, 7.24, TextJustify.Left, "p0.2"); BaseContents.DrawText(ArialNormal, 8, 4.92 /*5.55*/, 7.24, TextJustify.Left, "[MPa]"); BaseContents.DrawLine(5.9 + 0.00, 7.4, 5.9 + 0.00, 7.2); BaseContents.DrawText(ArialNormal, 8, 5.28 /*5.98*/, 7.24, TextJustify.Left, "R"); BaseContents.DrawText(ArialNormal, 6.5, 5.36 /*6.05*/, 7.24, TextJustify.Left, "t0.5"); BaseContents.DrawText(ArialNormal, 8, 5.55 /*6.24*/, 7.24, TextJustify.Left, "[MPa]"); BaseContents.DrawLine(6.6 + 2 * 0.00, 7.4, 6.6 + 2 * 0.00, 7.2); BaseContents.DrawText(ArialNormal, 8, 6.0 /*6.7*/, 7.24, TextJustify.Left, "ReL[MPa]"); BaseContents.DrawLine(7.3 + 3 * 0.00, 7.4, 7.3 + 3 * 0.00, 7.2); BaseContents.DrawText(ArialNormal, 8, 6.7 /*7.41*/, 7.24, TextJustify.Left, "ReH[MPa]"); BaseContents.DrawLine(8.0 + 4 * 0.00, 7.4, 8.0 + 4 * 0.00, 7.2); //BaseContents.DrawLine(8.7, 7.4, 8.7, 7.2); BaseContents.DrawText(ArialNormal, 8, 8.05, 7.24, TextJustify.Left, "A[%]"); BaseContents.DrawLine(9.0 + 4 * 0.00, 7.6, 9.0 + 4 * 0.00, 7.2);//za kraj mehanicko tehnickih osobina vertikalna linija BaseContents.DrawText(ArialNormal, 8, 9.15, 7.24, TextJustify.Left, "KV[J]"); BaseContents.DrawLine(9.6 + 4 * 0.00, 7.4, 9.6 + 4 * 0.00, 7.2); BaseContents.DrawText(ArialNormal, 8, 9.75, 7.24, TextJustify.Left, "KU[J]"); BaseContents.DrawLine(10.2 + 4 * 0.00, 7.4, 10.2 + 4 * 0.00, 7.2); //BaseContents.DrawLine(9.4, 7.4, 9.4, 7.2); //BaseContents.DrawText(ArialNormal, 8, 9.0, 7.24, TextJustify.Left, "At"); //BaseContents.DrawLine(10.8, 7.6, 10.8, 7.4);//vertical line BaseContents.DrawLine(9.4, 7.4, 10.8, 7.4);//horizontal line //BaseContents.DrawText(ArialNormal, 8, 9.45, 7.42, TextJustify.Left, "FAKTOR"); //BaseContents.DrawLine(10.2, 7.6, 10.2, 7.2);//faktor BaseContents.DrawText(ArialNormal, 8, 10.5, 7.24, TextJustify.Left, "n"); BaseContents.DrawText(ArialNormal, 8, 8.6, 7.24, TextJustify.Left, "Z[%]"); //BaseContents.DrawText(ArialNormal, 8, 0.5, 7.05, TextJustify.Left, "NAPOMENATEST"); //BaseContents.DrawLine(0.75, 7.4, 0.75, 7.2); //BaseContents.DrawLine(1.45, 7.4, 1.45, 7.2); //BaseContents.DrawLine(2.15, 7.4, 2.15, 7.2); //BaseContents.DrawLine(3.8, 7.4, 3.8, 7.2); BaseContents.DrawText(ArialNormal, 8, 0.45, 0.25, TextJustify.Left, "VERIFIKOVAO"); BaseContents.DrawLine(1.3, 0.2, 5, 0.2);//horizontal line BaseContents.DrawText(ArialNormal, 8, 7, 0.25, TextJustify.Left, "ISPITIVAČ"); BaseContents.DrawLine(7.8, 0.4, 9.8, 0.4); BaseContents.DrawLine(7.8, 0.2, 7.8, 0.4); BaseContents.DrawLine(9.8, 0.2, 9.8, 0.4); BaseContents.DrawLine(7.8, 0.2, 9.8, 0.2); BaseContents.DrawText(ArialNormal, 8, 7.8 + 0.01, 0.25, TextJustify.Left, _sumReport.Records[0].Ispitivac);//u jednom zbirnom izvestaju treba da ima samo jedan ispitivac // exit return; }
public void Test ( bool Debug, string InputFileName ) { // create document using (Document = new PdfDocument(PaperType.Letter, false, UnitOfMeasure.Inch, InputFileName)) { // set document page mode to open the layers panel Document.InitialDocDisplay = InitialDocDisplay.UseLayers; // define font ArialFont = PdfFont.CreatePdfFont(Document, "Arial", FontStyle.Bold); // open layer control object (in PDF terms optional content object) PdfLayers Layers = new PdfLayers(Document, "PDF layers group"); // set layer panel to incluse all layers including ones that are not visible Layers.ListMode = ListMode.AllPages; // Add new page PdfPage Page = new PdfPage(Document); // Add contents to page PdfContents Contents = new PdfContents(Page); // heading Contents.DrawText(ArialFont, 24, 4.25, 10, TextJustify.Center, "PDF File Writer Layer Test/Demo"); // define layers PdfLayer DrawingTest = new PdfLayer(Layers, "Drawing Test"); PdfLayer Rectangle = new PdfLayer(Layers, "Rectangle"); PdfLayer HorLines = new PdfLayer(Layers, "Horizontal Lines"); PdfLayer VertLines = new PdfLayer(Layers, "Vertical Lines"); PdfLayer QRCodeLayer = new PdfLayer(Layers, "QRCode barcode"); PdfLayer Pdf417Layer = new PdfLayer(Layers, "PDF417 barcode"); PdfLayer NoBarcodeLayer = new PdfLayer(Layers, "No barcode"); // combine three layers into one group of radio buttons QRCodeLayer.RadioButton = "Barcode"; Pdf417Layer.RadioButton = "Barcode"; NoBarcodeLayer.RadioButton = "Barcode"; // set the order of layers in the layer pane Layers.DisplayOrder(DrawingTest); Layers.DisplayOrder(Rectangle); Layers.DisplayOrder(HorLines); Layers.DisplayOrder(VertLines); Layers.DisplayOrderStartGroup("Barcode group"); Layers.DisplayOrder(QRCodeLayer); Layers.DisplayOrder(Pdf417Layer); Layers.DisplayOrder(NoBarcodeLayer); Layers.DisplayOrderEndGroup(); // start a group layer Contents.LayerStart(DrawingTest); // sticky note annotation PdfAnnotation StickyNote = Page.AddStickyNote(2.0, 9.0, "My sticky note", StickyNoteIcon.Note); StickyNote.LayerControl = DrawingTest; // draw a single layer Contents.LayerStart(Rectangle); Contents.DrawText(ArialFont, 14, 1.0, 8.0, TextJustify.Left, "Draw rectangle"); Contents.LayerEnd(); // draw a single layer Contents.LayerStart(HorLines); Contents.DrawText(ArialFont, 14, 1.0, 7.5, TextJustify.Left, "Draw horizontal lines"); Contents.LayerEnd(); // draw a single layer Contents.LayerStart(VertLines); Contents.DrawText(ArialFont, 14, 1.0, 7.0, TextJustify.Left, "Draw vertical lines"); Contents.LayerEnd(); double Left = 4.0; double Right = 7.0; double Top = 9.0; double Bottom = 6.0; // draw a single layer Contents.LayerStart(Rectangle); Contents.SaveGraphicsState(); Contents.SetLineWidth(0.1); Contents.SetColorStroking(Color.Black); Contents.SetColorNonStroking(Color.LightBlue); Contents.DrawRectangle(Left, Bottom, 3.0, 3.0, PaintOp.CloseFillStroke); Contents.RestoreGraphicsState(); Contents.LayerEnd(); // save graphics state Contents.SaveGraphicsState(); // draw a single layer Contents.SetLineWidth(0.02); Contents.LayerStart(HorLines); for (int Row = 1; Row < 6; Row++) { Contents.DrawLine(Left, Bottom + 0.5 * Row, Right, Bottom + 0.5 * Row); } Contents.LayerEnd(); // draw a single layer Contents.LayerStart(VertLines); for (int Col = 1; Col < 6; Col++) { Contents.DrawLine(Left + 0.5 * Col, Bottom, Left + 0.5 * Col, Top); } Contents.LayerEnd(); // restore graphics state Contents.RestoreGraphicsState(); // terminate a group of layers Contents.LayerEnd(); // define QRCode barcode QREncoder QREncoder = new QREncoder(); QREncoder.ErrorCorrection = ErrorCorrection.M; QREncoder.Encode(QRCodeArticle); PdfImage QRImage = new PdfImage(Document); QRImage.LoadImage(QREncoder); // define PDF417 barcode Pdf417Encoder Pdf417Encoder = new Pdf417Encoder(); Pdf417Encoder.ErrorCorrection = ErrorCorrectionLevel.AutoMedium; Pdf417Encoder.Encode(Pdf417Article); PdfImage Pdf417Image = new PdfImage(Document); Pdf417Image.LoadImage(Pdf417Encoder); // draw a single layer Contents.LayerStart(QRCodeLayer); Contents.DrawText(ArialFont, 14, 1.0, 2.5, TextJustify.Left, "QRCode Barcode"); Contents.DrawImage(QRImage, 3.7, 2.5 - 1.75, 3.5); Contents.LayerEnd(); // draw a single layer Contents.LayerStart(Pdf417Layer); Contents.DrawText(ArialFont, 14, 1.0, 2.5, TextJustify.Left, "PDF417 Barcode"); Contents.DrawImage(Pdf417Image, 3.7, 2.5 - 1.75 * Pdf417Encoder.ImageHeight / Pdf417Encoder.ImageWidth, 3.5); Contents.LayerEnd(); // draw a single layer Contents.LayerStart(NoBarcodeLayer); Contents.DrawText(ArialFont, 14, 1.0, 3.0, TextJustify.Left, "Display no barcode"); Contents.LayerEnd(); // create pdf file Document.CreateFile(); // start default PDF reader and display the file Process Proc = new Process(); Proc.StartInfo = new ProcessStartInfo(InputFileName); Proc.Start(); } return; }
public void appendSectionBreak() { drawY -= .15; cont.SetColorStroking(Color.LightGray); cont.DrawLine(firstColumnHeaderX, drawY, pageWidth - rightMargin, drawY, .015); }
public FileInfo CreateOfferDocument(Offer offer, bool asOrder = false, bool withPreview = true) { ResetVars(); myOffer = offer; PdfDocument doc; PdfPage page; PdfContents content; PdfImage img; double lineSpacing; double descent; const double fontSize = 10.0; bool isOffer = (this.myOffer.Bestellkennzeichen | asOrder); string fullName = Path.Combine(CatalistRegistry.Application.OfferFilePath, offer.OfferId + ".pdf"); doc = new PdfDocument(PaperType.A4, false, UnitOfMeasure.mm, fullName); doc.Debug = false; page = new PdfPage(doc); content = new PdfContents(page); content.SetLineWidth(0.03); fontDefault = new PdfFont(doc, "Calibri", System.Drawing.FontStyle.Regular, true); myFontBold = new PdfFont(doc, "Calibri", System.Drawing.FontStyle.Bold, true); fontFooter = new PdfFont(doc, "Calibri Light", System.Drawing.FontStyle.Regular, true); fontFooterBold = new PdfFont(doc, "Calibri Light", System.Drawing.FontStyle.Bold, true); fontPriceTotal = new PdfFont(doc, "Calibri Light", System.Drawing.FontStyle.Bold, true); lineSpacing = fontDefault.LineSpacing(fontSize); descent = fontDefault.Descent(fontSize); // Header string imagePath = Path.Combine(CatalistRegistry.Application.PicturePath, "briefkopf.png"); img = new PdfImage(doc, imagePath); content.DrawImage(img, 5, pageHeight - 27.9 - 5, 199.6, 27.4); content.DrawLine(xLeftMargin - 5, pageHeight - 27.9 - 5 - 2, xRightMargin + 5, pageHeight - 27.9 - 5 - 2); string absender = @"Cut & Print Media GmbH & Co. KG · Osterheide 9 · 49124 Georgsmarienhütte"; content.DrawText(fontDefault, fontSize - 4, 18, pageHeight - 49.5, absender); content.DrawLine(18, pageHeight - 50.5, 84.5, pageHeight - 50.5, 0.1); content.DrawText(fontDefault, fontSize + 2, 18, pageHeight - 55, offer.Customer.CompanyName1); content.DrawText(fontDefault, fontSize + 2, 18, pageHeight - 65, offer.Customer.Street); string zipCity = string.Format("{0} {1}", offer.Customer.ZipCode, offer.Customer.City); content.DrawText(fontDefault, fontSize + 2, 18, pageHeight - 71, zipCity); string vorgang = isOffer ? "Bestellung" : "Angebot"; content.DrawText(fontDefault, fontSize + 2, xVLine3 + 5, pageHeight - 55, "Kunden-Nr.:"); content.DrawText(fontDefault, fontSize + 2, xVLine5 - 13, pageHeight - 55, offer.CustomerId.Substring(0, 5)); content.DrawText(fontDefault, fontSize + 2, xVLine3 + 5, pageHeight - 60, vorgang + " Nr.:"); content.DrawText(fontDefault, fontSize + 2, xVLine5 - 13, pageHeight - 60, offer.OfferId); content.DrawText(fontDefault, fontSize + 2, xVLine3 + 5, pageHeight - 65, "Datum:"); content.DrawText(fontDefault, fontSize + 2, xVLine5 - 13, pageHeight - 65, offer.ChangeDate.ToShortDateString()); content.DrawText(fontDefault, fontSize + 2, xVLine3 + 5, pageHeight - 70, "Bearbeitet von:"); content.DrawText(fontDefault, fontSize + 2, xVLine5 - 13, pageHeight - 70, offer.ChangeUser); content.DrawText(myFontBold, fontSize + 2, 10, pageHeight - 96.5, vorgang + " " + offer.OfferId); var table = new PdfTable(page, content, fontDefault, 9); table.TableStartEvent += tab_TableStartEvent; table.TableEndEvent += tab_TableEndEvent; table.TableArea = new PdfRectangle(10D, 35D, 200D, pageHeight - 40); table.RowTopPosition = pageHeight - 100D; // 10cm vom oberen Rand table.SetColumnWidth(9D, 34D, 86D, 13D, 19D, 19D); table.HeaderOnEachPage = true; table.Header[colPos].Style = table.HeaderStyle; table.Header[colPos].Style.Alignment = System.Drawing.ContentAlignment.MiddleRight; table.Header[colPos].Value = "Pos."; table.Header[colArtNr].Value = "Artikel-Nr."; table.Header[colArtBez].Value = "Artikelbezeichnung"; table.Header[colMenge].Style = table.HeaderStyle; table.Header[colMenge].Style.Alignment = System.Drawing.ContentAlignment.MiddleRight; table.Header[colMenge].Value = "Menge"; table.Header[colPreis].Style = table.HeaderStyle; table.Header[colPreis].Style.Alignment = System.Drawing.ContentAlignment.MiddleRight; table.Header[colPreis].Value = "Einzelpreis"; table.Header[colGesamt].Style = table.HeaderStyle; table.Header[colGesamt].Style.Alignment = System.Drawing.ContentAlignment.MiddleRight; table.Header[colGesamt].Value = "Gesamtpreis"; table.DefaultHeaderStyle.Font = myFontBold; table.DefaultHeaderStyle.Alignment = System.Drawing.ContentAlignment.TopLeft; table.DefaultHeaderStyle.MultiLineText = false; table.DefaultCellStyle.Font = fontDefault; table.DefaultCellStyle.FontSize = 9; table.DefaultCellStyle.Alignment = System.Drawing.ContentAlignment.TopLeft; table.Cell[colPos].Style = table.CellStyle; table.Cell[colPos].Style.Alignment = System.Drawing.ContentAlignment.TopRight; table.Cell[colArtNr].Style = table.CellStyle; table.Cell[colArtNr].Style.TextBoxTextJustify = TextBoxJustify.Left; table.Cell[colArtBez].Style = table.CellStyle; table.Cell[colArtBez].Style.TextBoxTextJustify = TextBoxJustify.Left; table.Cell[colMenge].Style = table.CellStyle; table.Cell[colMenge].Style.Format = "#,##0"; table.Cell[colMenge].Style.Alignment = System.Drawing.ContentAlignment.TopRight; table.Cell[colPreis].Style = table.CellStyle; table.Cell[colPreis].Style.Format = "#,##0.00"; table.Cell[colPreis].Style.Alignment = System.Drawing.ContentAlignment.TopRight; table.Cell[colGesamt].Style = table.CellStyle; table.Cell[colGesamt].Style.ForegroundColor = System.Drawing.Color.DarkRed; table.Cell[colGesamt].Style.Format = "#,##0.00"; table.Cell[colGesamt].Style.Alignment = System.Drawing.ContentAlignment.TopRight; int dCount = offer.OfferDetails.Count; for (int i = 0; i < dCount; i++) { lastRow |= i == dCount - 1; table.Cell[colPos].Value = offer.OfferDetails[i].Position; table.Cell[colArtNr].Value = offer.OfferDetails[i].Artikelnummer; TextBox txtBezeichnung = table.Cell[colArtBez].CreateTextBox(); txtBezeichnung.AddText(myFontBold, 9, offer.OfferDetails[i].Artikelname); if (!isOffer) { txtBezeichnung.AddText(fontDefault, 9, string.Format("\n\n{0}", offer.OfferDetails[i].Artikeltext.Replace("\t", " "))); } table.Cell[colMenge].Value = string.Format("{0:#,##0} {1}", offer.OfferDetails[i].Menge, offer.OfferDetails[i].Einheit); if (!isOffer) { table.Cell[colPreis].Value = offer.OfferDetails[i].Kundenpreis; table.Cell[colGesamt].Value = offer.OfferDetails[i].Zeilensumme; zwischenSumme += offer.OfferDetails[i].Zeilensumme; } else { table.Cell[colPreis].Value = "-"; table.Cell[colGesamt].Value = "-"; } table.DrawRow(offer.OfferDetails[i].NeueSeite); } table.Close(); try { doc.CreateFile(); if (File.Exists(fullName) && withPreview) { // Datei in das lokale TEMP Verzeichnis kopieren var temp = Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments); string prefix = asOrder ? "B" : "A"; var tempFilename = string.Format("{0}{1}.pdf", prefix, DateTime.Now.ToString("yyyy-MM-dd_hh.mm.ss")); var tempFileAndPath = Path.Combine(temp, tempFilename); File.Copy(fullName, tempFileAndPath); var proc = new Process(); proc.StartInfo = new ProcessStartInfo(tempFileAndPath); proc.Start(); } return(new FileInfo(fullName)); } catch (Exception ex) { throw ex; } }