public void WriteSiteSummaryPage(string siteName, ListView lv) { pdfPage myPage = myDoc.addPage(predefinedPageSize.csSharpPDFFormat); int width = myPage.width - leftMargin - rightMargin; WritePageTitle(myPage, "Site Description", siteName); pdfTable myTable = new pdfTable(myDoc, 1, pdfColor.Black, 5, new pdfTableStyle(myDoc.getFontReference(strFont), 12, pdfColor.Black, new pdfColor("d9d1b3")), new pdfTableStyle(myDoc.getFontReference(strFont), 12, pdfColor.Black, pdfColor.White), new pdfTableStyle(myDoc.getFontReference(strFont), 12, pdfColor.Black, pdfColor.White)); myTable.coordX = leftMargin; myTable.coordY = GetLineTop(myPage, 5); myTable.tableHeader.rowHeight = 25; myTable.tableHeader.addColumn(175, predefinedAlignment.csLeft); myTable.tableHeader[0].addText("Parameter"); myTable.tableHeader.addColumn(160, predefinedAlignment.csLeft); myTable.tableHeader[1].addText("Current Scenario"); myTable.tableHeader.addColumn(160, predefinedAlignment.csLeft); myTable.tableHeader[2].addText("Baseline Scenario"); int tableRowHt = 15; pdfTableRow myRow; for (int i = 0; i < lv.Items.Count; i++) { if (i > 11 && i <= 18) { continue; } myRow = myTable.createRow(); myRow.rowHeight = tableRowHt; for (int j = 0; j < 3; j++) { myRow[j].addText(lv.Items[i].SubItems[j].Text); } myTable.addRow(myRow); } myPage.addTable(myTable); WriteLidSummaryTable(myPage, lv); WriteFooter(myPage); }
private void button1_Click(object sender, EventArgs e) { pdfDocument myDoc = new pdfDocument("RemiseImpot", "ME"); pdfPage myFirstPage = myDoc.addPage(); myDoc.createPDF(@"C:\Users\William\Documents\Remises_Impots.pdf"); myFirstPage = null; myDoc = null; }
/// <summary> ///titlepage with info such as scene name and current date /// </summary> /// <param name="doc"> the document to which to add the page</param> private void Titlepage(pdfDocument doc) { //create and add page to document pdfPage TitlePage = doc.addPage(); int titlelengt = sceneName.Length; int fontSize = 60; //add text to middlle document TitlePage.addText(sceneName, TitlePage.width / 2 - titlelengt * fontSize / 3, TitlePage.height - fontSize * 2, predefinedFont.csHelveticaBold, fontSize); TitlePage.addText(date, TitlePage.width / 2 - date.Length * 12 / 3, TitlePage.height - fontSize * 2 - 40, predefinedFont.csHelvetica, 12); }
/// <summary> /// Конструктор конкретного продукта (документа) в формате PDF. /// </summary> public PDFText() { // Добавление новой страницы в PDF документ с разрешением 500х500px. pdfData.addPage(500, 500); //Устанавка шрифта документа по умолчанию. currentPDFfont = pdfData.getFontReference(pdfFont.getFontName(predefinedFont.csHelvetica)); //Создание текстового елемента (в подключеной библиотеке sharpPDF это контейнер для символьных данных, аналогично блоку текста/f,pfwf). currentCharElem = new textElement(String.Empty, 14, currentPDFfont, 30, lastElemPostionY); //Устанавка Y-координаты последнего символа в документе. lastElemPostionY = currentCharElem.coordY; }
private void Button_Click(object sender, RoutedEventArgs e) { pdfDocument myDoc = new pdfDocument("TUTORIAL", "ME"); pdfPage myPage = myDoc.addPage(); myPage.addText("Hello,World!", 200, 450, myDoc.getFontReference(predefinedFont.csHelvetica), 20); myDoc.addTrueTypeFont(@"verdana.ttf", "verdana"); myPage.addText("Привет, мир!", 200, 250, myDoc.getFontReference("verdana"), 20); myDoc.createPDF(@"test.pdf"); myPage = null; myDoc = null; }
private IEnumerator createPdf() { pdfDocument myDoc = new pdfDocument("Palm Measure Application", "", false); pdfPage myFirstPage = myDoc.addPage(); //yield return StartCoroutine(myFirstPage.newAddImage(Application.persistentDataPath + "/" + "screenshot.png", 0, 800)); myFirstPage.addText("Name: " + NameInputField.text, 0, 700, sharpPDF.Enumerators.predefinedFont.csCourier, 36); myFirstPage.addText("Id: " + IdInputField.text, 0, 650, sharpPDF.Enumerators.predefinedFont.csCourier, 36); myFirstPage.addText("Scale: " + PreviewZoomIndication.text, 0, 600, sharpPDF.Enumerators.predefinedFont.csCourier, 36); myFirstPage.addText("Comments: " + CommentsInputField.text, 0, 550, sharpPDF.Enumerators.predefinedFont.csCourier, 36); myDoc.createPDF(Application.persistentDataPath + "/Data.pdf"); yield return(null); }
/// <summary> /// add create page and add image to page /// </summary> /// <param name="imagePath"> path to where the image is located </param> /// <param name="doc"> the document to add a page to </param> private void InsertImage(string imagePath, pdfDocument doc) { //create page with size of 1080 by 1920 and add to document pdfPage page = doc.addPage(1080, 1920); //read image file as byte array byte[] vs = File.ReadAllBytes(imagePath); //calc image height using page size and 16:9 aspect ratio int IWidht = page.width; int IHeight = IWidht * 9 / 16; //add image to page anchor point 0,0 with height and with page.addImage(vs, 0, 0, IHeight, IWidht); }
/// <summary> /// add create page with special height and width and add image to page /// </summary> /// <param name="imagePath"> path to where the image is located </param> /// <param name="doc"> the document to add a page to </param> /// <param name="pageWidth"> the widht of the created page </param> /// <param name="pageHeight"> the height of the created page </param> private void InsertImage(string imagePath, pdfDocument doc, int pageWidth, int pageHeight) { //create and add page to document pdfPage page = doc.addPage(pageHeight, pageWidth); //read image file as byte array byte[] vs = File.ReadAllBytes(imagePath); //calc image height using page size and 16:9 aspect ratio int IWidht = page.width; int IHeight = IWidht * 9 / 16; //add image to page. position 0,0 with height and with page.addImage(vs, 0, 0, IHeight, IWidht); }
/// <summary> /// Exports the chart to the specified output stream as binary. When /// exporting to a web response the WriteToHttpResponse() method is likely /// preferred. /// </summary> /// <param name="outputStream">An output stream.</param> internal void WriteToStream(Stream outputStream) { switch (this.ContentType) { case "image/jpeg": CreateSvgDocument().Draw().Save( outputStream, ImageFormat.Jpeg); break; case "image/png": // PNG output requires a seekable stream. using (MemoryStream seekableStream = new MemoryStream()) { CreateSvgDocument().Draw().Save( seekableStream, ImageFormat.Png); seekableStream.WriteTo(outputStream); } break; case "application/pdf": SvgDocument svgDoc = CreateSvgDocument(); Bitmap bmp = svgDoc.Draw(); pdfDocument doc = new pdfDocument(this.Name, null); pdfPage page = doc.addPage(bmp.Height, bmp.Width); page.addImage(bmp, 0, 0); doc.createPDF(outputStream); break; case "image/svg+xml": using (StreamWriter writer = new StreamWriter(outputStream)) { writer.Write(this.Svg); writer.Flush(); } break; default: throw new InvalidOperationException(string.Format( "ContentType '{0}' is invalid.", this.ContentType)); } outputStream.Flush(); }
/// <summary> /// imprimir O.S /// </summary> /// <param name="sender"></param> /// <param name="e"></param> protected void btnImprimirOS_Click(object sender, EventArgs e) { if (ViewState["cmpIdOS"].ToString() == "0") { this.GravarOS(); } ImprimirOs Imprimir = new ImprimirOs(); pdfDocument myDoc = new pdfDocument("Horizon", "Orion"); Imprimir.myDoc = myDoc; Imprimir.myPage = myDoc.addPage(predefinedPageSize.csSharpPDFFormat); Imprimir.cmpCoObra = loadObra(); Imprimir.cmpIdOS = ViewState["cmpIdOS"].ToString(); Imprimir.NomeObra = "Serviços de TI"; Imprimir.EnderecoLogoOrion = Server.MapPath("~/Imagens/logo_Orion.jpg"); if (ViewState["cmpInLogoObra"].ToString() == "1") { Imprimir.EnderecoLogoObra = Server.MapPath("~/Imagens/logo_IPEN.bmp"); } else { Imprimir.EnderecoLogoObra = ""; } Imprimir.ImprimeOrdemServico(); string filename = "pdf" + DateTime.Now.Day.ToString() + DateTime.Now.Month.ToString() + DateTime.Now.Year.ToString() + DateTime.Now.Millisecond.ToString() + ".pdf"; string nomepdf = Server.MapPath("~/Relatorios/" + filename); myDoc.createPDF(nomepdf); Response.Write("<script>window.open('" + Global.UrlRelatorio + filename + "', '_blank', 'width=850, height=600, menubar=no, resizable=yes, scrollbars=yes, top=35, left=105');</script>"); // Impressão ambiente desenvolvimento local //Response.Write("<script language='javascript'>" // + "window.open('" + @"http://*****:*****@"http://172.10.10.2/HzWebManutencao_Desenv/Relatorios/" + filename + "', '_blank', 'width=850, height=600, menubar=no, resizable=yes, scrollbars=yes, top=35, left=105')" // + "</script>"); }
private void ImprimirTodasOS() { DataTable table = pesquisaOs(); if (table != null && table.Rows.Count > 0) { ImprimirOs Imprimir = new ImprimirOs(); pdfDocument myDoc = new pdfDocument("Horizon", "Orion"); Imprimir.myDoc = myDoc; Imprimir.cmpCoObra = ((HzLibGeneral.Util.HzLogin)Session["login"]).cmpCoObraGrupoLista; Imprimir.NomeObra = cmbObra.SelectedItem.ToString(); Imprimir.EnderecoLogoOrion = Server.MapPath("~/Imagens/logo_Orion.jpg"); if (ViewState["cmpInLogoObra"].ToString() == "True") { Imprimir.EnderecoLogoObra = Server.MapPath("~/Imagens/logo_IPEN.bmp"); } else { Imprimir.EnderecoLogoObra = ""; } foreach (DataRow lin in table.Rows) { Imprimir.cmpIdOS = lin["cmpIdOs"].ToString(); Imprimir.myPage = myDoc.addPage(predefinedPageSize.csSharpPDFFormat); Imprimir.ImprimeOrdemServico(); } //filename = "pdf" + DateTime.Now.Day.ToString() + DateTime.Now.Month.ToString() + DateTime.Now.Year.ToString() + DateTime.Now.Millisecond.ToString() + ".pdf"; string nomepdf = Server.MapPath("~/Relatorios/" + filename); myDoc.createPDF(nomepdf); Response.Write("<script>window.open('" + Global.UrlRelatorio + filename + "', '_blank', 'width=850, height=600, menubar=no, resizable=yes, scrollbars=yes, top=35, left=105');</script>"); // Impressão ambiente produção ambiente interno orion //Response.Write("<script language='javascript'>" // + "window.open('" + @"http://172.10.10.2/HzWebManutencao_Desenv/Relatorios/" + filename + "', '_blank', 'width=850, height=600, menubar=no, resizable=yes, scrollbars=yes, top=35, left=105')" // + "</script>"); } }
public virtual pdfDocument ImprimeAtividades(DataTable table) { String strFont = "Helvetica"; int leftMargin = 30; int pg = 1; int top = 20; int RegItemAtv; //Tamanho da lin em pixel int nTamLinPixel = 19; // Variaveis de controle para quebra de linha de campos //int QtdCaracterLinha = 50; //int Tamanho; //int QtdLin; //int StrInicio; //int StrFim; int cl; // Adiciona Página pdfDocument myDoc = new pdfDocument("Horizon", "Orion"); pdfPage myPage = myDoc.addPage(predefinedPageSize.csSharpPDFFormat); ImprimeFormPrevEquipamento Cab = new ImprimeFormPrevEquipamento(); Cab.cmpNoObra = table.Rows[0]["cmpNoObra"].ToString().TrimEnd(); Cab.cmpDcTipoAtividade = table.Rows[0]["cmpDcTipoAtividade"].ToString().TrimEnd(); Cab.cmpDcPeriodicidade = table.Rows[0]["cmpDcPeriodicidade"].ToString().TrimEnd(); top = Cab.CabRelatorio(myDoc, myPage, top); top = Cab.SubCabRelatorio(myDoc, myPage, top, table.Rows[0]); pdfTable myTable = ItemAtividade(myDoc, myPage, top, table.Rows[0]); top += 40; RegItemAtv = 0; int IdEquipamento = int.Parse(table.Rows[0]["cmpIdEquipamentoObra"].ToString()); // Imprimir linhas de detalhes pdfTableRow myRow = myTable.createRow(); foreach (DataRow row in table.Rows) { if (IdEquipamento != int.Parse(row["cmpIdEquipamentoObra"].ToString())) { IdEquipamento = int.Parse(row["cmpIdEquipamentoObra"].ToString()); myPage.addTable(myTable); myTable = ConclusaoRelatorio(myDoc, myPage, top); myPage.addText("Pág. " + pg++, leftMargin, 10, myDoc.getFontReference(strFont), 10, pdfColor.Black); myPage.addTable(myTable); // Adiciona uma página myPage = myDoc.addPage(predefinedPageSize.csSharpPDFFormat); pg = 1; top = 30; top = Cab.CabRelatorio(myDoc, myPage, top); top = Cab.SubCabRelatorio(myDoc, myPage, top, row); myTable = ItemAtividade(myDoc, myPage, top, row); top += 40; } else { if (RegItemAtv == 0) { RegItemAtv = 1; } else { cl = 0; myRow = myTable.createRow(); myRow.rowStyle = myTable.rowStyle; myRow[cl++].addText(""); myRow[cl++].addText(row["cmpDcItemAtividadePreventiva"].ToString().TrimEnd()); myTable.addRow(myRow); top += nTamLinPixel; } } if (top > 1000) { myPage.addText("Pág. " + pg++, leftMargin, 10, myDoc.getFontReference(strFont), 10, pdfColor.Black); myPage.addTable(myTable); // Adiciona uma página myPage = myDoc.addPage(predefinedPageSize.csSharpPDFFormat); top = 30; top = Cab.CabRelatorio(myDoc, myPage, top); top = Cab.SubCabRelatorio(myDoc, myPage, top, row); myTable = ItemAtividade(myDoc, myPage, top, row); top += 40; } } if (top < 1000) { myPage.addTable(myTable); myTable = ConclusaoRelatorio(myDoc, myPage, top); myPage.addText("Pág. " + pg++, leftMargin, 10, myDoc.getFontReference(strFont), 10, pdfColor.Black); myPage.addTable(myTable); } return(myDoc); }
private void btnGeneratePDF_Click(object sender, EventArgs e) { // Si un employé est sélectionné if (this.dataEmployes.SelectedRows.Count > 0) { FolderBrowserDialog folderBrowserDialog = new System.Windows.Forms.FolderBrowserDialog(); DialogResult result = folderBrowserDialog.ShowDialog(); if (result == DialogResult.OK) { IGestionEmployes gestionEmployes = GestionEmployesBuilderClassFactory.getInterface(); string folderName = folderBrowserDialog.SelectedPath; int selectedRowIndex = this.dataEmployes.SelectedRows[0].Index; int IdUtilisateur = Convert.ToInt32(this.dataEmployes.Rows[selectedRowIndex].Cells["IdUtilisateur"].Value); object[] tabInfoUser = gestionEmployes.findUtilisateur(IdUtilisateur); Utilisateur utilisateur = (Utilisateur)tabInfoUser[0]; Adresse adresse = (Adresse)tabInfoUser[1]; Societe societe = (Societe)tabInfoUser[2]; Role role = (Role)tabInfoUser[3]; Ville ville = (Ville)tabInfoUser[4]; FormModificationEmploye form = new FormModificationEmploye(); // Génération du fichier PDF try { pdfDocument myDoc = new pdfDocument("Sample Application", "Me", false); pdfPage myFirstPage = myDoc.addPage(700, 700); myFirstPage.addText("Fiche d'information - " + utilisateur.Prenom.Trim() + " " + utilisateur.Nom.Trim(), 100, 630, predefinedFont.csHelvetica, 30, new pdfColor(predefinedColor.csBlack)); /*Table's creation*/ pdfTable myTable = new pdfTable(); //Set table's border myTable.borderSize = 0; myTable.borderColor = new pdfColor(predefinedColor.csBlack); /*Create table's header*/ myTable.tableHeader.addColumn(new pdfTableColumn("Information", predefinedAlignment.csLeft, 150)); myTable.tableHeader.addColumn(new pdfTableColumn("Valeur", predefinedAlignment.csCenter, 250)); /*Create table's rows*/ pdfTableRow myRow = myTable.createRow(); myRow[0].columnValue = "Prénom"; myRow[1].columnValue = utilisateur.Prenom.Trim(); myTable.addRow(myRow); myRow = myTable.createRow(); myRow[0].columnValue = "Nom"; myRow[1].columnValue = utilisateur.Nom.Trim(); myTable.addRow(myRow); myRow = myTable.createRow(); myRow[0].columnValue = "Identifiant"; myRow[1].columnValue = utilisateur.Identifiant; myTable.addRow(myRow); myRow = myTable.createRow(); myRow[0].columnValue = "Mot de passe"; myRow[1].columnValue = utilisateur.MotPasse; myTable.addRow(myRow); myRow = myTable.createRow(); myRow[0].columnValue = "Rôle"; myRow[1].columnValue = role.CodeRole; myTable.addRow(myRow); myRow = myTable.createRow(); myRow[0].columnValue = "Date de début"; myRow[1].columnValue = utilisateur.DateDebut.ToShortDateString(); myTable.addRow(myRow); myRow = myTable.createRow(); myRow[0].columnValue = "Date de fin"; myRow[1].columnValue = utilisateur.DateFin.ToShortDateString(); myTable.addRow(myRow); myRow = myTable.createRow(); myRow[0].columnValue = "Adresse"; myRow[1].columnValue = adresse.NumeroRue + " " + adresse.NomRue + ", " + adresse.CodePostal + " " + ville.CodeVille; myTable.addRow(myRow); myRow = myTable.createRow(); myRow[0].columnValue = "Nom de société"; myRow[1].columnValue = societe.NomSociete; myTable.addRow(myRow); myRow = myTable.createRow(); myRow[0].columnValue = "Description de société"; myRow[1].columnValue = societe.DescriptionSociete; myTable.addRow(myRow); myRow = myTable.createRow(); myRow[0].columnValue = "Numéro de siret"; myRow[1].columnValue = societe.NumeroSiret; myTable.addRow(myRow); /*Set Header's Style*/ myTable.tableHeaderStyle = new pdfTableRowStyle(predefinedFont.csHelveticaBold, 12, new pdfColor(predefinedColor.csWhite), new pdfColor(predefinedColor.csRed)); /*Set Row's Style*/ myTable.rowStyle = new pdfTableRowStyle(predefinedFont.csHelvetica, 10, new pdfColor(predefinedColor.csBlack), new pdfColor(predefinedColor.csWhite)); /*Set Alternate Row's Style*/ myTable.alternateRowStyle = new pdfTableRowStyle(predefinedFont.csHelvetica, 10, new pdfColor(predefinedColor.csBlack), new pdfColor(predefinedColor.csLightGray)); /*Set Cellpadding*/ myTable.cellpadding = 10; /*Put the table on the page object*/ myFirstPage.addTable(myTable, 150, 550); myTable = null; myDoc.createPDF(folderName + "\\FicheInformation.pdf"); MessageBox.Show("Le fichier PDF a bien été créé", "Génération de PDF"); Process.Start(folderName + "\\FicheInformation.pdf"); // Fin de génération du fichier PDF } // Quand il y a une erreur catch (Exception exception) { MessageBox.Show("L'erreur suivante s'est produite : " + exception.Message + "", "Erreur lors de l'éxécution"); } } } // Si aucun employé n'est sélectionné else { MessageBox.Show("Sélectionnez un utilisateur.", "Génération fichier PDF"); } }
public static pdfDocument ImprimeFechamento(DataTable table, string DataInicial, string DataFinal) { String strFont = "Helvetica"; int leftMargin = 30; int pg = 1; int top = 40; //Tamanho da lin em pixel int nTamLinPixel = 19; // Variaveis de controle para quebra de linha de campos int QtdCaracterLinha = 80; int Tamanho; int QtdLin; int StrInicio; int StrFim; int cl; // Adiciona Página pdfDocument myDoc = new pdfDocument("Horizon", "Orion"); pdfPage myPage = myDoc.addPage(predefinedPageSize.csSharpPDFFormat); string DadosObra = (table.Rows[0]["cmpNoObra"].ToString().Trim() + (table.Rows[0]["cmpNuContrato"] != null ? " -> Contrato nº " + table.Rows[0]["cmpNuContrato"].ToString() : "")); CabRelatorio(myDoc, myPage, top, DadosObra, DataInicial, DataFinal); top += 30; pdfTable myTable = SubCabRelatorio(myDoc, myPage, top); top += 10; // Imprimir linhas de detalhes pdfTableRow myRow = myTable.createRow(); int cont = 0; foreach (DataRow row in table.Rows) { cl = 0; myRow = myTable.createRow(); myRow.rowStyle = myTable.rowStyle; myRow[cl++].addText(row["cmpNuOs"].ToString()); myRow[cl++].addText(row["cmpNoSolicitante"].ToString().TrimEnd()); row["cmpDcObservacoes"] = TiraCaractEspecial(row["cmpDcObservacoes"].ToString().ToUpper()); Tamanho = row["cmpDcObservacoes"].ToString().Length; if (Tamanho > 0) { QtdLin = (Tamanho % QtdCaracterLinha == 0 ? Tamanho / QtdCaracterLinha : (Tamanho / QtdCaracterLinha) + 1); StrInicio = 0; for (int Linha = 1; Linha <= QtdLin; Linha++) { StrFim = Linha == QtdLin ? Tamanho - StrInicio : QtdCaracterLinha; if (Linha == 1) { myRow[cl++].addText(row["cmpDcObservacoes"].ToString().Substring(StrInicio, StrFim).Trim()); if (row["cmpDcLocal"] != null) { cont++; //System.Diagnostics.Debug.WriteLine(cont.ToString()); myRow[cl++].addText(TiraCaractEspecial(row["cmpDcLocal"].ToString())); } else { myRow[cl++].addText(" "); } myRow[cl++].addText(row["cmpDtAbertura"].ToString().Substring(0, 10)); myRow[cl++].addText(row["cmpDtConclusaoAtendimento"].ToString() == "" ? "" : row["cmpDtConclusaoAtendimento"].ToString().Substring(0, 10)); } else { cl = 0; myRow = myTable.createRow(); myRow.rowStyle = myTable.rowStyle; myRow[cl++].addText(""); myRow[cl++].addText(""); myRow[cl++].addText(row["cmpDcObservacoes"].ToString().Substring(StrInicio, StrFim).Trim()); myRow[cl++].addText(""); myRow[cl++].addText(""); myRow[cl++].addText(""); } myTable.addRow(myRow); StrInicio += QtdCaracterLinha; top += nTamLinPixel; } } else { myRow[cl++].addText(row["cmpDcDescricaoSolicitacao"].ToString().TrimEnd()); myRow[cl++].addText(row["cmpDcLocal"].ToString()); myRow[cl++].addText(row["cmpDtAbertura"].ToString().Substring(0, 10)); myRow[cl++].addText(row["cmpDtConclusaoAtendimento"].ToString() == "" ? "" : row["cmpDtConclusaoAtendimento"].ToString().Substring(0, 10)); myTable.addRow(myRow); top += nTamLinPixel; } if (top > 1230) { myPage.addText("Pág. " + pg++, leftMargin, 10, myDoc.getFontReference(strFont), 10, pdfColor.Black); myPage.addTable(myTable); // Adiciona uma página myPage = myDoc.addPage(predefinedPageSize.csSharpPDFFormat); top = 30; CabRelatorio(myDoc, myPage, top, DadosObra, DataInicial, DataFinal); top += 30; myTable = SubCabRelatorio(myDoc, myPage, top); top = +10; } } if (top < 1230) { myPage.addText("Pág. " + pg++, leftMargin, 10, myDoc.getFontReference(strFont), 10, pdfColor.Black); myPage.addTable(myTable); } return(myDoc); }
public static pdfDocument ImprimePlano(DataTable table, string NoObra) { String strFont = "Helvetica"; int leftMargin = 30; int pg = 1; int top = 40; //Tamanho da lin em pixel int nTamLinPixel = 12; // Variaveis de controle para quebra de linha de campos int QtdCaracterLinha = 120; int Tamanho; int QtdLin; int StrInicio; int StrFim; int cl; // Adiciona Página pdfDocument myDoc = new pdfDocument("Horizon", "Orion"); pdfPage myPage = myDoc.addPage(predefinedPageSize.csSharpPDFFormat); CabRelatorio(myDoc, myPage, top, NoObra); top += 40; // Create Table pdfTable myTable; // Create Table Row pdfTableRow myRow; string TipoAtividade = table.Rows[0]["cmpCoTipoAtividade"].ToString(); string GrupoAtividade = table.Rows[0]["cmpCoGrupoAtividade"].ToString(); string Periodicidade = table.Rows[0]["cmpCoPeriodicidade"].ToString(); myTable = SubCabRelatorio(myDoc, myPage, top, table.Rows[0]["cmpDcTipoAtividade"].ToString(), table.Rows[0]["cmpDcGrupoAtividade"].ToString(), table.Rows[0]["cmpDcPeriodicidade"].ToString()); top += 90; int i = 1; foreach (DataRow row in table.Rows) { cl = 0; if (TipoAtividade != row["cmpCoTipoAtividade"].ToString() || GrupoAtividade != row["cmpCoGrupoAtividade"].ToString() || Periodicidade != row["cmpCoPeriodicidade"].ToString()) { TipoAtividade = row["cmpCoTipoAtividade"].ToString(); GrupoAtividade = row["cmpCoGrupoAtividade"].ToString(); Periodicidade = row["cmpCoPeriodicidade"].ToString(); myPage.addTable(myTable); if (pg == 2 && i == 0) { break; } top += 20; myTable = SubCabRelatorio(myDoc, myPage, top, row["cmpDcTipoAtividade"].ToString(), row["cmpDcGrupoAtividade"].ToString(), row["cmpDcPeriodicidade"].ToString()); top += 90; cl = 0; i++; } myRow = myTable.createRow(); myRow.rowStyle = myTable.rowStyle; row["cmpDcItemAtividadePreventiva"] = TiraCaractEspecial(row["cmpDcItemAtividadePreventiva"].ToString()); Tamanho = row["cmpDcItemAtividadePreventiva"].ToString().Length; if (Tamanho > 0) { QtdLin = (Tamanho % QtdCaracterLinha == 0 ? Tamanho / QtdCaracterLinha : (Tamanho / QtdCaracterLinha) + 1); StrInicio = 0; for (int Linha = 1; Linha <= QtdLin; Linha++) { StrFim = Linha == QtdLin ? Tamanho - StrInicio : QtdCaracterLinha; if (Linha == 1) { myRow[cl++].addText(row["cmpDcItemAtividadePreventiva"].ToString().Substring(StrInicio, StrFim).Trim()); } else { cl = 0; myRow = myTable.createRow(); myRow.rowStyle = myTable.rowStyle; myRow[cl++].addText(row["cmpDcItemAtividadePreventiva"].ToString().Substring(StrInicio, StrFim).Trim()); } myTable.addRow(myRow); StrInicio += QtdCaracterLinha; top += nTamLinPixel; //if (top % 3 == 0) // top -= 3; } } if (top > 700) //(top > 1230) { myPage.addText("Pág. " + pg++, leftMargin, 10, myDoc.getFontReference(strFont), 10, pdfColor.Black); myPage.addTable(myTable); // Adiciona uma página myPage = myDoc.addPage(predefinedPageSize.csSharpPDFFormat); top = 40; CabRelatorio(myDoc, myPage, top, NoObra); top += 40; myTable = SubCabRelatorio(myDoc, myPage, top, row["cmpDcTipoAtividade"].ToString(), row["cmpDcGrupoAtividade"].ToString(), row["cmpDcPeriodicidade"].ToString()); top = +90; if (pg == 2) { i = 0; } } //if (pg == 3) // break; } return(myDoc); }
public static pdfDocument ImprimePlano(DataTable table, string NoObra) { String strFont = "Helvetica"; int leftMargin = 30; int pg = 1; int top = 40; //Tamanho da lin em pixel int nTamLinPixel = 19; // Variaveis de controle para quebra de linha de campos int QtdCaracterLinha = 100; int Tamanho; int QtdLin; int StrInicio; int StrFim; int cl; // Adiciona Página pdfDocument myDoc = new pdfDocument("Horizon", "Orion"); pdfPage myPage = myDoc.addPage(predefinedPageSize.csSharpPDFFormat); string DadosObra = NoObra; CabRelatorio(myDoc, myPage, top, DadosObra); top += 30; pdfTable myTable = SubCabRelatorio(myDoc, myPage, top); top += 10; string TipoAtividade = ""; string GrupoAtividade = ""; string Periodicidade = ""; // Imprimir linhas de detalhes pdfTableRow myRow = myTable.createRow(); try { foreach (DataRow row in table.Rows) { cl = 0; myRow = myTable.createRow(); myRow.rowStyle = myTable.rowStyle; if (TipoAtividade != row["cmpCoTipoAtividade"].ToString()) { row["cmpDcTipoAtividade"] = TiraCaractEspecial(row["cmpDcTipoAtividade"].ToString()); myRow[cl++].addText(row["cmpDcTipoAtividade"].ToString().TrimEnd()); TipoAtividade = row["cmpCoTipoAtividade"].ToString(); } else { myRow[cl++].addText(""); } if (GrupoAtividade != row["cmpCoGrupoAtividade"].ToString()) { row["cmpDcGrupoAtividade"] = TiraCaractEspecial(row["cmpDcGrupoAtividade"].ToString()); myRow[cl++].addText(row["cmpDcGrupoAtividade"].ToString().TrimEnd()); GrupoAtividade = row["cmpCoGrupoAtividade"].ToString(); } else { myRow[cl++].addText(""); } if (Periodicidade != row["cmpCoPeriodicidade"].ToString()) { myRow[cl++].addText(row["cmpDcPeriodicidade"].ToString()); Periodicidade = row["cmpCoPeriodicidade"].ToString(); } else { myRow[cl++].addText(""); } row["cmpDcItemAtividadePreventiva"] = TiraCaractEspecial(row["cmpDcItemAtividadePreventiva"].ToString()); Tamanho = row["cmpDcItemAtividadePreventiva"].ToString().Length; if (Tamanho > 0) { QtdLin = (Tamanho % QtdCaracterLinha == 0 ? Tamanho / QtdCaracterLinha : (Tamanho / QtdCaracterLinha) + 1); StrInicio = 0; for (int Linha = 1; Linha <= QtdLin; Linha++) { StrFim = Linha == QtdLin ? Tamanho - StrInicio : QtdCaracterLinha; if (Linha == 1) { myRow[cl++].addText(row["cmpDcItemAtividadePreventiva"].ToString().Substring(StrInicio, StrFim).Trim()); } else { cl = 0; myRow = myTable.createRow(); myRow.rowStyle = myTable.rowStyle; myRow[cl++].addText(""); myRow[cl++].addText(""); myRow[cl++].addText(""); myRow[cl++].addText(row["cmpDcItemAtividadePreventiva"].ToString().Substring(StrInicio, StrFim).Trim()); } myTable.addRow(myRow); StrInicio += QtdCaracterLinha; top += nTamLinPixel; } } //else //{ // myRow[cl++].addText(row["cmpDcDescricaoSolicitacao"].ToString().TrimEnd()); // myRow[cl++].addText(row["cmpDcLocal"].ToString()); // myRow[cl++].addText(row["cmpDtAbertura"].ToString().Substring(0, 10)); // myRow[cl++].addText(row["cmpDtConclusaoAtendimento"].ToString() == "" ? "" : row["cmpDtConclusaoAtendimento"].ToString().Substring(0, 10)); // myTable.addRow(myRow); // top += nTamLinPixel; //} if (top > 1250) { myPage.addText("Pág. " + pg++, leftMargin, 10, myDoc.getFontReference(strFont), 10, pdfColor.Black); myPage.addTable(myTable); // Adiciona uma página myPage = myDoc.addPage(predefinedPageSize.csSharpPDFFormat); top = 30; CabRelatorio(myDoc, myPage, top, DadosObra); top += 30; myTable = SubCabRelatorio(myDoc, myPage, top); top = +10; } } if (top < 1250) { myPage.addText("Pág. " + pg++, leftMargin, 10, myDoc.getFontReference(strFont), 10, pdfColor.Black); myPage.addTable(myTable); } } catch (Exception ex) { Global.ShowError(Global.Title, ex); } return(myDoc); }
public int CreatePDF(int id, string idrecord) { int pageIndex = 0; int tableIndex = 0; DateTime dateNow = DateTime.Now; string getDate = String.Format("{0:D4}/{1:D2}/{2:D2} {3:D2}:{4:D2}", dateNow.Year, dateNow.Month, dateNow.Day, dateNow.Hour, dateNow.Minute); this.Get_user(id); this.Get_GameDetail(idrecord); this.Get_GameRecord(id, idrecord); attachName = "Rundom_" + nama.ToUpper() + "_" + gametype + "_" + idrecord + ".pdf"; myDoc = new pdfDocument("Rundom PDF Proses", "rajebdev", false); myFirstPage = myDoc.addPage(); pageList.Add(myFirstPage); pageList[0].addText("Hasil Perkembangan Siswa - RUNDOM GAME", 45, 730, predefinedFont.csHelveticaOblique, 20, new pdfColor(predefinedColor.csBlack)); pageList[0].addText("Nama Siswa : " + nama.ToUpper(), 50, 680, predefinedFont.csHelveticaOblique, 14, new pdfColor(predefinedColor.csBlack)); pageList[0].addText("Jenis Kelamin : " + sex, 50, 660, predefinedFont.csHelveticaOblique, 14, new pdfColor(predefinedColor.csBlack)); pageList[0].addText("Tingkatan : " + gametype, 50, 640, predefinedFont.csHelveticaOblique, 14, new pdfColor(predefinedColor.csBlack)); pageList[0].addText("ID Permainan : " + idrecord, 50, 620, predefinedFont.csHelveticaOblique, 14, new pdfColor(predefinedColor.csBlack)); pageList[0].addText("Ringkasan Permainan ", 50, 580, predefinedFont.csHelveticaOblique, 16, new pdfColor(predefinedColor.csBlack)); tableList.Add(new pdfTable()); //Set table's border tableList[tableIndex].borderSize = 1; tableList[tableIndex].borderColor = new pdfColor(predefinedColor.csDarkBlue); /*Set Header's Style*/ tableList[tableIndex].tableHeaderStyle = new pdfTableRowStyle(predefinedFont.csCourierBoldOblique, 12, new pdfColor(predefinedColor.csBlack), new pdfColor(predefinedColor.csLightOrange)); tableList[tableIndex].rowStyle = new pdfTableRowStyle(predefinedFont.csCourier, 12, new pdfColor(predefinedColor.csBlack), new pdfColor(predefinedColor.csWhite)); tableList[tableIndex].alternateRowStyle = new pdfTableRowStyle(predefinedFont.csCourier, 12, new pdfColor(predefinedColor.csBlack), new pdfColor(predefinedColor.csLightYellow)); tableList[tableIndex].cellpadding = 7; //========================== /*Add Columns to a grid*/ tableList[tableIndex].tableHeader.addColumn(new pdfTableColumn("Keterangan", predefinedAlignment.csCenter, 150)); tableList[tableIndex].tableHeader.addColumn(new pdfTableColumn("Nilai", predefinedAlignment.csCenter, 200)); pdfTableRow myRow = tableList[tableIndex].createRow(); myRow[0].columnValue = "Jumlah Benar"; myRow[1].columnValue = nilaibenar; tableList[tableIndex].addRow(myRow); pdfTableRow myRow1 = tableList[tableIndex].createRow(); myRow1[0].columnValue = "Jumlah Salah"; myRow1[1].columnValue = nilaisalah; tableList[tableIndex].addRow(myRow1); pdfTableRow myRow2 = tableList[tableIndex].createRow(); myRow2[0].columnValue = "Score"; myRow2[1].columnValue = score; tableList[tableIndex].addRow(myRow2); pdfTableRow myRow3 = tableList[tableIndex].createRow(); myRow3[0].columnValue = "Waktu"; myRow3[1].columnValue = time + " Detik"; tableList[tableIndex].addRow(myRow3); pdfTableRow myRow4 = tableList[tableIndex].createRow(); myRow4[0].columnValue = "Total Lompatan"; myRow4[1].columnValue = (int.Parse(nilaibenar) + int.Parse(nilaisalah)).ToString() + " Kali"; tableList[tableIndex].addRow(myRow4); pageList[pageIndex].addTable(tableList[tableIndex], 55, 560); // Detail Permainan pageList[0].addText("Detail Permainan ", 50, 350, predefinedFont.csHelveticaOblique, 16, new pdfColor(predefinedColor.csBlack)); tableList.Add(new pdfTable()); //Set table's border tableList[tableIndex].borderSize = 1; tableList[tableIndex].borderColor = new pdfColor(predefinedColor.csDarkBlue); /*Set Header's Style*/ tableList[1].tableHeaderStyle = new pdfTableRowStyle(predefinedFont.csCourierBoldOblique, 11, new pdfColor(predefinedColor.csBlack), new pdfColor(predefinedColor.csLightOrange)); tableList[1].rowStyle = new pdfTableRowStyle(predefinedFont.csCourier, 11, new pdfColor(predefinedColor.csBlack), new pdfColor(predefinedColor.csWhite)); tableList[1].alternateRowStyle = new pdfTableRowStyle(predefinedFont.csCourier, 11, new pdfColor(predefinedColor.csBlack), new pdfColor(predefinedColor.csLightYellow)); tableList[1].cellpadding = 5; //========================== /*Add Columns to a grid*/ tableList[1].tableHeader.addColumn(new pdfTableColumn("No", predefinedAlignment.csCenter, 30)); tableList[1].tableHeader.addColumn(new pdfTableColumn("Soal", predefinedAlignment.csCenter, 150)); tableList[1].tableHeader.addColumn(new pdfTableColumn("Jawab", predefinedAlignment.csCenter, 150)); tableList[1].tableHeader.addColumn(new pdfTableColumn("Kondisi", predefinedAlignment.csCenter, 50)); tableList[1].tableHeader.addColumn(new pdfTableColumn("Score", predefinedAlignment.csCenter, 50)); tableList[1].tableHeader.addColumn(new pdfTableColumn("Waktu", predefinedAlignment.csCenter, 70)); // add data gameecord hit to data; string connection = "URI=file:" + Application.dataPath + "/StreamingAssets/rundomdb.db"; IDbConnection dbcon = new SqliteConnection(connection); dbcon.Open(); IDbCommand cmnd_read = dbcon.CreateCommand(); IDataReader reader; string query = "SELECT * FROM GameRecordHit" + " WHERE idGameRecord='" + idrecord + "'"; cmnd_read.CommandText = query; reader = cmnd_read.ExecuteReader(); int no = 1; int tmp = 0; while (reader.Read()) { pdfTableRow tmpRow = tableList[1].createRow(); tmpRow[0].columnValue = no.ToString(); tmpRow[1].columnValue = soal[int.Parse(reader[1].ToString())]; tmpRow[2].columnValue = reader[6].ToString() + " " + namaBangun[int.Parse(reader[5].ToString())]; tmpRow[3].columnValue = reader[3].ToString() == "0" ? "SALAH" : "BENAR"; tmpRow[4].columnValue = reader[4].ToString(); tmpRow[5].columnValue = (int.Parse(reader[7].ToString()) - tmp).ToString() + " Detik"; tmp = int.Parse(reader[7].ToString()); tableList[1].addRow(tmpRow); no++; } pageList[pageIndex].addTable(tableList[1], 55, 330); pageList[0].addText("Generate at " + getDate, 400, 50, predefinedFont.csHelveticaOblique, 8, new pdfColor(predefinedColor.csBlack)); myDoc.createPDF(Application.dataPath + "/StreamingAssets/Pdf File/" + attachName); if (myDoc.isSucces == true) { pdfSuc.SetActive(true); } else { pdfWarn.SetActive(true); } pageList = null; tableList = null; return(0); }
protected void Page_Load(object sender, EventArgs e) { HzConexao c = new HzConexao(@"192.168.200.170\desenv", "sa", "rona3007", "HzManutencao", "System.Data.SqlClient"); String strFont = "Helvetica"; int leftMargin = 30; int topMargin = 30; int bottomMargin = 30; int lineHeight = 20; int linesPerPage; pdfDocument myDoc = new pdfDocument("Horizon", "Orion"); // Add a page pdfPage myPage = myDoc.addPage(predefinedPageSize.csSharpPDFFormat); // Load an image (I was able to load JPEG, GIF, TIFF, and BMP formats) //myDoc.addImageReference(Server.MapPath("~/Assets/Images/Sample.gif"), "ex"); //myPage.addImage(myDoc.getImageReference("ex"), leftMargin, getTop(myPage, 120)); // Header Text myPage.addText("Ordem de Serviço", leftMargin, getTop(myPage, 30), myDoc.getFontReference(strFont), 15, pdfColor.Black); // Body Text //myPage.addText("Divisão de Administração Predial, Obras e Instalações", leftMargin, getTop(myPage, 50), // myDoc.getFontReference(strFont), 10, pdfColor.Black); //myPage.addText("Relatório emitido em: " + DateTime.Now.ToShortDateString(), leftMargin, getTop(myPage, 70), // myDoc.getFontReference(strFont), 10, pdfColor.Black); //pdfTable myTable = new pdfTable(myDoc, 1, new pdfColor("000000"), 2, // new pdfTableStyle(myDoc.getFontReference(strFont), // 10, pdfColor.Black, new pdfColor("d9d1b3")), // new pdfTableStyle(myDoc.getFontReference(strFont), // 10, pdfColor.Black, pdfColor.White), // new pdfTableStyle(myDoc.getFontReference(strFont), // 10, pdfColor.Black, pdfColor.White)); int q = 0; int pg = 1; int top = 40; using (DataTable table = c.loadDataTable("select * from HzManutencao..vwATE_OS where cmpIdOS = 1")) { if (table != null && table.Rows.Count > 0) { DataRow r = table.Rows[0]; pdfTable myTable = new pdfTable(myDoc, 1, new pdfColor("000000"), 2, new pdfTableStyle(myDoc.getFontReference(strFont), 10, pdfColor.Black, new pdfColor("FFFFFF")), new pdfTableStyle(myDoc.getFontReference(strFont), 10, pdfColor.Black, pdfColor.White)); myTable.coordX = leftMargin; myTable.coordY = getTop(myPage, top); //// Create table's header int cl = 0; myTable.tableHeader.rowHeight = 10; myTable.tableHeader.addColumn(150, predefinedAlignment.csLeft); myTable.tableHeader[cl++].addText("Nº O.S."); myTable.tableHeader.addColumn(420, predefinedAlignment.csLeft); myTable.tableHeader[cl].columnAlign = predefinedAlignment.csLeft; myTable.tableHeader[cl++].addText(r["cmpNuOS"].ToString()); // Create Table Row pdfTableRow myRow = myTable.createRow(); cl = 0; myRow = myTable.createRow(); myRow[cl].columnAlign = predefinedAlignment.csLeft; myRow[cl++].addText("Data Solicitação:"); myRow[cl++].addText(r["cmpDtAbertura"].ToString().Trim()); myTable.addRow(myRow); cl = 0; myRow = myTable.createRow(); myRow[cl].columnAlign = predefinedAlignment.csLeft; myRow[cl++].addText("Obra:"); myRow[cl++].addText(r["cmpNoObra"].ToString().Trim() + (r["cmpNuContrato"] != null ? " -> Contrato nº " + r["cmpNuContrato"].ToString() : "")); myTable.addRow(myRow); cl = 0; myRow = myTable.createRow(); myRow[cl].columnAlign = predefinedAlignment.csLeft; myRow[cl++].addText("Soliciante:"); myRow[cl++].addText(r["cmpNoSolicitante"].ToString().Trim()); myTable.addRow(myRow); cl = 0; myRow = myTable.createRow(); myRow[cl].columnAlign = predefinedAlignment.csLeft; myRow[cl++].addText("Local:"); myRow[cl++].addText(r["cmpDcLocal"].ToString().Trim()); myTable.addRow(myRow); cl = 0; myRow = myTable.createRow(); myRow[cl].columnAlign = predefinedAlignment.csLeft; myRow[cl++].addText("Setor:"); myRow[cl++].addText(r["cmpNoSetor"].ToString().Trim()); myTable.addRow(myRow); cl = 0; myRow = myTable.createRow(); myRow[cl].columnAlign = predefinedAlignment.csLeft; myRow[cl++].addText("Data Início:"); myRow[cl++].addText(r["cmpDtInicioAtendimento"].ToString() != "" ? DateTime.Parse(r["cmpDtInicioAtendimento"].ToString()).ToString("dd/MM/yyyy HH:mm") : ""); myTable.addRow(myRow); cl = 0; myRow = myTable.createRow(); myRow[cl].columnAlign = predefinedAlignment.csLeft; myRow[cl++].addText("Data Conclusão:"); myRow[cl++].addText(r["cmpDtConclusaoAtendimento"].ToString() != "" ? DateTime.Parse(r["cmpDtConclusaoAtendimento"].ToString()).ToString("dd/MM/yyyy HH:mm") : ""); myTable.addRow(myRow); cl = 0; myRow = myTable.createRow(); myRow[cl].columnAlign = predefinedAlignment.csLeft; myRow[cl++].addText("Descrição do Serviço:"); myRow[cl++].addText(r["cmpDcDescricaoSolicitacao"].ToString().Trim()); myTable.addRow(myRow); cl = 0; myRow = myTable.createRow(); myRow.rowHeight = 50; myRow[cl].columnAlign = predefinedAlignment.csLeft; myRow[cl++].addText("Verificação do Serviço:"); myRow[cl++].addText(r["cmpDcObservacaoConclusao"].ToString().Trim()); myTable.addRow(myRow); top += 10 * 9; myPage.addTable(myTable); top += 100; myPage.addText("Material Utilizado", leftMargin, this.getTop(myPage, top), myDoc.getFontReference(strFont), 10, pdfColor.Black); top += 12; string sql = "select * from HzManutencao..vwATE_OSMaterial where cmpIdOS = " + r["cmpIdOS"].ToString(); using (DataTable tblMat = Global.GetConnection().loadDataTable(sql)) { if (tblMat != null && tblMat.Rows.Count > 0) { myTable = new pdfTable(myDoc, 1, new pdfColor("000000"), 2, new pdfTableStyle(myDoc.getFontReference(strFont), 8, pdfColor.Black, new pdfColor("FFFFFF")), new pdfTableStyle(myDoc.getFontReference(strFont), 8, pdfColor.Black, pdfColor.White)); myTable.coordX = leftMargin; //top = 210; myTable.coordY = getTop(myPage, top); //// Create table's header cl = 0; myTable.tableHeader.rowHeight = 10; myTable.tableHeader.addColumn(350, predefinedAlignment.csLeft); myTable.tableHeader[cl++].addText("Descrição"); myTable.tableHeader.addColumn(30, predefinedAlignment.csCenter); myTable.tableHeader[cl].columnAlign = predefinedAlignment.csCenter; myTable.tableHeader[cl++].addText("Unid"); myTable.tableHeader.addColumn(50, predefinedAlignment.csRight); myTable.tableHeader[cl].columnAlign = predefinedAlignment.csRight; myTable.tableHeader[cl++].addText("Qtd."); myTable.tableHeader.addColumn(50, predefinedAlignment.csRight); myTable.tableHeader[cl].columnAlign = predefinedAlignment.csRight; myTable.tableHeader[cl++].addText("Preço"); myTable.tableHeader.addColumn(90, predefinedAlignment.csRight); myTable.tableHeader[cl].columnAlign = predefinedAlignment.csRight; myTable.tableHeader[cl++].addText("Sub-Total"); top += 15; float total = 0f; foreach (DataRow row in tblMat.Rows) { // Create Table Row myRow = myTable.createRow(); cl = 0; myRow = myTable.createRow(); myRow[cl].columnAlign = predefinedAlignment.csLeft; myRow[cl++].addText(row["DcMaterial"].ToString().Trim()); myRow[cl++].addText(row["cmpDcUnidade"].ToString().Trim()); myRow[cl++].addText(decimal.Parse(row["cmpQtMaterial"].ToString()).ToString("0,0.00")); myRow[cl++].addText(decimal.Parse(row["cmpVlMaterial"].ToString()).ToString("0,0.00")); myRow[cl++].addText(decimal.Parse(row["cmpVlSubTotal"].ToString()).ToString("0,0.00")); total += float.Parse(row["cmpVlSubTotal"].ToString()); myTable.addRow(myRow); top += 12; } myPage.addTable(myTable); top += 3; myTable = new pdfTable(myDoc, 1, new pdfColor("000000"), 2, new pdfTableStyle(myDoc.getFontReference(strFont), 10, pdfColor.Black, new pdfColor("FFFFFF")), new pdfTableStyle(myDoc.getFontReference(strFont), 10, pdfColor.Black, pdfColor.White)); myTable.coordX = leftMargin; myTable.coordY = getTop(myPage, top); //// Create table's header cl = 0; myTable.tableHeader.rowHeight = 10; myTable.tableHeader.addColumn(570, predefinedAlignment.csRight); //IFormatProvider fp = new CultureInfo("pt-BR", true); myTable.tableHeader[cl++].addText("Total: " + total.ToString("0,0.00")); top += 17; myPage.addTable(myTable); } } myTable = new pdfTable(myDoc, 1, new pdfColor("000000"), 2, new pdfTableStyle(myDoc.getFontReference(strFont), 10, pdfColor.Black, new pdfColor("FFFFFF")), new pdfTableStyle(myDoc.getFontReference(strFont), 10, pdfColor.Black, pdfColor.White)); myTable.coordX = leftMargin; myTable.coordY = getTop(myPage, top); //// Create table's header cl = 0; myTable.tableHeader.rowHeight = 30; myTable.tableHeader.rowVerticalAlign = predefinedVerticalAlignment.csTop; myTable.tableHeader.addColumn(570, predefinedAlignment.csLeft); myTable.tableHeader[cl].columnVerticalAlign = predefinedVerticalAlignment.csTop; myTable.tableHeader[cl++].addText("Conclusão/Aceite do Solicitante"); top += 30; cl = 0; myRow = myTable.createRow(); myRow.rowHeight = 10; myRow[cl].columnAlign = predefinedAlignment.csLeft; myRow[cl++].addText("Data: " + DateTime.Now.ToShortDateString() + " às " + DateTime.Now.ToShortTimeString()); myTable.addRow(myRow); top += 15; cl = 0; myRow = myTable.createRow(); myRow.rowHeight = 10; myRow[cl].columnAlign = predefinedAlignment.csLeft; myRow[cl++].addText("Satisfeito com o serviço: " + "__Sim __Não"); myTable.addRow(myRow); top += 15; myPage.addTable(myTable); myTable = new pdfTable(myDoc, 1, new pdfColor("000000"), 2, new pdfTableStyle(myDoc.getFontReference(strFont), 10, pdfColor.Black, new pdfColor("FFFFFF")), new pdfTableStyle(myDoc.getFontReference(strFont), 10, pdfColor.Black, pdfColor.White)); myTable.coordX = leftMargin; myTable.coordY = getTop(myPage, top); cl = 0; myTable.tableHeader.rowHeight = 50; myTable.tableHeader.rowVerticalAlign = predefinedVerticalAlignment.csBottom; myTable.tableHeader.addColumn(285, predefinedAlignment.csCenter); myTable.tableHeader[cl].columnVerticalAlign = predefinedVerticalAlignment.csBottom; myTable.tableHeader[cl++].addText("De acordo Empresa"); myTable.tableHeader.addColumn(285, predefinedAlignment.csCenter); myTable.tableHeader[cl].columnVerticalAlign = predefinedVerticalAlignment.csBottom; myTable.tableHeader[cl].addText("De acordo Gestor"); myPage.addTable(myTable); myPage.addText("Pág. " + pg++, leftMargin, 10, myDoc.getFontReference(strFont), 5, pdfColor.Black); //string nomepdf = "c:\\Horizon\\Ocr\\Relatorios\\" + "Relatorio_" + (txtPlacaRelatorio.Text != "" ? txtPlacaRelatorio.Text : "Todas") + "_" + retornaDataRelatorio(txtDataInicial.Text) + "_" + retornaDataRelatorio(txtDataFinal.Text) + ".pdf"; string nomepdf = Server.MapPath("pdf" + DateTime.Now.Day.ToString() + DateTime.Now.Month.ToString() + DateTime.Now.Year.ToString() + DateTime.Now.Millisecond.ToString() + ".pdf"); myDoc.createPDF(nomepdf); System.Diagnostics.Process.Start(nomepdf); } } ++q; //if (q == 30) //{ // myPage.addText("Pág. " + pg++, leftMargin, 10, // myDoc.getFontReference(strFont), 5, pdfColor.Black); // myPage.addTable(myTable); // myPage = myDoc.addPage(predefinedPageSize.csSharpPDFFormat); // q = 0; // myTable = new pdfTable(myDoc, 1, new pdfColor("000000"), 5, // new pdfTableStyle(myDoc.getFontReference(strFont), // 10, pdfColor.Black, new pdfColor("d9d1b3")), // new pdfTableStyle(myDoc.getFontReference(strFont), // 10, pdfColor.Black, pdfColor.White), // new pdfTableStyle(myDoc.getFontReference(strFont), // 10, pdfColor.Black, pdfColor.White)); // myTable.coordX = leftMargin; // myTable.coordY = getTop(myPage, 100); // // Create table's header // myTable.tableHeader.rowHeight = 10; // c = 0; // myTable.tableHeader.addColumn(100, predefinedAlignment.csCenter); // myTable.tableHeader[c++].addText("Placa"); // if (rdbAcesso.IsChecked.Value) // { // myTable.tableHeader.addColumn(200, predefinedAlignment.csLeft); // myTable.tableHeader[c++].addText("Nome"); // } // myTable.tableHeader.addColumn(150, predefinedAlignment.csCenter); // myTable.tableHeader[c++].addText("Data"); // if (rdbAcesso.IsChecked.Value) // { // myTable.tableHeader.addColumn(100, predefinedAlignment.csCenter); // myTable.tableHeader[c].addText("Cancela"); // } // myPage.addText("Procuradoria Geral da República", leftMargin, getTop(myPage, 30), // myDoc.getFontReference(strFont), 20, pdfColor.Black); // // Body Text // myPage.addText("Relatório dos Acessos à Garagem", leftMargin, getTop(myPage, 50), // myDoc.getFontReference(strFont), 10, pdfColor.Black); // myPage.addText("Relatório emitido em: " + DateTime.Now.ToShortDateString(), leftMargin, getTop(myPage, 70), // myDoc.getFontReference(strFont), 10, pdfColor.Black); //} }
public static pdfDocument ImprimeAtividades(DataTable table, string NomeObra, string TipoAtividade, string Periodicidade) { String strFont = "Helvetica"; int leftMargin = 30; int pg = 1; int top = 20; //Tamanho da lin em pixel int nTamLinPixel = 19; // Variaveis de controle para quebra de linha de campos int QtdCaracterLinha = 50; int Tamanho; int QtdLin; int StrInicio; int StrFim; int cl; // Adiciona Página pdfDocument myDoc = new pdfDocument("Horizon", "Orion"); pdfPage myPage = myDoc.addPage(predefinedPageSize.csSharpPDFFormat); CabRelatorio(myDoc, myPage, top, NomeObra, TipoAtividade, Periodicidade); top += 50; SubCabRelatorio(myDoc, myPage, top, table.Rows[0]["cmpCoObra"].ToString(), table.Rows[0]["cmpCoPreventiva"].ToString()); top += 20; DataTable table2 = tblPreventivaAtividade.RetornaFormPreventivaPivot(Global.GetConnection(), table.Rows[0]["cmpCoPreventiva"].ToString(), table.Rows[0]["cmpCoObra"].ToString()); pdfTable myTable; string GrupoAtividade = ""; foreach (DataRow row in table2.Rows) { row["cmpDcGrupoAtividade"] = TiraCaractEspecial(row["cmpDcGrupoAtividade"].ToString().TrimEnd()); if (row["cmpDcGrupoAtividade"].ToString() != GrupoAtividade) { GrupoAtividade = row["cmpDcGrupoAtividade"].ToString(); ImprimeGrupo(myDoc, myPage, top, GrupoAtividade); top += 10; } // Imprimir Itens do grupo atividade myTable = new pdfTable(myDoc, 1, new pdfColor("000000"), 2, new pdfTableStyle(myDoc.getFontReference(strFont), 5, pdfColor.Black, new pdfColor("FFFFFF")), new pdfTableStyle(myDoc.getFontReference(strFont), 5, pdfColor.Black, pdfColor.White)); myTable.coordX = leftMargin; myTable.coordY = getTop(myPage, top); cl = 0; myTable.tableHeader.addColumn(190, predefinedAlignment.csLeft); myTable.tableHeader.rowHeight = 10; myTable.tableHeader[cl].addText(TiraCaractEspecial(row["cmpDcItemAtividadePreventiva"].ToString())); for (int i = 2; i <= 23; ++i) { myTable.tableHeader.addColumn(16, predefinedAlignment.csCenter); myTable.tableHeader[cl++].addText(""); } myPage.addTable(myTable); top += 10; } top += 20; myTable = ConclusaoRelatorio(myDoc, myPage, top); myPage.addText("Pág. " + pg++, leftMargin, 10, myDoc.getFontReference(strFont), 10, pdfColor.Black); myPage.addTable(myTable); return(myDoc); }
private void onCreatePDFFile() { if (string.IsNullOrWhiteSpace(fileName)) { NotifyWindow notifyWindow = new NotifyWindow("错误", "请先输入生成PDF文件名称!"); notifyWindow.Show(); return; } if (ImagesList.Count == 0) { NotifyWindow notifyWindow = new NotifyWindow("错误", "请先添加文件!"); notifyWindow.Show(); return; } pdfDocument doc = new pdfDocument(fileName, "", false); bool getIamge = false; foreach (AddImageEntity imageEntity in ImagesList) { try { WriteableBitmap bitmap; using (FileStream fs = new FileStream(imageEntity.FilePath, FileMode.Open)) { BitmapImage bi = new BitmapImage(); bi.SetSource(fs); bitmap = new WriteableBitmap(bi); } if (null != bitmap) { pdfPage page = doc.addPage((int)bitmap.PixelHeight, (int)bitmap.PixelWidth); page.addImage(bitmap, 0, 0); getIamge = true; createPDFFileSuccess = true; } else { createPDFFileSuccess = false; } } catch { createPDFFileSuccess = false; NotifyWindow notifyWindow = new NotifyWindow("错误", string.Format("打开图片文件{0}失败,请检查文件!!!", imageEntity.FilePath)); notifyWindow.Show(); } } if (getIamge) { tempPDFFile = System.IO.Path.GetTempFileName(); using (FileStream fs = new FileStream(tempPDFFile, FileMode.Create)) { doc.createPDF(fs); } UserFile = new UserFile(); UserFile.FileName = fileName; UserFile.FileFolder = taxPayerEntity.TaxPayerId.ToString(); UserFile.FileStream = (new FileInfo(tempPDFFile)).OpenRead(); taxPayerDocumentEntity = new TaxPayerDocumentEntity(); taxPayerDocumentEntity.TaxPayerDocumentBytes = UserFile.FileStream.Length; (OnUpdate as DelegateCommand).RaiseCanExecuteChanged(); UpdateChanged("UserFile"); } }
protected void grdOS_RowCommand(object sender, GridViewCommandEventArgs e) { string[] ParImpressao = e.CommandArgument.ToString().Split(new char[] { '$' }); try { string p; switch (e.CommandName.ToLower().Trim()) { case "lnk": if (cmbObra.SelectedItem.ToString().TrimEnd() == "SERVIÇOS DE TI" || chkServicosTI.Checked == true) { p = "webATE_ServicosTI.aspx?id=" + e.CommandArgument.ToString(); } else { p = "webATE_OS.aspx?id=" + e.CommandArgument.ToString(); } Response.Redirect(p, false); break; case "btn": ImprimirOs Imprimir = new ImprimirOs(); pdfDocument myDoc = new pdfDocument("Horizon", "Orion"); Imprimir.myDoc = myDoc; Imprimir.myPage = myDoc.addPage(predefinedPageSize.csSharpPDFFormat); Imprimir.cmpCoObra = ParImpressao[0].ToString(); Imprimir.cmpIdOS = ParImpressao[1].ToString(); Imprimir.NomeObra = cmbObra.SelectedItem.ToString(); Imprimir.EnderecoLogoOrion = Server.MapPath("~/Imagens/logo_Orion.jpg"); if (ViewState["cmpInLogoObra"].ToString() == "1") { Imprimir.EnderecoLogoObra = Server.MapPath("~/Imagens/logo_IPEN.bmp"); } else { Imprimir.EnderecoLogoObra = ""; } Imprimir.ImprimeOrdemServico(); //filename = "pdf" + DateTime.Now.Day.ToString() + DateTime.Now.Month.ToString() + DateTime.Now.Year.ToString() + DateTime.Now.Millisecond.ToString() + ".pdf"; //string nomepdf = Server.MapPath("~/Relatorios/" + filename); myDoc.createPDF(Server.MapPath("~/Relatorios/" + filename)); Response.Write("<script>window.open('" + Global.UrlRelatorio + filename + "', '_blank', 'width=850, height=600, menubar=no, resizable=yes, scrollbars=yes, top=35, left=105');</script>"); break; case "log": DataTable dtLog = tblLogOS.LogOS(Global.GetConnection(), e.CommandArgument.ToString().Trim()); grdLogs.DataSource = dtLog; grdLogs.DataBind(); ModalPopupExtender2.Show(); break; } } catch (Exception ex) { Global.ShowError(Global.Title, ex); } }
public static pdfDocument ImprimeResumoOS(DataTable table, string DataInicial, string DataFinal) { String strFont = "Helvetica"; int leftMargin = 30; int pg = 1; int top = 40; TotalOS totalos = new TotalOS(); //Tamanho da lin em pixel int nTamLinPixel = 19; // Variaveis de controle para quebra de linha de campos int QtdCaracterLinha = 120; int Tamanho; int QtdLin; int StrInicio; int StrFim; int cl; // Adiciona Página pdfDocument myDoc = new pdfDocument("Horizon", "Orion"); pdfPage myPage = myDoc.addPage(predefinedPageSize.csSharpPDFFormat); string DadosObra = (table.Rows[0]["cmpNoObra"].ToString().Trim() + (table.Rows[0]["cmpNuContrato"] != null ? " -> Contrato nº " + table.Rows[0]["cmpNuContrato"].ToString() : "")); pdfTable myTable = CabRelatorio(myDoc, myPage, top, DadosObra, DataInicial, DataFinal); // Imprimir linhas de detalhes pdfTableRow myRow = myTable.createRow(); foreach (DataRow row in table.Rows) { totalos.Adicionar(row["cmpDcOrigemOS"].ToString()); cl = 0; row["cmpDcObservacoes"] = TiraCaractEspecial(row["cmpDcObservacoes"].ToString()); Tamanho = row["cmpDcObservacoes"].ToString().Length; if (Tamanho > 0) { QtdLin = (Tamanho % QtdCaracterLinha == 0 ? Tamanho / QtdCaracterLinha : (Tamanho / QtdCaracterLinha) + 1); StrInicio = 0; for (int Linha = 1; Linha <= QtdLin; Linha++) { StrFim = Linha == QtdLin ? Tamanho - StrInicio : QtdCaracterLinha; if (Linha == 1) { myRow = myTable.createRow(); myRow.rowStyle = myTable.rowStyle; myRow[cl++].addText(row["cmpDcObservacoes"].ToString().Substring(StrInicio, StrFim).Trim()); myRow[cl++].addText(row["cmpDtAbertura"].ToString()); } else { cl = 0; myRow = myTable.createRow(); myRow.rowStyle = myTable.rowStyle; myRow[cl++].addText(row["cmpDcObservacoes"].ToString().Substring(StrInicio, StrFim).Trim()); myRow[cl++].addText(""); } myTable.addRow(myRow); StrInicio += QtdCaracterLinha; top += nTamLinPixel; } } else { myRow = myTable.createRow(); myRow.rowStyle = myTable.rowStyle; myRow[cl++].addText(row["cmpDcDescricaoSolicitacao"].ToString().TrimEnd()); myRow[cl++].addText(row["cmpDtAbertura"].ToString()); myTable.addRow(myRow); top += nTamLinPixel; } if (top > 980) { myPage.addText("Pág. " + pg++, leftMargin, 10, myDoc.getFontReference(strFont), 10, pdfColor.Black); myPage.addTable(myTable); // Adiciona uma página myPage = myDoc.addPage(predefinedPageSize.csSharpPDFFormat); top = 40; myTable = CabRelatorio(myDoc, myPage, top, DadosObra, DataInicial, DataFinal); top = +15; } } if (top < 980) { myPage.addText("Pág. " + pg++, leftMargin, 10, myDoc.getFontReference(strFont), 10, pdfColor.Black); myPage.addTable(myTable); // Adiciona uma página myPage = myDoc.addPage(predefinedPageSize.csSharpPDFFormat); top = 40; myTable = CabRelatorio(myDoc, myPage, top, DadosObra, DataInicial, DataFinal); top = +120; } // Imprimir Resumo dos atendimentos myTable = new pdfTable(myDoc, 1, new pdfColor("000000"), 2, new pdfTableStyle(myDoc.getFontReference(strFont), 12, pdfColor.Black, new pdfColor("FFFFFF")), new pdfTableStyle(myDoc.getFontReference(strFont), 10, pdfColor.Black, pdfColor.White)); myTable.coordX = leftMargin; myTable.coordY = getTop(myPage, top); cl = 0; myTable.tableHeader.rowHeight = 30; myTable.tableHeader.addColumn(300, predefinedAlignment.csCenter); myTable.tableHeader[cl++].addText("RESUMO DAS ATIVIDADES REALIZADAS"); myPage.addTable(myTable); top += 30; myTable = new pdfTable(myDoc, 1, new pdfColor("000000"), 2, new pdfTableStyle(myDoc.getFontReference(strFont), 10, pdfColor.Black, new pdfColor("FFFFFF")), new pdfTableStyle(myDoc.getFontReference(strFont), 8, pdfColor.Black, pdfColor.White)); myTable.coordX = leftMargin; myTable.coordY = getTop(myPage, top); cl = 0; myTable.tableHeader.rowHeight = 12; myTable.tableHeader.addColumn(200, predefinedAlignment.csLeft); myTable.tableHeader[cl++].addText("Tipo de Atendimento"); myTable.tableHeader.addColumn(100, predefinedAlignment.csRight); myTable.tableHeader[cl++].addText("Quantidade"); cl = 0; myRow = myTable.createRow(); myRow.rowStyle = myTable.rowStyle; myRow[cl++].addText("Eventuais"); myRow[cl++].addText(totalos.Eventual.ToString()); myTable.addRow(myRow); cl = 0; myRow = myTable.createRow(); myRow.rowStyle = myTable.rowStyle; myRow[cl++].addText("Interno"); myRow[cl++].addText(totalos.Interno.ToString()); myTable.addRow(myRow); cl = 0; myRow = myTable.createRow(); myRow.rowStyle = myTable.rowStyle; myRow[cl++].addText("Preventiva"); myRow[cl++].addText(totalos.Preventiva.ToString()); myTable.addRow(myRow); cl = 0; myRow = myTable.createRow(); myRow.rowStyle = myTable.rowStyle; myRow[cl++].addText("Externo"); myRow[cl++].addText(totalos.Externa.ToString()); myTable.addRow(myRow); cl = 0; myRow = myTable.createRow(); myRow.rowStyle = myTable.rowStyle; myRow[cl++].addText("Fora de Escopo"); myRow[cl++].addText(totalos.ForaEscopo.ToString()); myTable.addRow(myRow); myPage.addText("Pág. " + pg++, leftMargin, 10, myDoc.getFontReference(strFont), 10, pdfColor.Black); myPage.addTable(myTable); return(myDoc); }
private pdfPage getNewPage(ref double yPos) { yPos = topMargin; if (document == null) { document = new pdfDocument(myInterface.GetCompetitions()[0].Name, "Allberg Winshooter"); font = document.getFontReference(predefinedFont.csTimes); fontCompetitionHeader = document.getFontReference(predefinedFont.csTimesBold); fontHeader = document.getFontReference(predefinedFont.csTimesBold); } //double xsize = 210/conversionPixelsToMM; // A4 = 210*297mm (35,3*35,3 mm) //double ysize = 297/conversionPixelsToMM; bottomMargin = (int)((297 - 20)); //pdfPage myPage = document.addPage((int)ysize, (int)xsize); pdfPage myPage = document.addPage(predefinedPageSize.csA4Page); sharpPDF.Fonts.pdfAbstractFont headerFont = document.getFontReference(predefinedFont.csTimes); // Add copyright text addText(myPage, "WinShooter", leftMargin, (int)((bottomMargin + 3)), headerFont, 10); //addText(myPage, "©" + settings.PrinterSettings.Copyright, // leftMargin+155, (int)((bottomMargin+3)), headerFont, 10); // Add club logo Image image = settings.Logo; int logoHeight = image.Height; int logoWidth = image.Width; calculateLogoSize(image, 60, 200, out logoHeight, out logoWidth); int logoX = myPage.width - 20 - logoWidth; int logoY = myPage.height - 20 - logoHeight; try { sharpPDF.Elements.pdfImageReference imageRef = document.getImageReference("logo"); myPage.addImage(imageRef, logoX, logoY, logoHeight, logoWidth); } catch (sharpPDF.Exceptions.pdfImageNotLoadedException) { document.addImageReference((System.Drawing.Image)image, "logo"); sharpPDF.Elements.pdfImageReference imageRef = document.getImageReference("logo"); myPage.addImage(imageRef, logoX, logoY, logoHeight, logoWidth); } // Add Winshooter logo image = settings.GetWinshooterLogo(1000, 1000); logoHeight = image.Height; logoWidth = image.Width; calculateLogoSize(image, 50, 200, out logoHeight, out logoWidth); logoX = myPage.width - 20 - logoWidth; logoY = 10; try { sharpPDF.Elements.pdfImageReference imageRef = document.getImageReference("WinShooterLogo"); myPage.addImage(imageRef, logoX, logoY, logoHeight, logoWidth); } catch (sharpPDF.Exceptions.pdfImageNotLoadedException) { document.addImageReference((System.Drawing.Image)image, "WinShooterLogo"); sharpPDF.Elements.pdfImageReference imageRef = document.getImageReference("WinShooterLogo"); myPage.addImage(imageRef, logoX, logoY, logoHeight, logoWidth); } // TextStart = 20 + conversionPixelsToMM * logoHeight; return(myPage); }
public void GenBank2Pdf() { string line = ""; short index = 0; string[] tokensGenBankFlatFile = { "LOCUS", "//" }; char[] token = { ' ' }; string ContigName = ""; string BlockGenBankStart = ""; string BlockGenBankEnd = ""; string newPdfFile = ""; pdfDocument pdfGenBankFile = null; pdfPage pdfGenBankFileFilePage = null; int pagePositionTextY = 0; Console.WriteLine("Parsing...."); do { try { line = sr.ReadLine(); index = (short)line.IndexOf(tokensGenBankFlatFile[0]); if (index != -1) //found LOCUS? { BlockGenBankStart = line; line = line.Substring(5, (line.Length - 5)); line = line.Trim(); index = (short)line.IndexOf(token[0]); ContigName = line.Substring(0, index); //start to generate a new PDF Gen Bank Flat File newPdfFile = saveDirectory + "/" + ContigName + ".pdf"; pdfGenBankFile = new pdfDocument(ContigName, "Jacob Israel Cervantes Luevano"); pdfGenBankFileFilePage = pdfGenBankFile.addPage(); //sw = File.CreateText(newPdfFile); //sw.WriteLine(BlockGenBankStart); pagePositionTextY = 150; pdfGenBankFileFilePage.addText(BlockGenBankStart, 5, pagePositionTextY, predefinedFont.csHelveticaBold, 10); Console.WriteLine("Extracting data block with identifier: {0} on file:{1}", ContigName, newPdfFile); continue; } index = (short)line.IndexOf(tokensGenBankFlatFile[1]); if (index != -1) //found end block { BlockGenBankEnd = line; //sw.WriteLine(BlockGenBankEnd); //sw.Close(); pagePositionTextY = pagePositionTextY + 10; pdfGenBankFileFilePage.addText(BlockGenBankEnd, 5, pagePositionTextY, predefinedFont.csHelveticaBold, 10); pdfGenBankFile.createPDF(newPdfFile); pdfGenBankFile = null; pdfGenBankFileFilePage = null; continue; } if (line != "" && line != " " && line != string.Empty) { //sw.WriteLine(line); pagePositionTextY = pagePositionTextY + 10; pdfGenBankFileFilePage.addText(line, 5, pagePositionTextY, predefinedFont.csHelveticaBold, 10); } } //end_try catch (Exception e) { Console.WriteLine(e.Message); } //end_try_catch } //end_while while(line != null); sr.Close(); }
// Update is called once per frame public IEnumerator CreatePDF() { pdfDocument myDoc = new pdfDocument("Sample Application", "Me", false); pdfPage myFirstPage = myDoc.addPage(); pdfPage mySecondPage = myDoc.addPage(); Debug.Log("Continue to create PDF"); myFirstPage.addText("ADMIN Summary Sheet", 10, 730, predefinedFont.csHelveticaOblique, 30, new pdfColor(predefinedColor.csOrange)); /*Table's creation*/ pdfTable myTable = new pdfTable(); //Set table's border myTable.borderSize = 1; myTable.borderColor = new pdfColor(predefinedColor.csDarkBlue); /*Add Columns to a grid*/ myTable.tableHeader.addColumn(new pdfTableColumn("faculty name", predefinedAlignment.csLeft, 90)); myTable.tableHeader.addColumn(new pdfTableColumn("year", predefinedAlignment.csLeft, 90)); myTable.tableHeader.addColumn(new pdfTableColumn("subject", predefinedAlignment.csLeft, 90)); myTable.tableHeader.addColumn(new pdfTableColumn("section", predefinedAlignment.csLeft, 90)); myTable.tableHeader.addColumn(new pdfTableColumn("category name", predefinedAlignment.csLeft, 90)); myTable.tableHeader.addColumn(new pdfTableColumn("filename", predefinedAlignment.csLeft, 90)); myTable.tableHeader.addColumn(new pdfTableColumn("extension", predefinedAlignment.csLeft, 50)); pdfTableRow myRow = myTable.createRow(); myRow[0].columnValue = "preeti"; myRow[1].columnValue = "2017-18"; myRow[2].columnValue = "4-Linux System Programming"; myRow[3].columnValue = "A"; myRow[4].columnValue = "Ethics"; myRow[5].columnValue = "facnames(1).pdf"; myRow[6].columnValue = "pdf"; myTable.addRow(myRow); //pdfTableRow myRow1 = myTable.createRow(); //myRow1[0].columnValue = "B"; //myRow1[1].columnValue = "130 km/h"; //myRow1[2].columnValue = "150Kg"; //myRow1[3].columnValue = "Yellow"; //myTable.addRow(myRow1); /*Set Header's Style*/ myTable.tableHeaderStyle = new pdfTableRowStyle(predefinedFont.csCourierBoldOblique, 12, new pdfColor(predefinedColor.csBlack), new pdfColor(predefinedColor.csLightOrange)); /*Set Row's Style*/ myTable.rowStyle = new pdfTableRowStyle(predefinedFont.csCourier, 8, new pdfColor(predefinedColor.csBlack), new pdfColor(predefinedColor.csWhite)); /*Set Alternate Row's Style*/ myTable.alternateRowStyle = new pdfTableRowStyle(predefinedFont.csCourier, 8, new pdfColor(predefinedColor.csBlack), new pdfColor(predefinedColor.csLightYellow)); /*Set Cellpadding*/ myTable.cellpadding = 10; /*Put the table on the page object*/ myFirstPage.addTable(myTable, 5, 700); //yield return StartCoroutine(myFirstPage.newAddImage("D:/TEMPORARY/UnitySharpPDF/picture2.jpg", 2, 100)); //yield return StartCoroutine(mySecondPage.newAddImage("D:/TEMPORARY/UnitySharpPDF/picture1.jpg", 2, 100)); yield return(myFirstPage); yield return(mySecondPage); myDoc.createPDF(attacName); Debug.Log(" pdf created "); myTable = null; //yield return null; }
public static pdfDocument ImprimeCapaRostoOS(DataTable table, string DataInicial, string DataFinal) { String strFont = "Helvetica"; int leftMargin = 30; int pg = 1; int top = 40; //Tamanho da lin em pixel int nTamLinPixel = 19; // Variaveis de controle para quebra de linha de campos int QtdCaracterLinha = 50; int Tamanho; int QtdLin; int StrInicio; int StrFim; int cl; DataTable DtTotMatOs; decimal TotMatOs = 0; TotMaterial totalMat = new TotMaterial(); totalMat.Adicionar(table); decimal ValorBdiLucro = totalMat.Valor * decimal.Parse(table.Rows[0]["cmpPeBDILucro"].ToString()) / 100; decimal ValorBdiTributo = totalMat.Valor * decimal.Parse(table.Rows[0]["cmpPeBDITributos"].ToString()) / 100; decimal TotalMaterialLucroTributo = totalMat.Valor + ValorBdiLucro + ValorBdiTributo; // Adiciona Página pdfDocument myDoc = new pdfDocument("Horizon", "Orion"); pdfPage myPage = myDoc.addPage(predefinedPageSize.csSharpPDFFormat); string DadosObra = (table.Rows[0]["cmpNoObra"].ToString().Trim() + (table.Rows[0]["cmpNuContrato"] != null ? " -> Contrato nº " + table.Rows[0]["cmpNuContrato"].ToString() : "")); CabRelatorio(myDoc, myPage, top, DadosObra, DataInicial, DataFinal); top += 30; #region Resultado Financeiro //Imprime Total Geral de Material pdfTable myTable = new pdfTable(myDoc, 1, new pdfColor("000000"), 2, new pdfTableStyle(myDoc.getFontReference(strFont), 10, pdfColor.Black, new pdfColor("FFFFFF")), new pdfTableStyle(myDoc.getFontReference(strFont), 10, pdfColor.Black, pdfColor.White)); myTable.coordX = leftMargin; myTable.coordY = getTop(myPage, top); cl = 0; myTable.tableHeader.rowHeight = 10; myTable.tableHeader.addColumn(400, predefinedAlignment.csRight); myTable.tableHeader[cl++].addText("Total do Material R$ "); myTable.tableHeader.addColumn(150, predefinedAlignment.csRight); myTable.tableHeader[cl++].addText(totalMat.Valor.ToString("0,0.00")); top += 20; // Create Table Row pdfTableRow myRow = myTable.createRow(); cl = 0; myRow = myTable.createRow(); myRow[cl].columnAlign = predefinedAlignment.csRight; myRow[cl++].addText("Lucro + Despesas Administrativas (" + table.Rows[0]["cmpPeBDILucro"].ToString() + "%)"); myRow[cl++].addText(ValorBdiLucro.ToString("0,0.00")); myTable.addRow(myRow); top += 20; cl = 0; myRow = myTable.createRow(); myRow[cl].columnAlign = predefinedAlignment.csRight; myRow[cl++].addText("Tributos (" + table.Rows[0]["cmpPeBDITributos"].ToString() + "%)"); myRow[cl++].addText(ValorBdiTributo.ToString("0,0.00")); myTable.addRow(myRow); top += 20; cl = 0; myRow = myTable.createRow(); myRow[cl].columnAlign = predefinedAlignment.csRight; myRow[cl++].addText("Total (Material + Lucro + Tributos)"); myRow[cl++].addText(TotalMaterialLucroTributo.ToString("0,0.00")); myTable.addRow(myRow); myPage.addTable(myTable); #endregion top += 10; myTable = SubCabRelatorio(myDoc, myPage, top); top += 10; // Imprimir linhas de detalhes myRow = myTable.createRow(); foreach (DataRow row in table.Rows) { DtTotMatOs = tblOSMaterial.RetornarTotalMatOS(Global.GetConnection(), row["cmpIdOs"].ToString()); TotMatOs = DtTotMatOs.Rows[0]["TotalMaterial"].ToString() != "" ? decimal.Parse(DtTotMatOs.Rows[0]["TotalMaterial"].ToString()) : 0; cl = 0; myRow = myTable.createRow(); myRow.rowStyle = myTable.rowStyle; myRow[cl++].addText(row["cmpNuOs"].ToString()); myRow[cl++].addText(row["cmpNoSolicitante"].ToString().TrimEnd()); row["cmpDcObservacoes"] = TiraCaractEspecial(row["cmpDcObservacoes"].ToString().ToUpper()); Tamanho = row["cmpDcObservacoes"].ToString().Length; if (Tamanho > 0) { QtdLin = (Tamanho % QtdCaracterLinha == 0 ? Tamanho / QtdCaracterLinha : (Tamanho / QtdCaracterLinha) + 1); StrInicio = 0; for (int Linha = 1; Linha <= QtdLin; Linha++) { StrFim = Linha == QtdLin ? Tamanho - StrInicio : QtdCaracterLinha; if (Linha == 1) { myRow[cl++].addText(row["cmpDcObservacoes"].ToString().Substring(StrInicio, StrFim).Trim()); myRow[cl++].addText(row["cmpDcLocal"].ToString()); myRow[cl++].addText(row["cmpDtAbertura"].ToString().Substring(0, 10)); myRow[cl++].addText(row["cmpDtConclusaoAtendimento"].ToString() == "" ? "" : row["cmpDtConclusaoAtendimento"].ToString().Substring(0, 10)); myRow[cl++].addText(TotMatOs.ToString("0,0.00")); } else { cl = 0; myRow = myTable.createRow(); myRow.rowStyle = myTable.rowStyle; myRow[cl++].addText(""); myRow[cl++].addText(""); myRow[cl++].addText(row["cmpDcObservacoes"].ToString().Substring(StrInicio, StrFim).Trim()); myRow[cl++].addText(""); myRow[cl++].addText(""); myRow[cl++].addText(""); myRow[cl++].addText(""); } myTable.addRow(myRow); StrInicio += QtdCaracterLinha; top += nTamLinPixel; } } else { myRow[cl++].addText(row["cmpDcDescricaoSolicitacao"].ToString().TrimEnd()); myRow[cl++].addText(row["cmpDcLocal"].ToString()); myRow[cl++].addText(row["cmpDtAbertura"].ToString().Substring(0, 10)); myRow[cl++].addText(row["cmpDtConclusaoAtendimento"].ToString() == "" ? "" : row["cmpDtConclusaoAtendimento"].ToString().Substring(0, 10)); myRow[cl++].addText(TotMatOs.ToString("0,0.00")); myTable.addRow(myRow); top += nTamLinPixel; } if (top > 1230) { myPage.addText("Pág. " + pg++, leftMargin, 10, myDoc.getFontReference(strFont), 10, pdfColor.Black); myPage.addTable(myTable); // Adiciona uma página myPage = myDoc.addPage(predefinedPageSize.csSharpPDFFormat); top = 30; CabRelatorio(myDoc, myPage, top, DadosObra, DataInicial, DataFinal); top += 30; myTable = SubCabRelatorio(myDoc, myPage, top); top = +10; } } if (top < 1230) { //Imprime Total Geral de Material myRow = myTable.createRow(); myRow.rowStyle = myTable.rowStyle; cl = 0; myRow[cl++].addText(""); myRow[cl++].addText(""); myRow[cl++].addText(""); myRow[cl++].addText(""); myRow[cl++].addText(""); myRow[cl++].addText("Total ==>"); myRow[cl++].addText(totalMat.Valor.ToString("0,0.00")); myTable.addRow(myRow); myPage.addText("Pág. " + pg++, leftMargin, 10, myDoc.getFontReference(strFont), 10, pdfColor.Black); myPage.addTable(myTable); } return(myDoc); }
private void Main(object link) { try { _novel = KitaabGhar.GetNovelInformation(link.ToString()); LogMessage("Information collected."); LogMessage(string.Format("Total pages: {0} ({1} - {2})", _novel.TotalPages, _novel.FirstIndex, _novel.LastIndex)); } catch (Exception ex) { LogMessage("Error: " + ex.Message); _running = false; return; } var directory = System.Web.Hosting.HostingEnvironment.MapPath(Path.Combine(DownloadLocation, _novel.Name)); if (directory == null) { LogMessage("Unable to get permission"); return; } var imageFormat = Path.Combine(directory, "{0}.gif"); Directory.CreateDirectory(directory); for (var i = _novel.FirstIndex; i <= _novel.LastIndex; i++) { LogMessage("Downloading page: " + i); var r = 0; Retry: if (!_running) { return; } try { //TODO retries if (r <= 3) { //TODO resume //if (!(true && File.Exists(string.Format(imageFormat, i)))) if (!File.Exists(string.Format(imageFormat, i))) { var tempImage = Http.DownloadImage(_novel.GetImageLink(i), _novel.GetRefLink(i), _novel.NewFormat); tempImage.Save(string.Format(imageFormat, i)); tempImage.Dispose(); } if (!_running) { return; } Progress((int)((double)((i - _novel.FirstIndex) * 100) / _novel.TotalPages)); } else { LogMessage("Unable to download within the provided number of retries."); } } catch (Exception ex) { LogMessage("Unable to download page: " + i); LogMessage("Trying to download page" + i + " again."); LogMessage("Error: " + ex.Message); r++; goto Retry; } } LogMessage("Download complete."); //TODO ApplicationSettings.CreatePdf if (true) { LogMessage("Creating PDF file."); try { using (var pdfFile = new pdfDocument(_novel.Name, "Abdullah Saleem")) { for (var i = _novel.FirstIndex; i <= _novel.LastIndex; i++) { var file = string.Format(imageFormat, i); LogMessage("Processing page: " + i); if (File.Exists(file)) { try { using (var image = Image.FromFile(file)) { pdfFile.addImageReference(file, i.ToString(CultureInfo.InvariantCulture)); var tempPage = pdfFile.addPage(image.Height, image.Width); tempPage.addImage( pdfFile.getImageReference(i.ToString(CultureInfo.InvariantCulture)), 0, 0); } LogMessage("Page " + i + " added."); } catch (Exception) { LogMessage("Page number " + i + "missing."); } } else { LogMessage("Page number " + i + "missing."); } } pdfFile.createPDF(Path.Combine(directory, _novel.Name + ".pdf")); LogMessage("PDF Created!"); //TODO ApplicationSettings.OpenPdf //if (false) //{ // Process.Start(Path.Combine(directory, _novel.Name + ".pdf")); //} } } catch (Exception ex) { LogMessage("Error occured while creating the PDF."); LogMessage("Error: " + ex.Message); } } //TODO: ApplicationSettings.DeleteImages if (true) { LogMessage("Deleting images."); for (var i = _novel.FirstIndex; i <= _novel.LastIndex; i++) { if (File.Exists(string.Format(imageFormat, i))) { try { File.Delete(string.Format(imageFormat, i)); } catch (Exception ex) { LogMessage("Error occured while deleting images."); LogMessage("Error: " + ex.Message); } } } } LogMessage("Completed."); }
public pdfDocument ImprimeAgenda(DataTable table, string NoObra, string DtInicial, string DtFinal) { String strFont = "Helvetica"; int leftMargin = 30; int pg = 1; int top = 40; //Tamanho da lin em pixel int nTamLinPixel = 12; // Variaveis de controle para quebra de linha de campos int QtdCaracterLinha = 145; int Tamanho; int QtdLin; int StrInicio; int StrFim; int cl; // Adiciona Página pdfDocument myDoc = new pdfDocument("Horizon", "Orion"); pdfPage myPage = myDoc.addPage(predefinedPageSize.csSharpPDFFormat); pdfTable myTable; pdfTableRow myRow; DataTable table2; DataColumn column; string DadosObra = NoObra; int qtdReg; foreach (DataRow row in table.Rows) { top = 40; CabRelatorio(myDoc, myPage, top, DadosObra, DtInicial, DtFinal); top += 55; SubCabRelatorio(myDoc, myPage, top, row); top += 32; column = table.Columns["cmpCoPreventiva"]; table2 = tblPreventivaAtividade.Get(Global.GetConnection(), row[column].ToString()); string GrupoAtividade = ""; qtdReg = 0; foreach (DataRow row2 in table2.Rows) { row2["cmpDcGrupoAtividade"] = TiraCaractEspecial(row2["cmpDcGrupoAtividade"].ToString()); if (row2["cmpDcGrupoAtividade"].ToString() != GrupoAtividade) { qtdReg = 0; GrupoAtividade = row2["cmpDcGrupoAtividade"].ToString(); ImprimeGrupo(myDoc, myPage, top, GrupoAtividade); top += 20; ItensAtividade(myDoc, myPage, top); top += 20; } cl = 0; row2["cmpDcItemAtividadePreventiva"] = TiraCaractEspecial(row2["cmpDcItemAtividadePreventiva"].ToString()); Tamanho = row2["cmpDcItemAtividadePreventiva"].ToString().Length; if (Tamanho > 0) { QtdLin = (Tamanho % QtdCaracterLinha == 0 ? Tamanho / QtdCaracterLinha : (Tamanho / QtdCaracterLinha) + 1); StrInicio = 0; cl = 0; for (int Linha = 1; Linha <= QtdLin; Linha++) { myTable = new pdfTable(myDoc, 1, new pdfColor("000000"), 2, new pdfTableStyle(myDoc.getFontReference(strFont), 8, pdfColor.Black, new pdfColor("FFFFFF")), new pdfTableStyle(myDoc.getFontReference(strFont), 8, pdfColor.Black, pdfColor.White)); myTable.coordX = leftMargin; myTable.coordY = getTop(myPage, top); myTable.tableHeader.rowHeight = 10; myTable.tableHeader.addColumn(550, predefinedAlignment.csLeft); StrFim = Linha == QtdLin ? Tamanho - StrInicio : QtdCaracterLinha; myTable.tableHeader[cl].addText(row2["cmpDcItemAtividadePreventiva"].ToString().Substring(StrInicio, StrFim).Trim()); myPage.addTable(myTable); StrInicio += QtdCaracterLinha; top += nTamLinPixel; qtdReg++; if (top > 700) { myPage.addText("Pág. " + pg++, leftMargin, 10, myDoc.getFontReference(strFont), 10, pdfColor.Black); // Adiciona uma página myPage = myDoc.addPage(predefinedPageSize.csSharpPDFFormat); top = 40; CabRelatorio(myDoc, myPage, top, DadosObra, DtInicial, DtFinal); top += 30; if (qtdReg <= table2.Rows.Count) { SubCabRelatorio(myDoc, myPage, top, row); top += 32; ImprimeGrupo(myDoc, myPage, top, GrupoAtividade); top += 20; ItensAtividade(myDoc, myPage, top); top += 20; } } } } } myPage.addText("Pág. " + pg++, leftMargin, 10, myDoc.getFontReference(strFont), 10, pdfColor.Black); myPage = myDoc.addPage(predefinedPageSize.csSharpPDFFormat); } //if (top < 700) //{ // myPage.addText("Pág. " + pg++, leftMargin, 10, myDoc.getFontReference(strFont), 10, pdfColor.Black); //} return(myDoc); }
//Onglet Recapitulatif private void btnCreeReca_Click(object sender, EventArgs e) { try { //Initialisation des variables connec.Open(); string mois = dtpReca.Value.Month.ToString(); string annee = dtpReca.Value.Year.ToString(); string text = "____________________________________________________"; string typeNull = "Type NULL"; float montant = 0; int recette = 0; int percu = 0; int indentation = 20; int hauteurDesLignes = 720; List <string> un = new List <string>(); List <string> de = new List <string>(); List <string> tr = new List <string>(); List <string> qu = new List <string>(); List <string> ci = new List <string>(); List <string> si = new List <string>(); List <Boolean> nbTransaction = new List <Boolean>(); pdfDocument myDoc = new pdfDocument("Recapitulatif_" + mois + "_" + annee, "Pique_Sous"); pdfPage myPage = myDoc.addPage(); //SQL OleDbCommand cd1 = new OleDbCommand("SELECT [Transaction].* FROM [Transaction] WHERE MONTH([dateTransaction]) = " + dtpReca.Value.Month.ToString(), connec); OleDbDataReader dr1 = cd1.ExecuteReader(); //Lecture de la base while (dr1.Read()) { nbTransaction.Add(dr1.GetBoolean(4)); if (dr1.GetBoolean(4) == true) { recette++; } if (dr1.GetBoolean(5) == true) { percu++; } montant = montant + dr1.GetFloat(3); un.Add(dr1[1].ToString().Substring(0, 11)); de.Add(dr1[2].ToString()); tr.Add(dr1[3].ToString()); qu.Add(dr1[4].ToString()); ci.Add(dr1[5].ToString()); if (dr1[6].ToString() != "") { si.Add(dr1[6].ToString()); } else { si.Add(typeNull); } } for (int i = 0; i < si.Count; i++) { if (si[i] != typeNull) { //Pour eviter de faire une requette avec une jointure OleDbCommand cd2 = new OleDbCommand("SELECT [TypeTransaction].* FROM [TypeTransaction] where [codeType] = " + si[i], connec); OleDbDataReader dr2 = cd2.ExecuteReader(); while (dr2.Read()) { si[i] = dr2[1].ToString(); } } } //Creation du text dans le PDF myPage.addText("Recapitulatif du : " + mois + "_" + annee, indentation, hauteurDesLignes, myDoc.getFontReference(predefinedFont.csHelvetica), 20); hauteurDesLignes = hauteurDesLignes - 30; myPage.addText(text, indentation, hauteurDesLignes, myDoc.getFontReference(predefinedFont.csHelvetica), 20); hauteurDesLignes = hauteurDesLignes - 30; myPage.addText("Dépenses", indentation, hauteurDesLignes, myDoc.getFontReference(predefinedFont.csHelvetica), 20); hauteurDesLignes = hauteurDesLignes - (30 + 25 * un.Count); myPage.addText(text, indentation, hauteurDesLignes, myDoc.getFontReference(predefinedFont.csHelvetica), 20); hauteurDesLignes = hauteurDesLignes - 30; myPage.addText("Recette : " + recette.ToString(), indentation, hauteurDesLignes, myDoc.getFontReference(predefinedFont.csHelvetica), 20); hauteurDesLignes = hauteurDesLignes - 30; myPage.addText(text, indentation, hauteurDesLignes, myDoc.getFontReference(predefinedFont.csHelvetica), 20); hauteurDesLignes = hauteurDesLignes - 30; myPage.addText(" Depenses : " + montant.ToString(), indentation, hauteurDesLignes, myDoc.getFontReference(predefinedFont.csHelvetica), 20); hauteurDesLignes = hauteurDesLignes - 30; myPage.addText(text, indentation, hauteurDesLignes, myDoc.getFontReference(predefinedFont.csHelvetica), 20); hauteurDesLignes = hauteurDesLignes - 30; myPage.addText("Reste a persevoir : " + percu.ToString(), indentation, hauteurDesLignes, myDoc.getFontReference(predefinedFont.csHelvetica), 20); hauteurDesLignes = hauteurDesLignes - 30; myPage.addText(text, indentation, hauteurDesLignes, myDoc.getFontReference(predefinedFont.csHelvetica), 20); hauteurDesLignes = hauteurDesLignes - 30; myPage.addText("Somme total dépensée : -" + montant.ToString(), indentation, hauteurDesLignes, myDoc.getFontReference(predefinedFont.csHelvetica), 20); hauteurDesLignes = hauteurDesLignes - 30; myPage.addText(text, indentation, hauteurDesLignes, myDoc.getFontReference(predefinedFont.csHelvetica), 20); hauteurDesLignes = hauteurDesLignes - 30; myPage.addText("nombres de transactions : " + nbTransaction.Count.ToString(), indentation, hauteurDesLignes, myDoc.getFontReference(predefinedFont.csHelvetica), 20); hauteurDesLignes = hauteurDesLignes - 30; myPage.addText(text, indentation, hauteurDesLignes, myDoc.getFontReference(predefinedFont.csHelvetica), 20); //Initiallisation tableau PDF pdfTable myTable = new pdfTable(myDoc); myTable.borderSize = 1; myTable.borderColor = sharpPDF.pdfColor.Black; myTable.tableHeader.addColumn(90); myTable.tableHeader.addColumn(120); myTable.tableHeader.addColumn(70); myTable.tableHeader.addColumn(70); myTable.tableHeader.addColumn(70); myTable.tableHeader.addColumn(110); pdfTableRow myRow = myTable.createRow(); //Remplissage de la première ligne du tableau myRow[0].addText("Date Transaction"); myRow[1].addText("Description"); myRow[2].addText("Montant"); myRow[3].addText("Recette ?"); myRow[4].addText("Perçu ?"); myRow[5].addText("Type de dépence ?"); myTable.addRow(myRow); //Remplissage des ligne du tableau for (int i = 0; i < un.Count; i++) { myRow = myTable.createRow(); myRow[0].addText(un[i]); myRow[1].addText(de[i]); myRow[2].addText(tr[i]); myRow[3].addText(qu[i]); myRow[4].addText(ci[i]); myRow[5].addText(si[i]); myTable.addRow(myRow); } //Place le tableau myTable.coordY = 650; myTable.coordX = 20; myPage.addTable(myTable); //creer le PDF FolderBrowserDialog fbd = new FolderBrowserDialog(); if (fbd.ShowDialog() == DialogResult.OK) { myDoc.createPDF(fbd.SelectedPath + @"\Recapitulatif_" + mois + "_" + annee + ".pdf"); } myPage = null; myDoc = null; connec.Close(); MessageBox.Show("PDF créé"); } catch (InvalidOperationException erreur) { MessageBox.Show("Erreur de chaine de connexion ! pdf"); MessageBox.Show(erreur.Message); } catch (OleDbException erreur) { MessageBox.Show("Erreur de requete SQL ! pdf"); MessageBox.Show(erreur.Message); } }
// Update is called once per frame public IEnumerator CreatePDF() { pdfDocument myDoc = new pdfDocument("Sample Application", "Me", false); pdfPage myFirstPage = myDoc.addPage(); // Debug.Log ( "Continue to create PDF"); myFirstPage.addText("Daily Report", 10, 730, predefinedFont.csHelveticaOblique, 30, new pdfColor(predefinedColor.csOrange)); /*Table's creation*/ pdfTable myTable = new pdfTable(); //Set table's border myTable.borderSize = 1; myTable.borderColor = new pdfColor(predefinedColor.csDarkBlue); /*Add Columns to a grid*/ myTable.tableHeader.addColumn(new pdfTableColumn("Building1", predefinedAlignment.csRight, 120)); myTable.tableHeader.addColumn(new pdfTableColumn("Building2", predefinedAlignment.csCenter, 120)); myTable.tableHeader.addColumn(new pdfTableColumn("Building3", predefinedAlignment.csLeft, 150)); myTable.tableHeader.addColumn(new pdfTableColumn("Building4", predefinedAlignment.csLeft, 150)); pdfTableRow myRow = myTable.createRow(); myRow[0].columnValue = "A"; myRow[1].columnValue = "100 km/h"; myRow[2].columnValue = "180Kg"; myRow[3].columnValue = "Orange"; myTable.addRow(myRow); pdfTableRow myRow1 = myTable.createRow(); myRow1[0].columnValue = "B"; myRow1[1].columnValue = "130 km/h"; myRow1[2].columnValue = "150Kg"; myRow1[3].columnValue = "Yellow"; myTable.addRow(myRow1); /*Set Header's Style*/ myTable.tableHeaderStyle = new pdfTableRowStyle(predefinedFont.csCourierBoldOblique, 12, new pdfColor(predefinedColor.csBlack), new pdfColor(predefinedColor.csLightOrange)); /*Set Row's Style*/ myTable.rowStyle = new pdfTableRowStyle(predefinedFont.csCourier, 8, new pdfColor(predefinedColor.csBlack), new pdfColor(predefinedColor.csWhite)); /*Set Alternate Row's Style*/ myTable.alternateRowStyle = new pdfTableRowStyle(predefinedFont.csCourier, 8, new pdfColor(predefinedColor.csBlack), new pdfColor(predefinedColor.csLightYellow)); /*Set Cellpadding*/ myTable.cellpadding = 10; /*Put the table on the page object*/ myFirstPage.addTable(myTable, 5, 700); yield return(StartCoroutine(myFirstPage.newAddImage(Application.dataPath + "/picture2.jpg", 2, 100))); myDoc.createPDF(attacName); myTable = null; Application.OpenURL(attacName); }