private void btnSelectionText_Click(object sender, EventArgs e) { #region #SelectionText DocumentRange range = richEditControl1.Document.Selection; SubDocument doc = range.BeginUpdateDocument(); string plainText = doc.GetText(range); MessageBox.Show(plainText, "Selected Text"); doc.InsertText(range.Start, "->"); doc.InsertText(range.End, "<-"); range.EndUpdateDocument(doc); #endregion #SelectionText }
void InsertRowNumber(TableRow row, int rowNumber) { SubDocument doc = row.FirstCell.Range.BeginUpdateDocument(); DocumentRange range = doc.InsertText(row.FirstCell.Range.Start, String.Format("{0}", rowNumber + 2)); range.EndUpdateDocument(doc); }
static void ModifyFieldCode(Document document) { #region #ModifyFieldCode DocumentPosition caretPosition = document.CaretPosition; SubDocument currentDocument = caretPosition.BeginUpdateDocument(); //Create a DATE field at the caret position currentDocument.Fields.Create(caretPosition, "DATE"); currentDocument.EndUpdate(); for (int i = 0; i < currentDocument.Fields.Count; i++) { string fieldCode = document.GetText(currentDocument.Fields[i].CodeRange); if (fieldCode == "DATE") { //Retrieve the range obtained by the field code DocumentPosition position = currentDocument.Fields[i].CodeRange.End; //Insert the format switch to the end of the field code range currentDocument.InsertText(position, @"\@ ""M/d/yyyy h:mm am/pm"""); } } //Update all document fields currentDocument.Fields.Update(); #endregion #ModifyFieldCode }
private void EditComment() { #region #EditCommentContent Document document = richEditControl.Document; int commentCount = document.Comments.Count; if (commentCount > 0) { //The target comment is the first one Comment comment = document.Comments[0]; if (comment != null) { //Open the comment for modification SubDocument commentDocument = comment.BeginUpdate(); //Add text to the comment range commentDocument.InsertText(commentDocument.CreatePosition(0), "J. Taylor, Enabling Voice - over - IP and RAID with sofa, in Proceedings of NOSSDAV, Oct. 1994.\r\n" + @"R.Tarjan, S.Shenker, J.Gray, A.Einstein, Q.Thomas, and X.Sato, ""Deconstructing operating systems with flanchedripper"", in Proceedings of INFOCOM, Mar. 2000."); //End the comment update comment.EndUpdate(commentDocument); } } #endregion #EditCommentContent }
//public DxDoc(DxChartFactory factory, string projtitle, string datafile, string netid) //{ // _creator_netid = netid; // //Document doc = new DevExpress.XtraRichEdit.API.Native.Document(); //} //public DxDoc(List<DxChartOrder> ordersC, string path, string projtitle, string datafile, string netid) //{ // _creator_netid = netid; // _temppath = path; // _projtitle = projtitle; // _datafile = datafile; // _filename = "test.docx"; // filename; // MakeDocx(ordersC); // //Document doc = new DevExpress.XtraRichEdit.API.Native.Document(); //} //public DxDoc(DataTable dt_plots, List<string> htmltables, string path, string filename, string projtitle, string datafile, string netid) //{ // _creator_netid = netid; // _temppath = path; // _projtitle = projtitle; // _datafile = datafile; // _filename = filename; // MakeDocx(dt_plots, htmltables); // //Document doc = new DevExpress.XtraRichEdit.API.Native.Document(); //} //public DxDoc(DataTable dt_plots, DataTable dt_tables, string path, string filename, string projtitle, string datafile, string netid) //{ // _creator_netid = netid; // _temppath = path; // _projtitle = projtitle; // _datafile = datafile; // _filename = filename; // MakeDocx(dt_plots, dt_tables); // //Document doc = new DevExpress.XtraRichEdit.API.Native.Document(); //} #endregion protected void DocxHeader(DevExpress.XtraRichEdit.API.Native.Document doc, string s1, string s2) { DevExpress.XtraRichEdit.API.Native.Section firstSection = doc.Sections[0]; // Create an empty header. SubDocument newHeader = firstSection.BeginUpdateHeader(); firstSection.EndUpdateHeader(newHeader); // Check whether the document already has a header (the same header for all pages). if (firstSection.HasHeader(DevExpress.XtraRichEdit.API.Native.HeaderFooterType.Primary)) { SubDocument myHeader = firstSection.BeginUpdateHeader(); doc.ChangeActiveDocument(myHeader); doc.CaretPosition = myHeader.CreatePosition(0); string txt = String.Format("{0} p.", s1); DocumentRange range = myHeader.InsertText(myHeader.CreatePosition(0), txt); Field fld = myHeader.Fields.Create(range.End, "PAGE"); // "PAGE \\* ARABICDASH"); myHeader.Fields.Update(); myHeader.Paragraphs.Append(); string user_time = String.Format("{0} {1:MM/dd/yy H:mm}", _creator_netid, System.DateTime.Now); myHeader.AppendText(String.Format("{0} {1}", s2, user_time)); firstSection.EndUpdateHeader(myHeader); } }
public Form1() { InitializeComponent(); // Fill first section with text for (int i = 0; i < 5; i++) { richEditControl1.Document.AppendText(StringSample.SampleText); } // Add a header to the document Section firstSection = richEditControl1.Document.Sections[0]; SubDocument doc = firstSection.BeginUpdateHeader(); doc.InsertText(doc.CreatePosition(doc.Range.End.ToInt()), "Default Header"); firstSection.EndUpdateHeader(doc); // Add a new section with a separate header richEditControl1.Document.AppendSection(); Section newSection = richEditControl1.Document.Sections[richEditControl1.Document.Sections.Count - 1]; newSection.UnlinkHeaderFromPrevious(); doc = newSection.BeginUpdateHeader(); doc.Replace(doc.Range, "Non-Default Header"); newSection.EndUpdateHeader(doc); richEditControl1.Document.AppendText(StringSample.SampleText); }
public static void MakeMultiplicationCell(TableCell cell, int i, int j) { SubDocument doc = cell.Range.BeginUpdateDocument(); doc.InsertText(cell.Range.Start, String.Format("{0}*{1} = {2}", i + 2, j + 2, (i + 2) * (j + 2))); cell.Range.EndUpdateDocument(doc); }
private void SetTestHeaderContent() { Section firstSection = richEditControl1.Document.Sections[0]; SubDocument doc = firstSection.BeginUpdateHeader(HeaderFooterType.Odd); doc.InsertText(doc.Range.Start, "Page header"); richEditControl1.Document.Sections[0].EndUpdateHeader(doc); }
private void btnInsertText_Click(object sender, EventArgs e) { #region #InsertText DocumentPosition pos = richEditControl1.Document.CaretPosition; SubDocument doc = pos.BeginUpdateDocument(); doc.InsertText(pos, " INSERTED TEXT "); pos.EndUpdateDocument(doc); #endregion #InsertText }
public static DocumentRange InsertField(SubDocument document, DocumentPosition start, TemplateItem foundField) { if (foundField != null) { return(BuildBarcode(document, start, foundField)); } return(document.InsertText(start, string.Empty)); }
static void InsertTextAtCaretPosition(Document document) { #region #InsertTextAtCaretPosition DocumentPosition pos = document.CaretPosition; SubDocument doc = pos.BeginUpdateDocument(); doc.InsertText(pos, " INSERTED TEXT "); pos.EndUpdateDocument(doc); #endregion #InsertTextAtCaretPosition }
private static DocumentRange BuildBarcode(SubDocument document, DocumentPosition start, TemplateItem foundFeld) { if (!string.IsNullOrEmpty(foundFeld.Code)) { using (var barCode = new BarCode()) { barCode.Symbology = Symbology.Code128; barCode.Options.Code128.Charset = Code128CharacterSet.CharsetAuto; barCode.Options.Code128.ShowCodeText = false; barCode.Unit = GraphicsUnit.Point; barCode.CodeText = foundFeld.Code; barCode.CodeBinaryData = Encoding.UTF8.GetBytes(barCode.CodeText); barCode.BackColor = Color.White; barCode.ForeColor = Color.Black; if (foundFeld.BarCodeHeight.HasValue) { barCode.ImageHeight = foundFeld.BarCodeHeight.Value; } if (foundFeld.BarCodeWidth.HasValue) { barCode.ImageWidth = foundFeld.BarCodeWidth.Value; } if (foundFeld.BarCodeRotation.HasValue) { barCode.RotationAngle = foundFeld.BarCodeRotation.Value; } if (foundFeld.BarCodeAutoScale.HasValue) { barCode.AutoSize = foundFeld.BarCodeAutoScale.Value; } barCode.DpiY = foundFeld.BarCodeDpiY; barCode.DpiX = foundFeld.BarCodeDpiX; barCode.Module = foundFeld.Module.HasValue ? foundFeld.Module.Value : 1f; var img = document.Images.Insert(start, barCode.BarCodeImage); if (foundFeld.BarCodeScaleY.HasValue) { img.ScaleY = foundFeld.BarCodeScaleY.Value; } if (foundFeld.BarCodeScaleX.HasValue) { img.ScaleX = foundFeld.BarCodeScaleX.Value; } return(img.Range); } } return(document.InsertText(start, string.Empty)); }
private void barButtonItem1_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e) { DocumentPosition caretPosition = richEditControl1.Document.CaretPosition; SubDocument document = caretPosition.BeginUpdateDocument(); DocumentRange checkBox = document.InsertText(caretPosition, uncheckedCheckBox); CharacterProperties cp = document.BeginUpdateCharacters(checkBox); cp.FontName = "MS Gothic"; document.EndUpdateCharacters(cp); caretPosition.EndUpdateDocument(document); }
private void btnAppendToParagraph_Click(object sender, EventArgs e) { #region #AppendToParagraph DocumentPosition pos = richEditControl1.Document.CaretPosition; SubDocument doc = pos.BeginUpdateDocument(); Paragraph par = doc.Paragraphs.Get(pos); DocumentPosition newPos = doc.CreatePosition(par.Range.End.ToInt() - 1); doc.InsertText(newPos, "<<Appended to the End>>"); pos.EndUpdateDocument(doc); #endregion #AppendToParagraph }
private void btnEditHeader_Click(object sender, EventArgs e) { #region #EditHeader Section firstSection = richEditControl1.Document.Sections[0]; SubDocument doc = firstSection.BeginUpdateHeader(HeaderFooterType.First); DocumentRange range = doc.InsertText(doc.CreatePosition(0), " PAGE NUMBER "); Field fld = doc.Fields.Create(range.End, "PAGE \\* ARABICDASH"); doc.Fields.Update(); richEditControl1.Document.Sections[0].EndUpdateHeader(doc); richEditControl1.Document.Sections[0].DifferentFirstPage = true; #endregion #EditHeader }
TableRow InsertHeader(Table _table, string caption) { _table.BeginUpdate(); TableRow row = _table.Rows.InsertBefore(0); _table.MergeCells(row.FirstCell, row.LastCell); SubDocument doc = _table.Range.BeginUpdateDocument(); DocumentRange header_Range = doc.InsertText(row.FirstCell.Range.Start, caption); _table.Range.EndUpdateDocument(doc); _table.EndUpdate(); return(row); }
static void AppendToParagraph(Document document) { #region #AppendToParagraph document.BeginUpdate(); document.AppendText("First Paragraph\nSecond Paragraph\nThird Paragraph"); document.EndUpdate(); DocumentPosition pos = document.CaretPosition; SubDocument doc = pos.BeginUpdateDocument(); Paragraph par = doc.Paragraphs.Get(pos); DocumentPosition newPos = doc.CreatePosition(par.Range.End.ToInt() - 1); doc.InsertText(newPos, "<<Appended to Paragraph End>>"); pos.EndUpdateDocument(doc); #endregion #AppendToParagraph }
static void ModifyHeader(Document document) { #region #ModifyHeader document.AppendSection(); Section firstSection = document.Sections[0]; // Modify the header of the HeaderFooterType.First type. SubDocument myHeader = firstSection.BeginUpdateHeader(HeaderFooterType.First); DocumentRange range = myHeader.InsertText(myHeader.CreatePosition(0), " PAGE NUMBER "); Field fld = myHeader.Fields.Create(range.End, "PAGE \\* ARABICDASH"); myHeader.Fields.Update(); firstSection.EndUpdateHeader(myHeader); // Display the header of the HeaderFooterType.First type on the first page. firstSection.DifferentFirstPage = true; #endregion #ModifyHeader }
static void EditCommentContent(Document document) { #region #EditCommentContent document.LoadDocument("Documents//Grimm.docx", DevExpress.XtraRichEdit.DocumentFormat.OpenXml); int commentCount = document.Comments.Count; if (commentCount > 0) { DevExpress.XtraRichEdit.API.Native.Comment comment = document.Comments[document.Comments.Count - 1]; if (comment != null) { SubDocument commentDocument = comment.BeginUpdate(); commentDocument.InsertText(commentDocument.CreatePosition(0), "comment text"); commentDocument.Tables.Create(commentDocument.CreatePosition(13), 5, 4); comment.EndUpdate(commentDocument); } } #endregion #EditCommentContent }
public static void InsertPageNumber(Document someDocument) { for (int i = 1; i < someDocument.Sections.Count; i++) { Section currentSection = someDocument.Sections[i]; SubDocument myFooter = currentSection.BeginUpdateFooter(); DocumentRange range = myFooter.InsertText(myFooter.CreatePosition(0), " PAGE NUMBER "); Field fld = myFooter.Fields.Create(range.End, "PAGE"); myFooter.Fields.Update(); ParagraphProperties pp = myFooter.BeginUpdateParagraphs(myFooter.Range); pp.Alignment = ParagraphAlignment.Right; myFooter.EndUpdateParagraphs(pp); currentSection.EndUpdateFooter(myFooter); } }
void EditCommentContent(RichEditDocumentServer server) { #region #EditCommentContent Document document = server.Document; document.LoadDocument("Documents\\Grimm.docx", DocumentFormat.OpenXml); int commentCount = document.Comments.Count; if (commentCount > 0) { Comment comment = document.Comments[document.Comments.Count - 1]; if (comment != null) { SubDocument commentDocument = comment.BeginUpdate(); commentDocument.InsertText(commentDocument.CreatePosition(0), "some text"); commentDocument.Tables.Create(commentDocument.CreatePosition(9), 5, 4); comment.EndUpdate(commentDocument); } } #endregion #EditCommentContent }
private void button2_Click(object sender, RoutedEventArgs e) { #region #richserversave SubDocument doc = richServer.Document.Sections[0].BeginUpdateFooter(); DocumentRange docRange = doc.InsertText(doc.Range.Start, textBox1.Text); doc.InsertParagraph(docRange.End); richServer.Document.Sections[0].EndUpdateFooter(doc); SaveFileDialog sfdlg = new SaveFileDialog(); sfdlg.DefaultExt = ".docx"; sfdlg.Filter = "Word Document (*.docx)|*.docx"; if (sfdlg.ShowDialog() == true) { Stream fs = sfdlg.OpenFile(); richServer.SaveDocument(fs, DocumentFormat.OpenXml); fs.Close(); } #endregion #richserversave }
static void ProtectDocument(RichEditDocumentServer server) { #region #ProtectDocument server.LoadDocument("Documents//Grimm.docx", DocumentFormat.OpenXml); Document document = server.Document; if (!document.IsDocumentProtected) { //Protect the document with a password document.Protect("123", DocumentProtectionType.ReadOnly); //Insert a comment indicating that the document is protected document.Comments.Create(document.Paragraphs[0].Range, "Admin"); SubDocument commentDocument = document.Comments[0].BeginUpdate(); commentDocument.InsertText(commentDocument.CreatePosition(0), "Document is protected with a password.\nYou cannot modify the document until protection is removed."); commentDocument.EndUpdate(); } #endregion #ProtectDocument }
private void InsertNestedComment() { #region #NestedComment Document document = richEditControl.Document; if (document.Comments.Count > 0) { //Create a new comment nested to the second comment in the collection Comment nestedComment = document.Comments.Create("Brian Zetc", DateTime.Now, document.Comments[1]); //Add text to the newly created comment SubDocument nestedCommentDocument = nestedComment.BeginUpdate(); DocumentRange textRange = nestedCommentDocument.InsertText(nestedCommentDocument.CreatePosition(0), "Suffix trees are comprehensively reviewed in Wikipedia"); nestedComment.EndUpdate(nestedCommentDocument); } #endregion #NestedComment }
private void Button_Click(object sender, RoutedEventArgs e) { DevExpress.XtraRichEdit.API.Native.DocumentPosition pos = txtHtmlControl.Document.CaretPosition; SubDocument doc = pos.BeginUpdateDocument(); var selectedText = property; string propName = string.Concat("{", externType, ".", selectedText, "}"); if (string.IsNullOrEmpty(txtHtmlControl.Text)) { txtHtmlControl.Text = propName + " "; } else { doc.InsertText(pos, propName + " "); pos.EndUpdateDocument(doc); var position = txtHtmlControl.Document.CreatePosition(pos.ToInt() + propName.Length); txtHtmlControl.Document.CaretPosition = pos; } txtHtmlControl.Focus(); }
static void UnprotectDocument(RichEditDocumentServer server) { #region #UnprotectDocument server.LoadDocument("Documents//Grimm_Protected.docx", DocumentFormat.OpenXml); Document document = server.Document; if (document.IsDocumentProtected == true) { //Unprotect the document document.Unprotect(); //Insert a comment indicating that the document can be edited document.Comments.Create(document.Paragraphs[0].Range, "Admin"); SubDocument commentDocument = document.Comments[0].BeginUpdate(); commentDocument.InsertText(commentDocument.CreatePosition(0), "Document is unprotected. You can modify the document according to your requests."); commentDocument.EndUpdate(); } #endregion #UnprotectDocument }
public Form1() { InitializeComponent(); // Fill first section with text for (int i = 0; i < 5; i++) { richEditControl1.Document.AppendText(StringSample.SampleText); } // Add page numbering to the document Section firstSection = richEditControl1.Document.Sections[0]; SubDocument doc = firstSection.BeginUpdateHeader(); doc.InsertText(doc.CreatePosition(doc.Range.End.ToInt()), "Page "); doc.Fields.Create(doc.CreatePosition(doc.Range.End.ToInt()), "PAGE"); doc.Fields.Update(); firstSection.EndUpdateHeader(doc); // Add a new section and configure its page numbering richEditControl1.Document.AppendSection(); richEditControl1.Document.Sections[richEditControl1.Document.Sections.Count - 1].PageNumbering.FirstPageNumber = 1; richEditControl1.Document.AppendText(StringSample.SampleText); }
protected internal MemoryStream Template(bool Type, string companyName, string companyZip, string companySettlement, string companyAddress, string doctorName, int doctorSealNumber, string patientName, string motherName, DateTime birthDate, string TAJ, string patientZip, string patientSettlement, string patientAddress, string examination, string examinationCode) { Document doc = reds.Document; doc.Sections[0].Page.PaperKind = System.Drawing.Printing.PaperKind.A4; doc.DefaultCharacterProperties.FontSize = 12; doc.Unit = DevExpress.Office.DocumentUnit.Centimeter; doc.Sections[0].Margins.Bottom = 2; doc.Sections[0].Margins.Top = 2; doc.Sections[0].Margins.Left = 2; doc.Sections[0].Margins.Right = 2; doc.Sections[0].Margins.FooterOffset = 0.8F; doc.Unit = DevExpress.Office.DocumentUnit.Point; SubDocument subdoc = doc.Sections[0].BeginUpdateHeader(HeaderFooterType.Primary); DocumentRange textRange; if (Type) { textRange = subdoc.AppendText("Vizsgálati Lap"); } else { textRange = subdoc.AppendText("Státusz"); } CharacterProperties cp1 = subdoc.BeginUpdateCharacters(textRange); cp1.Bold = true; cp1.Italic = true; cp1.FontSize = 18; subdoc.EndUpdateCharacters(cp1); subdoc.Paragraphs[0].Alignment = ParagraphAlignment.Center; subdoc.Paragraphs[0].LineSpacingType = ParagraphLineSpacing.Sesquialteral; doc.Sections[0].EndUpdateHeader(subdoc); SubDocument subdoc2 = doc.Sections[0].BeginUpdateFooter(HeaderFooterType.Primary); Table table2 = subdoc2.Tables.Create(subdoc2.Range.Start, 1, 2); table2.TableLayout = TableLayoutType.Fixed; table2.PreferredWidth = 5000; table2.PreferredWidthType = WidthType.FiftiethsOfPercent; table2.Borders.InsideVerticalBorder.LineStyle = TableBorderLineStyle.None; table2.Borders.Left.LineStyle = TableBorderLineStyle.None; table2.Borders.Right.LineStyle = TableBorderLineStyle.None; table2.Borders.Bottom.LineStyle = TableBorderLineStyle.None; subdoc2.InsertText(table2[0, 0].Range.Start, DateTime.Now.ToString("yyyy. MMMM d.", new CultureInfo("hu-HU"))); DocumentRange range = subdoc2.InsertText(table2[0, 0].Range.Start, "Dátum: "); CharacterProperties cp = subdoc2.BeginUpdateCharacters(range); cp.Bold = true; subdoc2.Paragraphs[0].SpacingBefore = 3; subdoc2.InsertText(table2[0, 1].Range.Start, examinationCode); DocumentRange r = subdoc2.InsertText(table2[0, 1].Range.Start, "Azonosító: "); CharacterProperties c = subdoc2.BeginUpdateCharacters(r); c.Bold = true; subdoc2.Paragraphs[1].Alignment = ParagraphAlignment.Right; subdoc2.Paragraphs[1].SpacingBefore = 3; doc.Sections[0].EndUpdateFooter(subdoc2); Table table = doc.Tables.Create(doc.CaretPosition, 2, 2); table.TableLayout = TableLayoutType.Fixed; table.PreferredWidth = 5000; table.PreferredWidthType = WidthType.FiftiethsOfPercent; table.Borders.InsideVerticalBorder.LineStyle = TableBorderLineStyle.None; table.Borders.Left.LineStyle = TableBorderLineStyle.None; table.Borders.Right.LineStyle = TableBorderLineStyle.None; doc.InsertText(table[0, 0].Range.Start, "\t" + companyAddress); doc.InsertText(table[0, 0].Range.Start, " Címe: " + companyZip + " " + companySettlement + "\n"); doc.InsertText(table[0, 0].Range.Start, " Neve: " + companyName + "\n"); DocumentRange range1 = doc.InsertText(table[0, 0].Range.Start, "Intézmény\n"); CharacterProperties cp2 = doc.BeginUpdateCharacters(range1); cp2.Bold = true; cp2.FontSize = 16; doc.EndUpdateCharacters(cp2); doc.Paragraphs[0].SpacingBefore = 6; doc.Paragraphs[3].LineSpacingType = ParagraphLineSpacing.Sesquialteral; doc.InsertText(table[0, 1].Range.Start, " Pecsétszáma: " + doctorSealNumber); doc.InsertText(table[0, 1].Range.Start, " Neve: " + doctorName + "\n"); DocumentRange range2 = doc.InsertText(table[0, 1].Range.Start, "Orvos\n"); CharacterProperties cp3 = doc.BeginUpdateCharacters(range2); cp3.Bold = true; cp3.FontSize = 16; doc.EndUpdateCharacters(cp3); doc.Paragraphs[4].SpacingBefore = 6; doc.InsertText(table[1, 0].Range.Start, " Születési ideje: " + birthDate.ToString("yyyy. MMMM d.", new CultureInfo("hu-HU"))); doc.InsertText(table[1, 0].Range.Start, " Anyja neve: " + motherName + "\n"); doc.InsertText(table[1, 0].Range.Start, " Neve: " + patientName + "\n"); DocumentRange range3 = doc.InsertText(table[1, 0].Range.Start, "Páciens\n"); CharacterProperties cp4 = doc.BeginUpdateCharacters(range3); cp4.Bold = true; cp4.FontSize = 16; doc.EndUpdateCharacters(cp4); doc.Paragraphs[7].SpacingBefore = 6; doc.Paragraphs[10].LineSpacingType = ParagraphLineSpacing.Sesquialteral; doc.InsertText(table[1, 1].Range.Start, "\t" + patientAddress); doc.InsertText(table[1, 1].Range.Start, " Lakcíme: " + patientZip + " " + patientSettlement + "\n"); doc.InsertText(table[1, 1].Range.Start, " TAJ száma: " + TAJ + "\n"); DocumentRange range4 = doc.InsertText(table[1, 1].Range.Start, "\n"); CharacterProperties cp5 = doc.BeginUpdateCharacters(range4); cp5.Bold = true; cp5.FontSize = 16; doc.EndUpdateCharacters(cp5); doc.Paragraphs[11].SpacingBefore = 6; if (Type) { DocumentRange range5 = doc.AppendText(" Vizsgálat: "); CharacterProperties cp6 = doc.BeginUpdateCharacters(range5); cp6.Bold = true; cp6.FontSize = 16; doc.Paragraphs[15].SpacingBefore = 6; doc.Paragraphs[15].LineSpacingType = ParagraphLineSpacing.Sesquialteral; DocumentRange range6 = doc.AppendText(examination); CharacterProperties cp7 = doc.BeginUpdateCharacters(range6); cp7.Bold = false; cp7.FontSize = 12; } doc.Paragraphs.Append(); doc.Paragraphs[Type ? 16 : 15].SpacingBefore = 0; doc.Paragraphs[Type ? 16 : 15].LineSpacingType = ParagraphLineSpacing.Single; doc.AppendText(" "); RangePermissionCollection rpc = doc.BeginUpdateRangePermissions(); RangePermission rangePermission = new RangePermission(doc.Paragraphs[16].Range); rangePermission.UserName = "******"; rpc.Add(rangePermission); doc.EndUpdateRangePermissions(rpc); doc.Protect("admin"); using (MemoryStream ms = new MemoryStream()) { reds.SaveDocument(ms, DocumentFormat.OpenXml); return(ms); } }
protected internal MemoryStream Billing(string Code, CreateBillM.CompanyData from, CreateBillM.CompanyData to, ObservableCollection <CreateBillM.PrintItem> PrintList, int PriceWithoutVat, int Vat, int PriceWithVat) { Document doc = reds.Document; doc.Sections[0].Page.PaperKind = System.Drawing.Printing.PaperKind.A4; doc.DefaultCharacterProperties.FontSize = 11; doc.Unit = DevExpress.Office.DocumentUnit.Centimeter; doc.Sections[0].Margins.Bottom = 2; doc.Sections[0].Margins.Top = 2; doc.Sections[0].Margins.Left = 2; doc.Sections[0].Margins.Right = 2; doc.Sections[0].Margins.FooterOffset = 0.8F; doc.Unit = DevExpress.Office.DocumentUnit.Point; Section firstSection = doc.Sections[0]; SubDocument subdoc = firstSection.BeginUpdateHeader(HeaderFooterType.Primary); DocumentRange textRange = subdoc.AppendText("Számla"); CharacterProperties cp1 = subdoc.BeginUpdateCharacters(textRange); cp1.Bold = true; cp1.Italic = true; cp1.FontSize = 20; subdoc.EndUpdateCharacters(cp1); subdoc.Paragraphs[0].Alignment = ParagraphAlignment.Center; subdoc.Paragraphs[0].LineSpacingType = ParagraphLineSpacing.Sesquialteral; doc.Sections[0].EndUpdateHeader(subdoc); Section section = doc.Sections[0]; SubDocument subdoc2 = firstSection.BeginUpdateFooter(HeaderFooterType.Primary); Table table2 = subdoc2.Tables.Create(subdoc2.Range.Start, 1, 2); table2.TableLayout = TableLayoutType.Fixed; table2.PreferredWidth = 5000; table2.PreferredWidthType = WidthType.FiftiethsOfPercent; table2.Borders.InsideVerticalBorder.LineStyle = TableBorderLineStyle.None; table2.Borders.Left.LineStyle = TableBorderLineStyle.None; table2.Borders.Right.LineStyle = TableBorderLineStyle.None; table2.Borders.Bottom.LineStyle = TableBorderLineStyle.None; subdoc2.InsertText(table2[0, 0].Range.Start, DateTime.Now.ToString("yyyy. MMMM d.", new CultureInfo("hu-HU"))); DocumentRange range = subdoc2.InsertText(table2[0, 0].Range.Start, "Kiállítás dátuma: "); CharacterProperties cp = subdoc2.BeginUpdateCharacters(range); cp.Bold = true; subdoc2.Paragraphs[0].SpacingBefore = 3; subdoc2.InsertText(table2[0, 1].Range.Start, Code); DocumentRange r = subdoc2.InsertText(table2[0, 1].Range.Start, "Számla azonosító: "); CharacterProperties c = subdoc2.BeginUpdateCharacters(r); c.Bold = true; subdoc2.Paragraphs[1].Alignment = ParagraphAlignment.Right; subdoc2.Paragraphs[1].SpacingBefore = 3; doc.Sections[0].EndUpdateFooter(subdoc2); Table table = doc.Tables.Create(doc.Range.Start, 2, 2); table.TableLayout = TableLayoutType.Fixed; table.PreferredWidth = 5000; table.PreferredWidthType = WidthType.FiftiethsOfPercent; table.Borders.InsideVerticalBorder.LineStyle = TableBorderLineStyle.None; table.Borders.Left.LineStyle = TableBorderLineStyle.None; table.Borders.Right.LineStyle = TableBorderLineStyle.None; table.Borders.Top.LineStyle = TableBorderLineStyle.None; DocumentRange range2 = reds.Document.InsertText(table[0, 0].Range.Start, "Számla kiállító adatai"); CharacterProperties cp2 = reds.Document.BeginUpdateCharacters(range2); cp2.FontSize = 16; cp2.Bold = true; DocumentRange range3 = reds.Document.InsertText(table[0, 1].Range.Start, "Vevő adatai"); CharacterProperties cp3 = reds.Document.BeginUpdateCharacters(range3); cp3.FontSize = 16; cp3.Bold = true; ParagraphProperties props = reds.Document.BeginUpdateParagraphs(table[0, 0].Range); props.SpacingAfter = 2; Table left = doc.Tables.Create(table[1, 0].Range.Start, 1, 1); left.TableLayout = TableLayoutType.Fixed; left.PreferredWidth = 5000; left.PreferredWidthType = WidthType.FiftiethsOfPercent; left.Borders.Left.LineStyle = TableBorderLineStyle.None; left.Borders.Right.LineStyle = TableBorderLineStyle.None; left.Borders.Top.LineStyle = TableBorderLineStyle.None; left.Borders.Bottom.LineStyle = TableBorderLineStyle.None; Table right = doc.Tables.Create(table[1, 1].Range.Start, 1, 1); right.TableLayout = TableLayoutType.Fixed; right.PreferredWidth = 5000; right.PreferredWidthType = WidthType.FiftiethsOfPercent; right.Borders.Left.LineStyle = TableBorderLineStyle.None; right.Borders.Right.LineStyle = TableBorderLineStyle.None; right.Borders.Top.LineStyle = TableBorderLineStyle.None; right.Borders.Bottom.LineStyle = TableBorderLineStyle.None; bool exist1 = false; bool exist2 = false; if (from.WebPage != null) { if (!exist1) { range6 = doc.InsertText(left[0, 0].Range.Start, "WEB: " + from.WebPage); exist1 = true; } else { doc.InsertText(left[0, 0].Range.Start, "WEB: " + from.WebPage); } } if (to.WebPage != null) { if (!exist2) { range7 = doc.InsertText(right[0, 0].Range.Start, "WEB: " + to.WebPage); exist2 = true; } else { doc.InsertText(right[0, 0].Range.Start, "WEB: " + to.WebPage); } } if (from.Email != null) { if (!exist1) { range6 = doc.InsertText(left[0, 0].Range.Start, "Email: " + from.Email); exist1 = true; } else { doc.InsertText(left[0, 0].Range.Start, "Email: " + from.Email + "\n"); } } if (to.Email != null) { if (!exist2) { range7 = doc.InsertText(right[0, 0].Range.Start, "Email: " + to.Email); exist2 = true; } else { doc.InsertText(right[0, 0].Range.Start, "Email: " + to.Email + "\n"); } } if (from.Phone != null) { if (!exist1) { range6 = doc.InsertText(left[0, 0].Range.Start, "Telefon: " + from.Phone); exist1 = true; } else { doc.InsertText(left[0, 0].Range.Start, "Telefon: " + from.Phone + "\n"); } } if (to.Phone != null) { if (!exist2) { range7 = doc.InsertText(right[0, 0].Range.Start, "Telefon: " + to.Phone); exist2 = true; } else { doc.InsertText(right[0, 0].Range.Start, "Telefon: " + to.Phone + "\n"); } } if (from.InvoiceNumber != null) { if (!exist1) { range6 = doc.InsertText(left[0, 0].Range.Start, "Bankszámlaszám: " + from.InvoiceNumber); exist1 = true; } else { doc.InsertText(left[0, 0].Range.Start, "Bankszámlaszám: " + from.InvoiceNumber + "\n"); } } if (to.InvoiceNumber != null) { if (!exist2) { range7 = doc.InsertText(right[0, 0].Range.Start, "Bankszámlaszám: " + to.InvoiceNumber); exist2 = true; } else { doc.InsertText(right[0, 0].Range.Start, "Bankszámlaszám: " + to.InvoiceNumber + "\n"); } } if (from.RegistrationNumber != null) { if (!exist1) { range6 = doc.InsertText(left[0, 0].Range.Start, "Cégjegyzékszám: " + from.RegistrationNumber); exist1 = true; } else { doc.InsertText(left[0, 0].Range.Start, "Cégjegyzékszám: " + from.RegistrationNumber + "\n"); } } if (to.RegistrationNumber != null) { if (!exist2) { range7 = doc.InsertText(right[0, 0].Range.Start, "Cégjegyzékszám: " + to.RegistrationNumber); exist2 = true; } else { doc.InsertText(right[0, 0].Range.Start, "Cégjegyzékszám: " + to.RegistrationNumber + "\n"); } } if (!exist1) { range6 = doc.InsertText(left[0, 0].Range.Start, "Adószám: " + from.TaxNumber); exist1 = true; } else { doc.InsertText(left[0, 0].Range.Start, "Adószám: " + from.TaxNumber + "\n"); } if (to.TaxNumber != null) { if (!exist2) { range7 = doc.InsertText(right[0, 0].Range.Start, "Adószám: " + to.TaxNumber); exist2 = true; } else { doc.InsertText(right[0, 0].Range.Start, "Adószám: " + to.TaxNumber + "\n"); } } doc.InsertText(left[0, 0].Range.Start, from.Address + "\n"); if (!exist2) { range7 = doc.InsertText(right[0, 0].Range.Start, to.Address); exist2 = true; } else { doc.InsertText(right[0, 0].Range.Start, to.Address + "\n"); } doc.InsertText(left[0, 0].Range.Start, from.ZipCode + " " + from.Settlement + "\n"); doc.InsertText(right[0, 0].Range.Start, to.ZipCode + " " + to.Settlement + "\n"); DocumentRange range4 = doc.InsertText(left[0, 0].Range.Start, from.Name + "\n"); ParagraphProperties props2 = reds.Document.BeginUpdateParagraphs(range4); props2.SpacingBefore = 5; props2.SpacingAfter = 3; CharacterProperties cp4 = reds.Document.BeginUpdateCharacters(range4); cp4.Bold = true; cp4.FontSize = 14; DocumentRange range5 = doc.InsertText(right[0, 0].Range.Start, to.Name + "\n"); ParagraphProperties props3 = reds.Document.BeginUpdateParagraphs(range5); props3.SpacingBefore = 5; props3.SpacingAfter = 3; CharacterProperties cp5 = reds.Document.BeginUpdateCharacters(range5); cp5.Bold = true; cp5.FontSize = 14; ParagraphProperties props4 = reds.Document.BeginUpdateParagraphs(range6); ParagraphProperties props5 = reds.Document.BeginUpdateParagraphs(range7); props4.SpacingAfter = 5; props5.SpacingAfter = 5; doc.AppendText("\n\n"); Table table1 = doc.Tables.Create(doc.Range.End, 1, 7); table1.TableLayout = TableLayoutType.Fixed; table1.PreferredWidth = 5000; table1.PreferredWidthType = WidthType.FiftiethsOfPercent; table1.Borders.InsideVerticalBorder.LineStyle = TableBorderLineStyle.None; table1.Borders.Left.LineStyle = TableBorderLineStyle.None; table1.Borders.Right.LineStyle = TableBorderLineStyle.None; table1.Borders.Top.LineStyle = TableBorderLineStyle.None; table1.Borders.Bottom.LineStyle = TableBorderLineStyle.None; table1[0, 0].PreferredWidthType = WidthType.FiftiethsOfPercent; table1[0, 0].PreferredWidth = 1250; table1[0, 0].VerticalAlignment = TableCellVerticalAlignment.Center; table1[0, 1].PreferredWidthType = WidthType.FiftiethsOfPercent; table1[0, 1].PreferredWidth = 500; table1[0, 1].VerticalAlignment = TableCellVerticalAlignment.Center; table1[0, 2].PreferredWidthType = WidthType.FiftiethsOfPercent; table1[0, 2].PreferredWidth = 688; table1[0, 2].VerticalAlignment = TableCellVerticalAlignment.Center; table1[0, 3].PreferredWidthType = WidthType.FiftiethsOfPercent; table1[0, 3].PreferredWidth = 688; table1[0, 3].VerticalAlignment = TableCellVerticalAlignment.Center; table1[0, 4].PreferredWidthType = WidthType.FiftiethsOfPercent; table1[0, 4].PreferredWidth = 500; table1[0, 4].VerticalAlignment = TableCellVerticalAlignment.Center; table1[0, 5].PreferredWidthType = WidthType.FiftiethsOfPercent; table1[0, 5].PreferredWidth = 688; table1[0, 5].VerticalAlignment = TableCellVerticalAlignment.Center; table1[0, 6].PreferredWidthType = WidthType.FiftiethsOfPercent; table1[0, 6].PreferredWidth = 688; table1[0, 6].VerticalAlignment = TableCellVerticalAlignment.Center; DocumentRange r0 = doc.InsertText(table1[0, 0].Range.Start, "Megnevezés"); CharacterProperties c0 = reds.Document.BeginUpdateCharacters(r0); c0.Bold = true; c0.FontSize = 10; DocumentRange r1 = doc.InsertText(table1[0, 1].Range.Start, "Menny."); CharacterProperties c1 = reds.Document.BeginUpdateCharacters(r1); c1.Bold = true; c1.FontSize = 10; ParagraphProperties p1 = doc.BeginUpdateParagraphs(r1); p1.Alignment = ParagraphAlignment.Right; DocumentRange r2 = doc.InsertText(table1[0, 2].Range.Start, "Egységár"); CharacterProperties c2 = reds.Document.BeginUpdateCharacters(r2); c2.Bold = true; c2.FontSize = 10; ParagraphProperties p2 = doc.BeginUpdateParagraphs(r2); p2.Alignment = ParagraphAlignment.Right; DocumentRange r3 = doc.InsertText(table1[0, 3].Range.Start, "Nettó ár"); CharacterProperties c3 = reds.Document.BeginUpdateCharacters(r3); c3.Bold = true; c3.FontSize = 10; ParagraphProperties p3 = doc.BeginUpdateParagraphs(r3); p3.Alignment = ParagraphAlignment.Right; DocumentRange r4 = doc.InsertText(table1[0, 4].Range.Start, "ÁFA"); CharacterProperties c4 = reds.Document.BeginUpdateCharacters(r4); c4.Bold = true; c4.FontSize = 10; ParagraphProperties p4 = doc.BeginUpdateParagraphs(r4); p4.Alignment = ParagraphAlignment.Right; DocumentRange r5 = doc.InsertText(table1[0, 5].Range.Start, "Áfa érték"); CharacterProperties c5 = reds.Document.BeginUpdateCharacters(r5); c5.Bold = true; c5.FontSize = 10; ParagraphProperties p5 = doc.BeginUpdateParagraphs(r5); p5.Alignment = ParagraphAlignment.Right; DocumentRange r6 = doc.InsertText(table1[0, 6].Range.Start, "Bruttó ár"); CharacterProperties c6 = reds.Document.BeginUpdateCharacters(r6); c6.Bold = true; c6.FontSize = 10; ParagraphProperties p6 = doc.BeginUpdateParagraphs(r6); p6.Alignment = ParagraphAlignment.Right; Table table3 = doc.Tables.Create(doc.Range.End, PrintList.Count, 7); table3.TableLayout = TableLayoutType.Fixed; table3.PreferredWidth = 5000; table3.PreferredWidthType = WidthType.FiftiethsOfPercent; table3.Borders.InsideVerticalBorder.LineStyle = TableBorderLineStyle.None; table3.Borders.InsideHorizontalBorder.LineStyle = TableBorderLineStyle.None; table3.Borders.Left.LineStyle = TableBorderLineStyle.None; table3.Borders.Right.LineStyle = TableBorderLineStyle.None; table3[0, 0].PreferredWidthType = WidthType.FiftiethsOfPercent; table3[0, 0].PreferredWidth = 1250; table3[0, 1].PreferredWidthType = WidthType.FiftiethsOfPercent; table3[0, 1].PreferredWidth = 500; table3[0, 2].PreferredWidthType = WidthType.FiftiethsOfPercent; table3[0, 2].PreferredWidth = 688; table3[0, 3].PreferredWidthType = WidthType.FiftiethsOfPercent; table3[0, 3].PreferredWidth = 688; table3[0, 4].PreferredWidthType = WidthType.FiftiethsOfPercent; table3[0, 4].PreferredWidth = 500; table3[0, 5].PreferredWidthType = WidthType.FiftiethsOfPercent; table3[0, 5].PreferredWidth = 688; table3[0, 6].PreferredWidthType = WidthType.FiftiethsOfPercent; table3[0, 6].PreferredWidth = 688; List <DocumentRange> dr = new List <DocumentRange>(); List <ParagraphProperties> ppr = new List <ParagraphProperties>(); List <CharacterProperties> cpr = new List <CharacterProperties>(); for (int i = 0; i < PrintList.Count; i++) { if (i % 2 == 0) { for (int column = 0; column < 7; column++) { table3[i, column].BackgroundColor = ColorTranslator.FromHtml("#E6E6E6"); } } dr.Add(doc.InsertText(table3[i, 0].Range.Start, PrintList[i].Name)); ppr.Add(doc.BeginUpdateParagraphs(dr[dr.Count - 1])); cpr.Add(doc.BeginUpdateCharacters(dr[dr.Count - 1])); cpr[cpr.Count - 1].FontSize = 10; table3[i, 0].VerticalAlignment = TableCellVerticalAlignment.Center; dr.Add(doc.InsertText(table3[i, 1].Range.Start, PrintList[i].Quantity.ToString())); ppr.Add(doc.BeginUpdateParagraphs(dr[dr.Count - 1])); ppr[ppr.Count - 1].Alignment = ParagraphAlignment.Right; cpr.Add(doc.BeginUpdateCharacters(dr[dr.Count - 1])); cpr[cpr.Count - 1].FontSize = 10; table3[i, 1].VerticalAlignment = TableCellVerticalAlignment.Center; dr.Add(doc.InsertText(table3[i, 2].Range.Start, Grouping(PrintList[i].QuantityPrice))); ppr.Add(doc.BeginUpdateParagraphs(dr[dr.Count - 1])); ppr[ppr.Count - 1].Alignment = ParagraphAlignment.Right; cpr.Add(doc.BeginUpdateCharacters(dr[dr.Count - 1])); cpr[cpr.Count - 1].FontSize = 10; table3[i, 2].VerticalAlignment = TableCellVerticalAlignment.Center; dr.Add(doc.InsertText(table3[i, 3].Range.Start, Grouping(PrintList[i].PriceWithoutVat))); ppr.Add(doc.BeginUpdateParagraphs(dr[dr.Count - 1])); ppr[ppr.Count - 1].Alignment = ParagraphAlignment.Right; cpr.Add(doc.BeginUpdateCharacters(dr[dr.Count - 1])); cpr[cpr.Count - 1].FontSize = 10; table3[i, 3].VerticalAlignment = TableCellVerticalAlignment.Center; dr.Add(doc.InsertText(table3[i, 4].Range.Start, PrintList[i].Vat.ToString() + " %")); ppr.Add(doc.BeginUpdateParagraphs(dr[dr.Count - 1])); ppr[ppr.Count - 1].Alignment = ParagraphAlignment.Right; cpr.Add(doc.BeginUpdateCharacters(dr[dr.Count - 1])); cpr[cpr.Count - 1].FontSize = 10; table3[i, 4].VerticalAlignment = TableCellVerticalAlignment.Center; dr.Add(doc.InsertText(table3[i, 5].Range.Start, Grouping(PrintList[i].VatPrice))); ppr.Add(doc.BeginUpdateParagraphs(dr[dr.Count - 1])); ppr[ppr.Count - 1].Alignment = ParagraphAlignment.Right; cpr.Add(doc.BeginUpdateCharacters(dr[dr.Count - 1])); cpr[cpr.Count - 1].FontSize = 10; table3[i, 5].VerticalAlignment = TableCellVerticalAlignment.Center; dr.Add(doc.InsertText(table3[i, 6].Range.Start, Grouping(PrintList[i].PriceWithVat))); ppr.Add(doc.BeginUpdateParagraphs(dr[dr.Count - 1])); ppr[ppr.Count - 1].Alignment = ParagraphAlignment.Right; cpr.Add(doc.BeginUpdateCharacters(dr[dr.Count - 1])); cpr[cpr.Count - 1].FontSize = 10; table3[i, 6].VerticalAlignment = TableCellVerticalAlignment.Center; dr.Clear(); ppr.Clear(); cpr.Clear(); } Table table4 = doc.Tables.Create(doc.Range.End, 1, 7); table4.TableLayout = TableLayoutType.Fixed; table4.PreferredWidth = 5000; table4.PreferredWidthType = WidthType.FiftiethsOfPercent; table4.Borders.InsideVerticalBorder.LineStyle = TableBorderLineStyle.None; table4.Borders.Left.LineStyle = TableBorderLineStyle.None; table4.Borders.Right.LineStyle = TableBorderLineStyle.None; table4.Borders.Bottom.LineStyle = TableBorderLineStyle.None; table4.Borders.Top.LineStyle = TableBorderLineStyle.None; table4[0, 0].PreferredWidthType = WidthType.FiftiethsOfPercent; table4[0, 0].PreferredWidth = 1250; table4[0, 0].VerticalAlignment = TableCellVerticalAlignment.Bottom; table4[0, 1].PreferredWidthType = WidthType.FiftiethsOfPercent; table4[0, 1].PreferredWidth = 500; table4[0, 1].VerticalAlignment = TableCellVerticalAlignment.Bottom; table4[0, 2].PreferredWidthType = WidthType.FiftiethsOfPercent; table4[0, 2].PreferredWidth = 688; table4[0, 2].VerticalAlignment = TableCellVerticalAlignment.Bottom; table4[0, 3].PreferredWidthType = WidthType.FiftiethsOfPercent; table4[0, 3].PreferredWidth = 688; table4[0, 3].VerticalAlignment = TableCellVerticalAlignment.Bottom; table4[0, 4].PreferredWidthType = WidthType.FiftiethsOfPercent; table4[0, 4].PreferredWidth = 500; table4[0, 4].VerticalAlignment = TableCellVerticalAlignment.Bottom; table4[0, 5].PreferredWidthType = WidthType.FiftiethsOfPercent; table4[0, 5].PreferredWidth = 688; table4[0, 5].VerticalAlignment = TableCellVerticalAlignment.Bottom; table4[0, 6].PreferredWidthType = WidthType.FiftiethsOfPercent; table4[0, 6].PreferredWidth = 688; table4[0, 6].VerticalAlignment = TableCellVerticalAlignment.Bottom; DocumentRange rq0 = doc.InsertText(table4[0, 0].Range.Start, "Összesen:"); CharacterProperties cq0 = reds.Document.BeginUpdateCharacters(rq0); cq0.Bold = true; cq0.FontSize = 10; DocumentRange rq3 = doc.InsertText(table4[0, 3].Range.Start, Grouping(PriceWithoutVat)); CharacterProperties cq3 = reds.Document.BeginUpdateCharacters(rq3); cq3.Bold = true; cq3.FontSize = 10; ParagraphProperties pq3 = doc.BeginUpdateParagraphs(rq3); pq3.Alignment = ParagraphAlignment.Right; pq3.SpacingBefore = 4; DocumentRange rq5 = doc.InsertText(table4[0, 5].Range.Start, Grouping(Vat)); CharacterProperties cq5 = reds.Document.BeginUpdateCharacters(rq5); cq5.Bold = true; cq5.FontSize = 10; ParagraphProperties pq5 = doc.BeginUpdateParagraphs(rq5); pq5.Alignment = ParagraphAlignment.Right; DocumentRange rq6 = doc.InsertText(table4[0, 6].Range.Start, Grouping(PriceWithVat)); CharacterProperties cq6 = reds.Document.BeginUpdateCharacters(rq6); cq6.Bold = true; cq6.FontSize = 10; ParagraphProperties pq6 = doc.BeginUpdateParagraphs(rq6); pq6.Alignment = ParagraphAlignment.Right; doc.AppendText("\n\n"); DocumentRange last = doc.AppendText("Fizetendő: " + Grouping(PriceWithVat) + " Ft"); CharacterProperties lastcp = doc.BeginUpdateCharacters(last); lastcp.Bold = true; lastcp.FontSize = 16; ParagraphProperties lastpp = doc.BeginUpdateParagraphs(last); lastpp.Alignment = ParagraphAlignment.Right; using (MemoryStream ms = new MemoryStream()) { reds.ExportToPdf(ms); return(ms); } }