Exemple #1
0
        private void GenerarPDF_Temporal(tblDocumentoContenido contenido, string TipoDocumento, int _orden)
        {
            RichEditDocumentServer _reServer = new RichEditDocumentServer();
            MemoryStream           _ms       = new MemoryStream();
            string _tempFileName             = string.Format("tmp{0}_{1}_{2}_{3}_{4}.pdf", TipoDocumento,
                                                             contenido.IdEmpresa.ToString("000"),
                                                             _orden.ToString("00"),
                                                             contenido.IdDocumento.ToString("000"),
                                                             contenido.IdSubModulo.ToString("00000000"));

            string _tempFile = string.Format("{0}/{1}", _tempFilePath, _tempFileName);

            if (File.Exists(_tempFile))
            {
                File.Delete(_tempFile);
            }

            FileStream   _fileStream = new FileStream(_tempFile, FileMode.Create);
            MemoryStream _msData     = new MemoryStream(contenido.ContenidoBin.ToArray());

            _reServer.Document.LoadDocument(_msData, DevExpress.XtraRichEdit.DocumentFormat.OpenXml);
            _reServer.ExportToPdf(_ms);
            _reServer.EndUpdate();

            _ms.WriteTo(_fileStream);
            _ms.Close();
            _msData.Close();
            _fileStream.Close();
        }
Exemple #2
0
        public static bool ConvertImageToPdf(Image image, string naziv, RevizijaAPI.Models.Database.dms_file folderOstalo, int id_operater)
        {
            using (RichEditDocumentServer server = new RichEditDocumentServer())
            {
                try
                {
                    //Insert an image
                    DocumentImage docImage = server.Document.Images.Append(DocumentImageSource.FromImage(image));

                    //Adjust the page width and height to the image's size
                    server.Document.Sections[0].Page.Width  = docImage.Size.Width + server.Document.Sections[0].Margins.Right + server.Document.Sections[0].Margins.Left;
                    server.Document.Sections[0].Page.Height = docImage.Size.Height + server.Document.Sections[0].Margins.Top + server.Document.Sections[0].Margins.Bottom;

                    var result = Upload2DMS(folderOstalo, naziv, image, id_operater);
                    if (result.result)
                    {
                        using (FileStream fs = new FileStream(System.Web.Hosting.HostingEnvironment.MapPath($"~\\Uploads\\{result.guid}"), FileMode.OpenOrCreate))
                        {
                            server.ExportToPdf(fs);
                        }
                        return(true);
                    }
                    else
                    {
                        return(false);
                    }
                }
                catch (Exception ex)
                {
                    return(false);
                }
            }
        }
