/// <summary> /// creates a new rectangle /// </summary> /// <param name="RectangleArea">the area which will contains the rectangle</param> /// <param name="BorderColor"></param> public PdfRectangle(PdfDocument PdfDocument,PdfArea RectangleArea,Color BorderColor) { this.PdfDocument=PdfDocument; this.rectangleArea=RectangleArea; this.BorderColor=BorderColor; this.strokeWidth=1; }
/// <summary> /// creates a new rectangle /// </summary> /// <param name="RectangleArea"></param> /// <param name="BorderColor"></param> /// <param name="BorderWidth"></param> public PdfRectangle(PdfDocument PdfDocument,PdfArea RectangleArea,Color BorderColor,double BorderWidth) { this.PdfDocument=PdfDocument; if (BorderWidth<=0) throw new Exception("BorderWidth must be greater than zero."); this.rectangleArea=RectangleArea; this.BorderColor=BorderColor; this.strokeWidth=BorderWidth; }
internal PdfHeader(PdfDocument PdfDocument,string subject,string title,string author) { this.PdfDocument=PdfDocument; this.id=this.PdfDocument.GetNextId; this.subject=subject; this.title=title; this.author=author; this.creationdate=DateTime.Today.ToShortDateString(); }
public static Stream ListToPdf(object list, Dictionary<string, string> titles, bool IsExportAllCol) { DataTable dt = ListToDataTable(list, titles, IsExportAllCol,string.Empty); var pdfTitle = dt.TableName; // Starting instantiate the document. // Remember to set the Docuement Format. In this case, we specify width and height. PdfDocument myPdfDocument = new PdfDocument(PdfDocumentFormat.InCentimeters(21, 29.7)); // Now we create a Table of 100 lines, 6 columns and 4 points of Padding. PdfTable myPdfTable = myPdfDocument.NewTable(new Font("Arial", 12), dt.Rows.Count, dt.Columns.Count, 4); // Importing datas from the datatables... (also column names for the headers!) //myPdfTable.ImportDataTable(Table); myPdfTable.ImportDataTable(dt); // Sets the format for correct date-time representation //myPdfTable.Columns[2].SetContentFormat("{0:dd/MM/yyyy}"); // Now we set our Graphic Design: Colors and Borders... myPdfTable.HeadersRow.SetColors(Color.White, Color.Navy); myPdfTable.SetColors(Color.Black, Color.White, Color.Gainsboro); myPdfTable.SetBorders(Color.Black, 1, BorderType.CompleteGrid); //// With just one method we can set the proportional width of the columns. //// It's a "percentage like" assignment, but the sum can be different from 100. //myPdfTable.SetColumnsWidth(new int[] { 5, 25, 16, 20, 20, 15 }); //// You can also set colors for a range of cells, in this case, a row: //myPdfTable.Rows[7].SetColors(Color.Black, Color.LightGreen); // Now we set some alignment... for the whole table and then, for a column. myPdfTable.SetContentAlignment(ContentAlignment.MiddleCenter); myPdfTable.Columns[1].SetContentAlignment(ContentAlignment.MiddleLeft); // Here we start the loop to generate the table... while (!myPdfTable.AllTablePagesCreated) { // we create a new page to put the generation of the new TablePage: PdfPage newPdfPage = myPdfDocument.NewPage(); PdfTablePage newPdfTablePage = myPdfTable.CreateTablePage(new PdfArea(myPdfDocument, 48, 120, 500, 670)); // we also put a Label PdfTextArea pta = new PdfTextArea(new Font("Arial", 26, FontStyle.Bold), Color.Red , new PdfArea(myPdfDocument, 0, 20, 595, 120), ContentAlignment.MiddleCenter, pdfTitle); // nice thing: we can put all the objects in the following lines, so we can have // a great control of layer sequence... newPdfPage.Add(newPdfTablePage); newPdfPage.Add(pta); // we save each generated page before start rendering the next. newPdfPage.SaveToDocument(); } //myPdfDocument.SaveToFile("Example1.pdf"); var stream = new MemoryStream(); myPdfDocument.SaveToStream(stream); return stream; }
public PdfRoot(PdfDocument PdfDocument) { this.PdfDocument=PdfDocument; this.id=this.PdfDocument.GetNextId; }
public static Stream ListToPdf(object list, Dictionary <string, string> titles, bool IsExportAllCol) { DataTable dt = ListToDataTable(list, titles, IsExportAllCol, string.Empty); var pdfTitle = dt.TableName; // Starting instantiate the document. // Remember to set the Docuement Format. In this case, we specify width and height. PdfDocument myPdfDocument = new PdfDocument(PdfDocumentFormat.InCentimeters(21, 29.7)); // Now we create a Table of 100 lines, 6 columns and 4 points of Padding. PdfTable myPdfTable = myPdfDocument.NewTable(new Font("Arial", 12), dt.Rows.Count, dt.Columns.Count, 4); // Importing datas from the datatables... (also column names for the headers!) //myPdfTable.ImportDataTable(Table); myPdfTable.ImportDataTable(dt); // Sets the format for correct date-time representation //myPdfTable.Columns[2].SetContentFormat("{0:dd/MM/yyyy}"); // Now we set our Graphic Design: Colors and Borders... myPdfTable.HeadersRow.SetColors(Color.White, Color.Navy); myPdfTable.SetColors(Color.Black, Color.White, Color.Gainsboro); myPdfTable.SetBorders(Color.Black, 1, BorderType.CompleteGrid); //// With just one method we can set the proportional width of the columns. //// It's a "percentage like" assignment, but the sum can be different from 100. //myPdfTable.SetColumnsWidth(new int[] { 5, 25, 16, 20, 20, 15 }); //// You can also set colors for a range of cells, in this case, a row: //myPdfTable.Rows[7].SetColors(Color.Black, Color.LightGreen); // Now we set some alignment... for the whole table and then, for a column. myPdfTable.SetContentAlignment(ContentAlignment.MiddleCenter); myPdfTable.Columns[1].SetContentAlignment(ContentAlignment.MiddleLeft); // Here we start the loop to generate the table... while (!myPdfTable.AllTablePagesCreated) { // we create a new page to put the generation of the new TablePage: PdfPage newPdfPage = myPdfDocument.NewPage(); PdfTablePage newPdfTablePage = myPdfTable.CreateTablePage(new PdfArea(myPdfDocument, 48, 120, 500, 670)); // we also put a Label PdfTextArea pta = new PdfTextArea(new Font("Arial", 26, FontStyle.Bold), Color.Red , new PdfArea(myPdfDocument, 0, 20, 595, 120), ContentAlignment.MiddleCenter, pdfTitle); // nice thing: we can put all the objects in the following lines, so we can have // a great control of layer sequence... newPdfPage.Add(newPdfTablePage); newPdfPage.Add(pta); // we save each generated page before start rendering the next. newPdfPage.SaveToDocument(); } //myPdfDocument.SaveToFile("Example1.pdf"); var stream = new MemoryStream(); myPdfDocument.SaveToStream(stream); return(stream); }
/// <summary> /// created a new line to put inside a PdfPage /// </summary> /// <param name="Start">the starting point of the line</param> /// <param name="End">the ending point of the line</param> /// <param name="Color">the Color of the line</param> /// <param name="StrokeWidth">the width of the stroke</param> public PdfLine(PdfDocument PdfDocument,PointF Start,PointF End,Color Color,double StrokeWidth) { this.PdfDocument=PdfDocument; if (StrokeWidth<=0) throw new Exception("StrokeWidth must be greater than zero."); this.start=Start; this.end=End; this.color=Color; this.strokeWidth=StrokeWidth; }
/// <summary> /// creates a new rectangle /// </summary> /// <param name="RectangleArea"></param> /// <param name="BorderColor"></param> /// <param name="FillingColor"></param> public PdfRectangle(PdfDocument PdfDocument,PdfArea RectangleArea,Color BorderColor,Color FillingColor) { this.PdfDocument=PdfDocument; this.rectangleArea=RectangleArea; this.BorderColor=BorderColor; this.FillingColor=FillingColor; this.filled=true; this.strokeWidth=1; }
public PdfCatalog(PdfDocument PdfDocument) { this.PdfDocument=PdfDocument; this.id=this.PdfDocument.GetNextId; }
public PdfCatalog(PdfDocument PdfDocument) { this.PdfDocument = PdfDocument; this.id = this.PdfDocument.GetNextId; }
internal PdfTable(PdfDocument PdfDocument,ContentAlignment DefaultContentAlignment,Font Font,Color DefaultForegroundColor,int Rows ,int Columns,double CellPadding) { cells=new Hashtable(); pdfRows=new ArrayList(); this.owner=this; this.PdfDocument=PdfDocument; this.borderWidth=0; this.pdfColumns=new ArrayList(); this.rows=Rows; this.startRow=0; this.startColumn=0; this.endColumn=Columns-1; this.endRow=Rows-1; this.columns=Columns; for (int c=0;c<columns;c++) for (int r=0;r<rows;r++) { this.cells[r+","+c]=new PdfCell(this,r,c,DefaultContentAlignment,DefaultForegroundColor ,Font,CellPadding); } for (int r=0;r<rows;r++) { this.pdfRows.Add(new PdfRow(this,r)); } for (int c=0;c<columns;c++) { PdfColumn pc=new PdfColumn(this,c); pc.Width=100/this.columns; this.pdfColumns.Add(pc); } }
/// <summary> /// Generates a new Area inside the base one specifing the width difference. /// </summary> /// <param name="Difference">the Width difference of the inner Area</param> /// <returns></returns> public PdfArea InnerArea(double Difference) { this.PdfDocument=PdfDocument; if (Difference<0) throw new Exception("Difference must be non negative."); PdfArea pa=this.MemberwiseClone() as PdfArea; pa.width-=(double)Difference; pa.Height-=(double)Difference; pa.posx+=(double)Difference/2; pa.posy+=(double)Difference/2; return pa; }
internal PdfArea (PdfDocument PdfDocument){this.PdfDocument=PdfDocument;}
/// <summary> /// Creates a new Area for correctly placing objects into Pdf Pages /// </summary> /// <param name="posx">Top-Left Vertex X-coordinate</param> /// <param name="posy">Top-Left Vertex Y-coordinate</param> /// <param name="width">Width of the Area</param> /// <param name="height">Height of the Area</param> public PdfArea (PdfDocument PdfDocument,double posx,double posy,double width,double height) { this.PdfDocument=PdfDocument; if (width<=0) throw new Exception("Width must be grater than zero."); if (height<=0) throw new Exception("Height must be grater than zero."); this.PosX=(double)posx; this.PosY=(double)posy; this.Width=(double)width; this.Height=(double)height; }