Beispiel #1
0
        public DocModelProcessor()
        {
            license = new License();
            DocsPaDB.Query_DocsPAWS.ClientSideModelProcessor csmp = new DocsPaDB.Query_DocsPAWS.ClientSideModelProcessor();

            byte[] licenseContent = csmp.GetLicense("ASPOSE");
            if (licenseContent != null)
            {
                System.IO.MemoryStream licenseStream = new System.IO.MemoryStream(licenseContent, 0, licenseContent.Length);
                license.SetLicense(licenseStream);
                licenseStream.Close();
            }
        }
Beispiel #2
0
        public PdfModelProcessor(byte[] pdfContent)
        {
            license = new License();
            DocsPaDB.Query_DocsPAWS.ClientSideModelProcessor csmp = new DocsPaDB.Query_DocsPAWS.ClientSideModelProcessor();

            byte[] licenseContent = csmp.GetLicense("ASPOSE");
            if (licenseContent != null)
            {
                System.IO.MemoryStream licenseStream = new System.IO.MemoryStream(licenseContent, 0, licenseContent.Length);
                license.SetLicense(licenseStream);
                licenseStream.Close();
            }

            MemoryStream ms = new MemoryStream(pdfContent);

            form = new Form();
            form.BindPdf(ms);
        }
Beispiel #3
0
        public byte[] GetProcessedTemplate(DocsPaVO.utente.InfoUtente infoUtente, DocsPaVO.documento.SchedaDocumento sd)
        {
            byte[] content = null;
            System.IO.MemoryStream stream = new System.IO.MemoryStream();

            // Percorso modello
            string pathModel = sd.template.PATH_MODELLO_1;

            try
            {
                //System.IO.FileStream licenseStream = new System.IO.FileStream("C:\\Temp\\Aspose.total.xml", System.IO.FileMode.Open, System.IO.FileAccess.Read);

                // Caricamento licenza
                DocsPaDB.Query_DocsPAWS.ClientSideModelProcessor csmp = new DocsPaDB.Query_DocsPAWS.ClientSideModelProcessor();

                Aspose.Slides.License lic = new License();
                byte[] licenseContent     = csmp.GetLicense("ASPOSE");
                if (licenseContent != null)
                {
                    System.IO.MemoryStream licenseStream = new System.IO.MemoryStream(licenseContent, 0, licenseContent.Length);
                    lic.SetLicense(licenseStream);
                    licenseStream.Close();
                }

                DocsPaVO.Modelli.ModelKeyValuePair[] commonFields = this.GetModelKeyValuePairs(infoUtente, sd);

                // Lettura modello con Aspose
                using (Presentation ppt = new Presentation(pathModel))
                {
                    // 1 - Analisi master
                    foreach (LayoutSlide layoutSlide in ppt.LayoutSlides)
                    {
                        foreach (IShape shape in layoutSlide.Shapes)
                        {
                            if (shape is Aspose.Slides.AutoShape)
                            {
                                if (((IAutoShape)shape).TextFrame != null)
                                {
                                    string text = ((IAutoShape)shape).TextFrame.Text;
                                    if (!string.IsNullOrEmpty(text))
                                    {
                                        this.SearchAndReplaceFields(ref text, commonFields);
                                        ((IAutoShape)shape).TextFrame.Text = text;
                                    }
                                }
                            }
                        }
                    }

                    // Lettura caselle di testo
                    ITextFrame[] textFrames = Aspose.Slides.Util.SlideUtil.GetAllTextFrames(ppt, true);

                    foreach (ITextFrame tf in textFrames)
                    {
                        foreach (Paragraph par in tf.Paragraphs)
                        {
                            string text = par.Text;
                            if (!string.IsNullOrEmpty(text) && text.Contains("#"))
                            {
                                this.SearchAndReplaceFields(ref text, commonFields);
                                par.Text = text;
                            }
                            #region OLD CODE
                            //foreach (Portion port in par.Portions)
                            //{
                            //    string text = port.Text;
                            //    if (!string.IsNullOrEmpty(text) && text.Contains("#"))
                            //    {
                            //        this.SearchAndReplaceFields(ref text, commonFields);
                            //        port.Text = text;
                            //    }
                            //}
                            #endregion
                        }
                    }

                    #region OLD CODE
                    //Lettura slide
                    //foreach (ISlide slide in ppt.Slides)
                    //{
                    //    // Ciclo sulle forme della slide
                    //    foreach (IShape shape in slide.Shapes)
                    //    {
                    //        // Analisi testo
                    //        if (((IAutoShape)shape).TextFrame != null)
                    //        {
                    //            string text = ((IAutoShape)shape).TextFrame.Text;
                    //            if (!string.IsNullOrEmpty(text))
                    //            {
                    //                this.SearchAndReplaceFields(ref text, commonFields);
                    //                ((IAutoShape)shape).TextFrame.Text = text;
                    //            }
                    //        }
                    //    }
                    //}
                    #endregion

                    // Salvataggio del documento
                    Aspose.Slides.Export.SaveFormat frm = new Aspose.Slides.Export.SaveFormat();
                    switch (sd.template.PATH_MODELLO_1_EXT.ToUpper())
                    {
                    case "PPT":
                    default:
                        frm = Aspose.Slides.Export.SaveFormat.Ppt;
                        break;

                    case "PPTX":
                        frm = Aspose.Slides.Export.SaveFormat.Pptx;
                        break;

                    case "PPSX":
                        frm = Aspose.Slides.Export.SaveFormat.Ppsx;
                        break;

                    case "ODP":
                        frm = Aspose.Slides.Export.SaveFormat.Odp;
                        break;
                    }

                    ppt.Save(stream, Aspose.Slides.Export.SaveFormat.Pptx);
                }

                content = stream.ToArray();
            }
            catch (Exception ex)
            {
                logger.DebugFormat("{0}\r\n{1}", ex.Message, ex.StackTrace);
                content = null;
            }
            return(content);
        }