Exemple #3
0
        private void button1_Click(object sender, EventArgs e)
        {
            captureScreen();
            using (RichEditDocumentServer server = new RichEditDocumentServer())
            {
                DevExpress.XtraRichEdit.API.Native.DocumentImage docImage = server.Document.Images.Append(DevExpress.XtraRichEdit.API.Native.DocumentImageSource.FromFile(@"C:\Temp\test.png"));
                server.Document.Sections[0].Page.Width  = docImage.Size.Width + server.Document.Sections[0].Margins.Right + server.Document.Sections[0].Margins.Left;
                server.Document.Sections[0].Page.Height = docImage.Size.Height + server.Document.Sections[0].Margins.Top + server.Document.Sections[0].Margins.Bottom;

                // Displays a SaveFileDialog so the user can save the PDF
                SaveFileDialog saveFileDialog1 = new SaveFileDialog();
                saveFileDialog1.Filter = "PDF File|*.pdf";
                saveFileDialog1.Title  = "Save PDF";
                saveFileDialog1.ShowDialog();

                // If the file name is not an empty string open it for saving.
                if (saveFileDialog1.FileName != "")
                {
                    // Saves the Image via a FileStream created by the OpenFile method.
                    System.IO.FileStream fs = (System.IO.FileStream)saveFileDialog1.OpenFile();
                    server.ExportToPdf(fs);
                    MessageBox.Show("File Saved Successfully !!!");
                }
            }
        }
        static void Main(string[] args)
        {
            using (RichEditDocumentServer wordProcessor = new RichEditDocumentServer())
            {
                //Register the created service implementation
                wordProcessor.LoadDocument("Multimodal.docx");

                //Load embedded dictionaries
                var openOfficePatternStream = Assembly.GetExecutingAssembly().GetManifestResourceStream("word_processing_hyphenation.hyphen.dic");
                var customDictionaryStream  = Assembly.GetExecutingAssembly().GetManifestResourceStream("word_processing_hyphenation.hyphen_exc.dic");

                //Create dictionary objects
                OpenOfficeHyphenationDictionary hyphenationDictionary = new OpenOfficeHyphenationDictionary(openOfficePatternStream, new System.Globalization.CultureInfo("EN-US"));
                CustomHyphenationDictionary     exceptionsDictionary  = new CustomHyphenationDictionary(customDictionaryStream, new System.Globalization.CultureInfo("EN-US"));

                //Add them to the word processor's collection
                wordProcessor.HyphenationDictionaries.Add(hyphenationDictionary);
                wordProcessor.HyphenationDictionaries.Add(exceptionsDictionary);

                //Specify hyphenation settings
                wordProcessor.Document.Hyphenation   = true;
                wordProcessor.Document.HyphenateCaps = true;

                //Export the result to the PDF format
                wordProcessor.ExportToPdf("Result.pdf");
            }
            //Open the result
            Process.Start("Result.pdf");
        }
        private void barButtonItem1_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e)
        {
            int count = ((List <Employee>)richEditControl1.Options.MailMerge.DataSource).Count;

            SaveFileDialog saveFileDialog1 = new SaveFileDialog();

            saveFileDialog1.Filter           = "PDF files (*.pdf)|*.pdf|All files (*.*)|*.*";
            saveFileDialog1.FilterIndex      = 1;
            saveFileDialog1.RestoreDirectory = true;

            if (saveFileDialog1.ShowDialog() == DialogResult.OK)
            {
                using (RichEditDocumentServer docServer = new RichEditDocumentServer()) {
                    MailMergeOptions options = richEditControl1.CreateMailMergeOptions();

                    for (int i = 0; i < count; i++)
                    {
                        string filename = string.Format("{0}{1}.pdf", saveFileDialog1.FileName, (i + 1).ToString());
                        options.FirstRecordIndex = options.LastRecordIndex = i;

                        using (FileStream fs = new FileStream(filename, FileMode.Create, System.IO.FileAccess.Write)) {
                            richEditControl1.MailMerge(options, docServer.Document);
                            docServer.ExportToPdf(fs);
                        }
                    }
                }
            }
        }
Exemple #6
0
        /// <summary>
        /// Von dem Doc-Dokument wird die erste Seite in tiff konvertiert und gespeichert.
        /// die funktion liefert den Path zu der neue Datei zurück.
        /// </summary>
        public string GetFirstPageAsImageFromDocument(DocumentParam param)
        {
            try
            {
                string   fileName = string.Empty;
                FileInfo fileInfo = new FileInfo(param.FilePath);

                if (fileInfo.Exists == false)
                {
                    return(fileName);
                }

                string pathFolder = Path.GetTempPath();

                FilesFunctions.DeleteFilesInFolder(pathFolder, Tiff);
                string tempName = FilesFunctions.GetRandomName(pathFolder, fileInfo, true, Pdf);
                using (RichEditDocumentServer richServer = new RichEditDocumentServer())
                {
                    richServer.LoadDocument(param.FilePath);

                    //Specify export options:
                    PdfExportOptions options = new PdfExportOptions
                    {
                        Compressed   = false,
                        ImageQuality = PdfJpegImageQuality.Highest
                    };
                    //Export the document to the stream:

                    using (FileStream pdfFileStream = new FileStream(tempName, FileMode.Create))
                    {
                        richServer.ExportToPdf(pdfFileStream, options);
                    }
                }

                var pdf = new PdfTiffConverter();

                var parammeter = new DocumentParam
                {
                    Resolution   = param.Resolution,
                    Colour       = param.Colour,
                    Compression  = param.Compression,
                    Quality      = param.Quality,
                    KeepOriginal = param.KeepOriginal,
                    ConTyp       = param.ConTyp,
                    Doctyp       = param.Doctyp,
                    FilePath     = tempName
                };

                fileName = pdf.GetFirstPageAsImageFromDocument(parammeter);


                return(fileName);
            }
            catch (Exception ex)
            {
                FileLogger.FileLogger.Instance.WriteExeption(ex);
                return(string.Empty);
            }
        }
