Beispiel #1
0
        public void ToPdf(AuxDocument auxDocument, string documentsFolder, ICollection <AuxDocument> convertedDocuments, Config config)
        {
            License license = new License();

            license.SetLicense(config.AsposeLicenseFile);

            AuxDocument convertedDocumentDetails = convertedDocuments.FirstOrDefault(d => d.Id == auxDocument.Id);

            if (convertedDocumentDetails != null)
            {
                auxDocument.ConversionRequired = false;
                auxDocument.ConvertedFile      = convertedDocumentDetails.ConvertedFile;
                return;
            }

            Workbook workbook = new Workbook(documentsFolder + auxDocument.SourceFile)
            {
                FileFormat = FileFormatType.Pdf
            };

            auxDocument.ConvertedFile = string.Format("excel_{0}.pdf", Guid.NewGuid());

            workbook.Save(documentsFolder + auxDocument.ConvertedFile, new PdfSaveOptions
            {
                OnePagePerSheet = config.ConvertExcelToOnePagePerSheet
            });
            convertedDocuments.Add(auxDocument);
        }
Beispiel #2
0
        public void ToPdf(AuxDocument auxDocument, string documentsFolder, ICollection <AuxDocument> convertedDocuments)
        {
            AuxDocument convertedDocumentDetails = convertedDocuments.FirstOrDefault(d => d.Id == auxDocument.Id);

            if (convertedDocumentDetails != null)
            {
                auxDocument.ConversionRequired = false;
                auxDocument.ConvertedFile      = convertedDocumentDetails.ConvertedFile;
                auxDocument.PageCount          = TotalPages.GetCount(auxDocument.ConvertedFile);
                return;
            }

            string copiedFileName = string.Format("pdf_{0}.pdf", Guid.NewGuid());

            File.Copy(documentsFolder + auxDocument.SourceFile, documentsFolder + copiedFileName);
            auxDocument.ConvertedFile = copiedFileName;
            convertedDocuments.Add(auxDocument);
        }
        public PackageService WithDocumentItems()
        {
            foreach (Section section in Package.Sections)
            {
                using (Dal dal = new Dal(Config.ConnString))
                {
                    IDataParameter[] param =
                    {
                        dal.GetParameter("@section_id", section.Id)
                    };

                    using (
                        IDataReader dr = dal.GetReader("sc_package_load_documents", param, CommandType.StoredProcedure))
                    {
                        while (dr.Read())
                        {
                            Item item = new Item();

                            item.ItemType = ItemType.AuxiliaryDocument;
                            item.Name     = dr.GetDrValue <string>(0);
                            item.Order    = dr.GetDrValue <short>(1);

                            AuxDocument auxDocument = new AuxDocument();
                            auxDocument.Id                 = dr.GetDrValue <int>(2);
                            auxDocument.DocumentType       = MapDocumentType.Of(dr.GetDrValue <string>(3).Trim());
                            auxDocument.SourceFile         = dr.GetDrValue <string>(4);
                            auxDocument.ConvertedFile      = dr.GetDrValue <string>(5);
                            auxDocument.ConversionRequired = dr.GetDrValue <bool>(6);

                            item.AuxiliaryDocument = auxDocument;

                            section.Items.Add(item);
                        }
                    }
                }
            }
            return(this);
        }