Exemple #7
0
 static void ConvertHTMLtoPDF(RichEditDocumentServer wordProcessor)
 {
     #region #ConvertHTMLtoPDF
     wordProcessor.LoadDocument("Documents\\TextWithImages.htm");
     wordProcessor.ExportToPdf("Document_PDF.pdf");
     System.Diagnostics.Process.Start("Document_PDF.pdf");
     #endregion #ConvertHTMLtoPDF
 }
Exemple #8
0
    private Stream ConvertToPdf(Stream stream, string fileName)
    {
        RichEditDocumentServer server = new RichEditDocumentServer();

        server.LoadDocument(stream, FileExtensionHelper.GetDocumentFormat(fileName));
        MemoryStream memoryStream = new MemoryStream();

        server.ExportToPdf(memoryStream);
        return(memoryStream);
    }
        // Create New Invoice
        public void InvoiceCreate(string OrderID)
        {
            MemoryStream rtfStream = new MemoryStream();
            MemoryStream pdfStream = new MemoryStream();

            RichEditDocumentServer docServer = new RichEditDocumentServer();

            docServer.Document.LoadDocument(Server.MapPath("~/App_Data/WorkDirectory/Invoice.rtf"), DocumentFormat.Rtf);

            // Rtf file
            Document rtf = docServer.Document;

            // Customer's Data
            var arrayCustomer = SelectOrder(OrderID);

            var arrayOrderDetail = SelectOrderDetails(OrderID);

            // Replace Header String
            SubDocument header = docServer.Document.Sections[0].BeginUpdateHeader();

            header.ReplaceAll("#invoiceid", arrayCustomer[7].ToString(), SearchOptions.WholeWord);

            // Replace Fields
            rtf.ReplaceAll("#orderid", arrayCustomer[0].ToString(), SearchOptions.WholeWord);
            rtf.ReplaceAll("#customerid", arrayCustomer[1].ToString(), SearchOptions.WholeWord);
            rtf.ReplaceAll("#date", Convert.ToDateTime(arrayCustomer[2]).ToShortDateString(), SearchOptions.WholeWord);
            rtf.ReplaceAll("#customer", arrayCustomer[3].ToString(), SearchOptions.WholeWord);
            rtf.ReplaceAll("#address", arrayCustomer[4].ToString().Trim(), SearchOptions.WholeWord);
            rtf.ReplaceAll("#email", arrayCustomer[5].ToString().Trim(), SearchOptions.WholeWord);
            rtf.ReplaceAll("#phone", arrayCustomer[6].ToString(), SearchOptions.WholeWord);

            docServer.SaveDocument(rtfStream, DocumentFormat.Rtf);
            docServer.ExportToPdf(pdfStream);

            using (SqlConnection con = new SqlConnection(conStr))
            {
                using (SqlCommand cmd = new SqlCommand())
                {
                    cmd.CommandType = CommandType.Text;
                    cmd.Connection  = con;

                    cmd.CommandText = @"insert into Invoices (OrderID, InvoiceRtf, InvoicePdf) 
                                        values (@OrderID, @InvoiceRtf, @InvoicePdf)";

                    cmd.Parameters.AddWithValue("@OrderID", OrderID);
                    cmd.Parameters.AddWithValue("@InvoiceRtf", SqlDbType.VarBinary).Value = rtfStream.ToArray();
                    cmd.Parameters.AddWithValue("@InvoicePdf", SqlDbType.VarBinary).Value = pdfStream.ToArray();

                    con.Open();
                    cmd.ExecuteNonQuery();
                    con.Close();
                }
            }
        }
 static void ConvertHTMLtoPDF(RichEditDocumentServer server)
 {
     #region #ConvertHTMLtoPDF
     server.LoadDocument("Documents\\TextWithImages.htm");
     using (FileStream pdfFileStream = new FileStream("Document_PDF.pdf", FileMode.Create))
     {
         server.ExportToPdf(pdfFileStream);
     }
     System.Diagnostics.Process.Start("Document_PDF.pdf");
     #endregion #ConvertHTMLtoPDF
 }
    private void WriteToResponse(string text)
    {
        using (RichEditDocumentServer server = new RichEditDocumentServer()) {
            using (MemoryStream stream = new MemoryStream()) {
                server.HtmlText = text;
                server.ExportToPdf(stream);

                stream.WriteTo(Response.OutputStream);

                Page.Response.ContentType = "application/pdf";
                Page.Response.AddHeader("Content-Disposition", "attachment; filename=dataview.pdf");
                Page.Response.End();
            }
        }
    }
Exemple #12
0
        string PrintToPDF(RichEditDocumentServer server, string filePath)
        {
            try {
                server.LoadDocument(filePath);
            }
            catch (Exception ex) {
                server.CreateNewDocument();
                return(String.Format("{0:T} Error:{1} -> {2}", DateTime.Now, ex.Message, filePath) + Environment.NewLine);
            }
            string     outFileName = Path.ChangeExtension(filePath, "pdf");
            FileStream fsOut       = File.Open(outFileName, FileMode.Create);

            server.ExportToPdf(fsOut);
            fsOut.Close();
            return(String.Format("{0:T} Done-> {1}", DateTime.Now, outFileName) + Environment.NewLine);
        }
Exemple #13
0
        public IActionResult Get(string htmlText)
        {
            var server = new RichEditDocumentServer();

            server.LoadDocument(@"C:\Users\honay\Desktop\Doc1.rtf", DocumentFormat.Rtf);
            var bm = server.Document.Bookmarks["mainContent"];

            server.Document.InsertHtmlText(bm.Range.Start, htmlText);

            var stream = new MemoryStream();

            server.ExportToPdf(stream);
            stream.Position = 0;

            Response.Headers.Add("Content-Disposition", "inline; filename*=result.pdf");
            return(new FileStreamResult(stream, "application/pdf"));
        }
Exemple #14
0
        static void Main(string[] args)
        {
            RichEditDocumentServer server = new RichEditDocumentServer();
            // Create an instance of the class implementing the IPdfLinkUpdater interface.
            LinkUpdater linkUpdater = new LinkUpdater();

            server.AddService(typeof(ILinkUpdater), linkUpdater);
            RegisterAnchor(server.Document, linkUpdater, "1.html");
            server.Document.AppendText(new string(Characters.PageBreak, 1));
            RegisterAnchor(server.Document, linkUpdater, "2.html");
            // Export the document to PDF and open the resultant file.
            string resultPath = "..\\..\\result.pdf";

            using (Stream stream = File.Create(resultPath))
                server.ExportToPdf(stream);
            Process.Start(Path.GetFullPath(resultPath));
        }
 static void ExportToPDF(RichEditDocumentServer server)
 {
     #region #ExportToPDF
     server.LoadDocument("Documents\\MovieRentals.docx", DocumentFormat.OpenXml);
     //Specify export options:
     PdfExportOptions options = new PdfExportOptions();
     options.DocumentOptions.Author = "Mark Jones";
     options.Compressed             = false;
     options.ImageQuality           = PdfJpegImageQuality.Highest;
     //Export the document to the stream:
     using (FileStream pdfFileStream = new FileStream("Document_PDF.pdf", FileMode.Create))
     {
         server.ExportToPdf(pdfFileStream, options);
     }
     System.Diagnostics.Process.Start("Document_PDF.pdf");
     #endregion #ExportToPDF
 }
Exemple #16
0
        public void ConvertDocumentToPdf(string plik, string outputFile)
        {
            var server = new RichEditDocumentServer();

            server.LoadDocument(plik, DocumentFormat.OpenDocument);
            //Specify export options:
            PdfExportOptions options = new PdfExportOptions();

            options.DocumentOptions.Author = "Mediqus";
            options.Compressed             = false;
            options.ImageQuality           = PdfJpegImageQuality.Highest;
            //Export the document to the stream:


            using (FileStream pdfFileStream = new FileStream(outputFile, FileMode.Create))
            {
                server.ExportToPdf(pdfFileStream, options);
            }
        }
Exemple #17
0
        private void PrintToPDF(string filePath)
        {
            string displayText;

            try {
                server.LoadDocument(filePath);
            }
            catch (Exception ex) {
                server.CreateNewDocument();
                displayText    = String.Format("{0:T} Error:{1} -> {2}", DateTime.Now, ex.Message, filePath) + Environment.NewLine;
                textBox2.Text += displayText;
                return;
            }
            string     outFileName = Path.ChangeExtension(filePath, "pdf");
            FileStream fsOut       = File.Open(outFileName, FileMode.Create);

            server.ExportToPdf(fsOut);
            fsOut.Close();
            displayText    = String.Format("{0:T} Done-> {1}", DateTime.Now, outFileName) + Environment.NewLine;
            textBox2.Text += displayText;
        }
Exemple #18
0
        public string GetFileDownLoadType(string path, string fileName, AttachmentTypeEnum typeOffile)
        {
            string fileDownloadName;
            var    folder            = RootConstant.Documents;
            var    filePath          = Path.Combine(_hostingEnvironment.WebRootPath, folder);
            var    ServerRootAddress = RootConstant.ServerRootAddress;

            filePath = Path.GetFullPath(filePath);
            var filePDF = Path.Combine(filePath, fileName + ".pdf");
            RichEditDocumentServer server = new RichEditDocumentServer();

            server.LoadDocument(path);
            server.ExportToPdf(filePDF);
            if (typeOffile == AttachmentTypeEnum.DOCX)
            {
                fileDownloadName = $"{ServerRootAddress}{folder}{fileName}.docx";
            }
            else
            {
                fileDownloadName = $"{ServerRootAddress}{folder}{fileName}.pdf";
            }
            return(fileDownloadName);
        }
Exemple #19
0
        private void GenerarPDF_Temporal(byte[] ContenidoBin, string _tempFileName)
        {
            RichEditDocumentServer _reServer = new RichEditDocumentServer();
            MemoryStream           _ms       = new MemoryStream();

            string _tempFile = string.Format("{0}/{1}", _tempFilePath, _tempFileName);

            if (File.Exists(_tempFile))
            {
                File.Delete(_tempFile);
            }

            FileStream   _fileStream = new FileStream(_tempFile, FileMode.Create);
            MemoryStream _msData     = new MemoryStream(ContenidoBin.ToArray());

            _reServer.Document.LoadDocument(_msData, DevExpress.XtraRichEdit.DocumentFormat.OpenXml);
            _reServer.ExportToPdf(_ms);
            _reServer.EndUpdate();

            _ms.WriteTo(_fileStream);
            _ms.Close();
            _msData.Close();
            _fileStream.Close();
        }
Exemple #20
0
        /// <summary>
        /// Konvertiert die Doc-Datei in Tiff-Dateien.
        /// Gibt eine liste mit den Pfaden der Tiff-Dateien zurück.
        /// </summary>
        public List <string> ConvertPDFToImage(string pathFolder, bool tempPrefix, DocumentParam param)
        {
            List <string> list = new List <string>();

            try
            {
                FileInfo fileInfo = new FileInfo(param.FilePath);

                if (fileInfo.Exists == false)
                {
                    return(list);
                }

                FilesFunctions.DeleteFilesInFolder(pathFolder, Tiff);
                //string tempName = FilesFunctions.GetRandomName(pathFolder, fileInfo, tempPrefix, Pdf);

                string temp = $@"{Path.GetTempPath()}\Synios\{Path.GetFileNameWithoutExtension(fileInfo.FullName)}{Pdf}";


                using (RichEditDocumentServer richServer = new RichEditDocumentServer())
                {
                    richServer.LoadDocument(param.FilePath);

                    //Specify export options:
                    PdfExportOptions options = new PdfExportOptions
                    {
                        Compressed   = false,
                        ImageQuality = PdfJpegImageQuality.Highest
                    };
                    //Export the document to the stream:

                    using (FileStream pdfFileStream = new FileStream(temp, FileMode.Create))
                    {
                        richServer.ExportToPdf(pdfFileStream, options);
                    }
                }


                var pdf = new PdfTiffConverter();

                var parammeter = new DocumentParam
                {
                    Resolution   = param.Resolution,
                    Colour       = param.Colour,
                    Compression  = param.Compression,
                    Quality      = param.Quality,
                    KeepOriginal = param.KeepOriginal,
                    ConTyp       = param.ConTyp,
                    Doctyp       = param.Doctyp,
                    FilePath     = temp
                };

                list = pdf.ConvertPDFToImage(pathFolder, tempPrefix, parammeter);


                return(list);
            }
            catch (Exception ex)
            {
                FileLogger.FileLogger.Instance.WriteExeption(ex);
                return(list);
            }
        }
        //// POST: api/Convert
        public JsonResult <ConvertResult> Post()
        {
            string data   = Request.Content.ReadAsStringAsync().Result;
            var    client = new HttpClient();

            byte[]      byteArray   = MessagePackSerializer.ConvertFromJson($"{{ \"fileId\": \"{JObject.Parse(data)["fileId"]}\"}}");
            HttpContent httpContent = new ByteArrayContent(byteArray);

            client.DefaultRequestHeaders.Add("Authorization", Request.Headers.GetValues("Authorization")); //Crypto.Decrypt(Properties.Settings.Default.UserData, "pass"));
            var res  = client.PostAsync("https://adm.ijro.uz/api/files.download", httpContent).Result;
            var arr  = res.Content.ReadAsByteArrayAsync().Result;
            var json = MessagePackSerializer.ConvertToJson(arr);
            var file = JsonConvert.DeserializeObject <ReportAPI.Models.IjroFile>(json);

            file.Name = Path.GetFileNameWithoutExtension(file.Name) + ".pdf";
            var fileBytes = Convert.FromBase64String(file.Content);

            using (RichEditDocumentServer wordProcessor = new RichEditDocumentServer())
            {
                try
                {
                    string path = HttpContext.Current.Server.MapPath("~/Files/");
                    wordProcessor.Options.Import.OpenXml.IgnoreDeletedText  = false;
                    wordProcessor.Options.Import.OpenXml.IgnoreInsertedText = false;
                    wordProcessor.LoadDocument(fileBytes, DocumentFormat.OpenXml);
                    Document document = wordProcessor.Document;
                    foreach (var field in document.Fields)
                    {
                        string fieldCode = document.GetText(field.CodeRange).Trim();
                        if (fieldCode.ToUpper().StartsWith("TOC"))
                        {
                            field.Locked = true;
                            ReadOnlyHyperlinkCollection tocLinks = document.Hyperlinks.Get(field.ResultRange);
                            foreach (Hyperlink tocLink in tocLinks)
                            {
                                CharacterProperties cp = document.BeginUpdateCharacters(tocLink.Range);
                                cp.Style = document.CharacterStyles["Default Paragraph Font"];
                                document.EndUpdateCharacters(cp);
                            }
                        }
                    }
                    document.Fields.Update();
                    foreach (Field field in document.Fields)
                    {
                        string fieldCode = document.GetText(field.CodeRange).Trim();
                        if (fieldCode.ToUpper().StartsWith("TOC"))
                        {
                            CharacterProperties cp = document.BeginUpdateCharacters(field.ResultRange);
                            cp.Style = document.CharacterStyles["Default Paragraph Font"];
                            document.EndUpdateCharacters(cp);
                        }
                    }
                    using (var ms = new MemoryStream())
                    {
                        wordProcessor.ExportToPdf(ms);
                        using (var fs = File.Open(path + "/" + file.Name, FileMode.OpenOrCreate))
                        {
                            ms.Position = 0;
                            ms.CopyTo(fs);
                        }
                        return(Json(new ConvertResult()
                        {
                            FileUrl = string.Format(@"http://{0}/api/GetFile?fileName={1}", "192.168.70.141:8080", Uri.EscapeDataString(file.Name))
                        }));
                    }
                }
                catch (Exception ex)
                {
                    return(Json(new ConvertResult()
                    {
                        FileUrl = ex.Message
                    }));
                    // Your code to handle cancellation
                }
            }
        }
        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);
            }
        }