コード例 #1
0
        public static void Main()
        {
            //Source directory
            string sourceDir = RunExamples.Get_SourceDirectory();

            //Output directory
            string outputDir = RunExamples.Get_OutputDirectory();

            string inputPath = sourceDir + "BookWithSomeData.xlsx";


            // Load excel file containing some data
            Workbook workbook = new Workbook(inputPath);

            // Create an instance of PdfSaveOptions and pass SaveFormat to the constructor
            Aspose.Cells.PdfSaveOptions pdfSaveOpt = new Aspose.Cells.PdfSaveOptions(Aspose.Cells.SaveFormat.Pdf);

            // Create an instance of PdfSecurityOptions
            PdfSecurityOptions securityOptions = new PdfSecurityOptions();

            // Set AccessibilityExtractContent to true
            securityOptions.AccessibilityExtractContent = false;

            // Set the securityoption in the PdfSaveOptions
            pdfSaveOpt.SecurityOptions = securityOptions;

            // Save the workbook to PDF format while passing the object of PdfSaveOptions
            workbook.Save(outputDir + "outBookWithSomeData.pdf", pdfSaveOpt);

            Console.WriteLine("ContentCopyForAccessibilityOption executed successfully.\r\n");
        }
コード例 #2
0
ファイル: PDFCevirici.cs プロジェクト: inancakcan/kalibrasyon
    public static void ExcelToPDF(string CevrilecekDosyaAdresi, string SonucDosyaAdresi)
    {
        Workbook book = new Workbook(CevrilecekDosyaAdresi);

            //Worksheet sheet = book.Worksheets[0];

            foreach (Worksheet item in book.Worksheets)
            {
                item.PageSetup.Orientation = PageOrientationType.Landscape;
            }
            Aspose.Cells.PdfSaveOptions options = new Aspose.Cells.PdfSaveOptions(Aspose.Cells.SaveFormat.Pdf);
            options.AllColumnsInOnePagePerSheet = true;
            book.Save(SonucDosyaAdresi,options);
    }
コード例 #3
0
    public static void ExcelToPDF(string CevrilecekDosyaAdresi, string SonucDosyaAdresi)
    {
        Workbook book = new Workbook(CevrilecekDosyaAdresi);

        //Worksheet sheet = book.Worksheets[0];

        foreach (Worksheet item in book.Worksheets)
        {
            item.PageSetup.Orientation = PageOrientationType.Landscape;
        }
        Aspose.Cells.PdfSaveOptions options = new Aspose.Cells.PdfSaveOptions(Aspose.Cells.SaveFormat.Pdf);
        options.AllColumnsInOnePagePerSheet = true;
        book.Save(SonucDosyaAdresi, options);
    }
コード例 #4
0
        public void ConvertXlsxToPdfWithAspose(string OpenedDocumentPath, string OpenedDocumentName)
        {
            GetDefaultPdfName(OpenedDocumentPath, OpenedDocumentName);

            if (_saveDialog.ShowDialog() == DialogResult.OK)
            {
                using (FileStream OpenedDocumentStream = new FileStream(OpenedDocumentPath + Path.DirectorySeparatorChar + OpenedDocumentName, FileMode.Open, FileAccess.Read, FileShare.ReadWrite))
                {
                    Cells.Workbook       AsposeWorkbook = new Cells.Workbook(OpenedDocumentStream);
                    Cells.PdfSaveOptions SaveOptions    = new Cells.PdfSaveOptions();
                    SaveOptions.AllColumnsInOnePagePerSheet = true;
                    _saveAsPdfPath = _saveDialog.FileName;
                    AsposeWorkbook.Save(_saveAsPdfPath, SaveOptions);
                }
            }
        }
コード例 #5
0
        public static void Main()
        {
            // ExStart:1
            //Input directory
            string sourceDir = RunExamples.Get_SourceDirectory();

            //Output directory
            string outputDir = RunExamples.Get_OutputDirectory();

            // Load excel file containing custom properties
            Workbook workbook = new Workbook(sourceDir + "sampleWithCustProps.xlsx");

            // Create an instance of PdfSaveOptions and pass SaveFormat to the constructor
            Aspose.Cells.PdfSaveOptions pdfSaveOpt = new Aspose.Cells.PdfSaveOptions(Aspose.Cells.SaveFormat.Pdf);

            // Set CustomPropertiesExport property to PdfCustomPropertiesExport.Standard
            pdfSaveOpt.CustomPropertiesExport = Aspose.Cells.Rendering.PdfCustomPropertiesExport.Standard;

            // Save the workbook to PDF format while passing the object of PdfSaveOptions
            workbook.Save(outputDir + "outSampleWithCustProps.pdf", pdfSaveOpt);

            Console.WriteLine("ExportCustomPropertiesToPDF executed successfully.");
            // ExEnd:1
        }
コード例 #6
0
        public static void Main(string[] args)
        {
            // The path to the documents directory.
            string dataDir = Aspose.Cells.Examples.Utils.GetDataDir(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType);

            // Create directory if it is not already present.
            bool IsExists = System.IO.Directory.Exists(dataDir);
            if (!IsExists)
                System.IO.Directory.CreateDirectory(dataDir);

            //Instantiate a new workbook
            Workbook workbook = new Workbook();
            //Get the cells in the first(default) worksheet
            Cells cells = workbook.Worksheets[0].Cells;
            //Get the A1 cell
            Aspose.Cells.Cell p = cells["A1"];
            //Enter a value
            p.PutValue("Preface");
            //Get the A10 cell
            Aspose.Cells.Cell A = cells["A10"];
            //Enter a value.
            A.PutValue("page1");
            //Get the H15 cell
            Aspose.Cells.Cell D = cells["H15"];
            //Enter a value
            D.PutValue("page1(H15)");
            //Add a new worksheet to the workbook
            workbook.Worksheets.Add();
            //Get the cells in the second sheet
            cells = workbook.Worksheets[1].Cells;
            //Get the B10 cell in the second sheet
            Aspose.Cells.Cell B = cells["B10"];
            //Enter a value
            B.PutValue("page2");
            //Add a new worksheet to the workbook
            workbook.Worksheets.Add();
            //Get the cells in the third sheet
            cells = workbook.Worksheets[2].Cells;
            //Get the C10 cell in the third sheet
            Aspose.Cells.Cell C = cells["C10"];
            //Enter a value
            C.PutValue("page3");

            //Create a main PDF Bookmark entry object
            Aspose.Cells.Rendering.PdfBookmarkEntry pbeRoot = new Aspose.Cells.Rendering.PdfBookmarkEntry();
            //Specify its text
            pbeRoot.Text = "Sections";
            //Set the destination cell/location
            pbeRoot.Destination = p;

            //Set its sub entry array list
            pbeRoot.SubEntry = new ArrayList();

            //Create a sub PDF Bookmark entry object
            Aspose.Cells.Rendering.PdfBookmarkEntry subPbe1 = new Aspose.Cells.Rendering.PdfBookmarkEntry();
            //Specify its text
            subPbe1.Text = "Section 1";
            //Set its destination cell
            subPbe1.Destination = A;
            //Define/Create a sub Bookmark entry object of "Section A"
            Aspose.Cells.Rendering.PdfBookmarkEntry ssubPbe = new Aspose.Cells.Rendering.PdfBookmarkEntry();
            //Specify its text
            ssubPbe.Text = "Section 1.1";
            //Set its destination
            ssubPbe.Destination = D;
            //Create/Set its sub entry array list object
            subPbe1.SubEntry = new ArrayList();
            //Add the object to "Section 1"
            subPbe1.SubEntry.Add(ssubPbe);
            //Add the object to the main PDF root object
            pbeRoot.SubEntry.Add(subPbe1);

            //Create a sub PDF Bookmark entry object
            Aspose.Cells.Rendering.PdfBookmarkEntry subPbe2 = new Aspose.Cells.Rendering.PdfBookmarkEntry();
            //Specify its text
            subPbe2.Text = "Section 2";
            //Set its destination
            subPbe2.Destination = B;
            //Add the object to the main PDF root object
            pbeRoot.SubEntry.Add(subPbe2);

            //Create a sub PDF Bookmark entry object
            Aspose.Cells.Rendering.PdfBookmarkEntry subPbe3 = new Aspose.Cells.Rendering.PdfBookmarkEntry();
            //Specify its text
            subPbe3.Text = "Section 3";
            //Set its destination
            subPbe3.Destination = C;
            //Add the object to the main PDF root object
            pbeRoot.SubEntry.Add(subPbe3);

            //Create an instance of PdfSaveOptions
            Aspose.Cells.PdfSaveOptions pdfSaveOptions = new Aspose.Cells.PdfSaveOptions();

            //Set the PDF Bookmark root object
            pdfSaveOptions.Bookmark = pbeRoot;

            //Save the pdf file
            workbook.Save(dataDir+ "PDFBookmarks_test.pdf", pdfSaveOptions);
            
            
        }
コード例 #7
0
ファイル: Program.cs プロジェクト: cglu/tlook
        static void Main(string[] args)
        {

            //            -----
            //卢:基于上述的企图,又想起了一个用户提出的需求。
            //政府机关在发布文件的时候,他们往往会把不同程序的输出,合并到一个PDF中。这我们在PDF转换中可以见到很多。于是,用户问我们能否在输出PDF的时候,连带输出其他的文件,比如 XLS。
            //当然我回答说使用其他的 PDFmerge的软件就可以实现。
            //现在想来,如果我们提供一个 PDFmerge的工具,而在这个工具中加上设置PDF的各种限制,而且是默认限制的话,这样可以去限制 or 骚扰其他公司的PDF转换了。
            //所以,我想要一个这样的工具
            //1.有个UI,可以指定多个文件,每个文件都生成一个PDF
            //2.对多个PDF,进行merge,改变顺序,删除某页
            //3.生成1个PDF, 可以设置是否加密,允许打印,复制文字
           // https://docs.aspose.com/display/pdfnet/Set+Privileges%2C+Encrypt+and+Decrypt+PDF+File pdf加密
           // https://docs.aspose.com/display/cellsnet/Secure+PDF+Documents 转换加密
           // https://docs.aspose.com/display/pdfnet/Set+Privileges+on+an+Existing+PDF+File pdf权限禁止
           // https://docs.aspose.com/display/wordsnet/Home 官方文档
           //https://docs.aspose.com/display/pdfnet/Delete+PDF+pages 删除pdf页
           //https://docs.aspose.com/display/pdfnet/Append+PDF+files 合并pdf

           //Load an exiting workbook or create from scratch
           Workbook book = new Workbook("test1.xlsx");

            // Instantiate PDFSaveOptions to manage security attributes
            Aspose.Cells.PdfSaveOptions saveOption = new Aspose.Cells.PdfSaveOptions();

            saveOption.SecurityOptions = new Aspose.Cells.Rendering.PdfSecurity.PdfSecurityOptions();
            // Set the user password
            saveOption.SecurityOptions.UserPassword = "******";

            // Set the owner password
            saveOption.SecurityOptions.OwnerPassword = "******";

            // Disable extracting content permission
            saveOption.SecurityOptions.ExtractContentPermission = false;

            // Disable print permission
            saveOption.SecurityOptions.PrintPermission = false;
            book.Save("test1.pdf", saveOption);



             Aspose.Words.Document doc = new Aspose.Words.Document("test2.docx");
            doc.Save("test2.pdf", Aspose.Words.SaveFormat.Pdf);
            using (Document document = new Document("test2.pdf"))
            {
                // Instantiate Document Privileges object
                // Apply restrictions on all privileges
                Aspose.Pdf.Facades.DocumentPrivilege documentPrivilege = Aspose.Pdf.Facades.DocumentPrivilege.ForbidAll;
                // Only allow screen reading
                documentPrivilege.AllowScreenReaders = true;

                // Encrypt the file with User and Owner password.
                // Need to set the password, so that once the user views the file with user password,
                // Only screen reading option is enabled
                document.Encrypt("user", "owner", documentPrivilege, CryptoAlgorithm.AESx128, false);
                // Save updated document
                document.Save("SetPrivileges_out.pdf");
            }



        }
コード例 #8
0
        public static void Main(string[] args)
        {
            //ExStart:1
            // The path to the documents directory.
            string dataDir = Aspose.Cells.Examples.Utils.GetDataDir(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType);

            // Create directory if it is not already present.
            bool IsExists = System.IO.Directory.Exists(dataDir);

            if (!IsExists)
            {
                System.IO.Directory.CreateDirectory(dataDir);
            }

            //Instantiate a new workbook
            Workbook workbook = new Workbook();
            //Get the cells in the first(default) worksheet
            Cells cells = workbook.Worksheets[0].Cells;

            //Get the A1 cell
            Aspose.Cells.Cell p = cells["A1"];
            //Enter a value
            p.PutValue("Preface");
            //Get the A10 cell
            Aspose.Cells.Cell A = cells["A10"];
            //Enter a value.
            A.PutValue("page1");
            //Get the H15 cell
            Aspose.Cells.Cell D = cells["H15"];
            //Enter a value
            D.PutValue("page1(H15)");
            //Add a new worksheet to the workbook
            workbook.Worksheets.Add();
            //Get the cells in the second sheet
            cells = workbook.Worksheets[1].Cells;
            //Get the B10 cell in the second sheet
            Aspose.Cells.Cell B = cells["B10"];
            //Enter a value
            B.PutValue("page2");
            //Add a new worksheet to the workbook
            workbook.Worksheets.Add();
            //Get the cells in the third sheet
            cells = workbook.Worksheets[2].Cells;
            //Get the C10 cell in the third sheet
            Aspose.Cells.Cell C = cells["C10"];
            //Enter a value
            C.PutValue("page3");

            //Create a main PDF Bookmark entry object
            Aspose.Cells.Rendering.PdfBookmarkEntry pbeRoot = new Aspose.Cells.Rendering.PdfBookmarkEntry();
            //Specify its text
            pbeRoot.Text = "Sections";
            //Set the destination cell/location
            pbeRoot.Destination = p;

            //Set its sub entry array list
            pbeRoot.SubEntry = new ArrayList();

            //Create a sub PDF Bookmark entry object
            Aspose.Cells.Rendering.PdfBookmarkEntry subPbe1 = new Aspose.Cells.Rendering.PdfBookmarkEntry();
            //Specify its text
            subPbe1.Text = "Section 1";
            //Set its destination cell
            subPbe1.Destination = A;
            //Define/Create a sub Bookmark entry object of "Section A"
            Aspose.Cells.Rendering.PdfBookmarkEntry ssubPbe = new Aspose.Cells.Rendering.PdfBookmarkEntry();
            //Specify its text
            ssubPbe.Text = "Section 1.1";
            //Set its destination
            ssubPbe.Destination = D;
            //Create/Set its sub entry array list object
            subPbe1.SubEntry = new ArrayList();
            //Add the object to "Section 1"
            subPbe1.SubEntry.Add(ssubPbe);
            //Add the object to the main PDF root object
            pbeRoot.SubEntry.Add(subPbe1);

            //Create a sub PDF Bookmark entry object
            Aspose.Cells.Rendering.PdfBookmarkEntry subPbe2 = new Aspose.Cells.Rendering.PdfBookmarkEntry();
            //Specify its text
            subPbe2.Text = "Section 2";
            //Set its destination
            subPbe2.Destination = B;
            //Add the object to the main PDF root object
            pbeRoot.SubEntry.Add(subPbe2);

            //Create a sub PDF Bookmark entry object
            Aspose.Cells.Rendering.PdfBookmarkEntry subPbe3 = new Aspose.Cells.Rendering.PdfBookmarkEntry();
            //Specify its text
            subPbe3.Text = "Section 3";
            //Set its destination
            subPbe3.Destination = C;
            //Add the object to the main PDF root object
            pbeRoot.SubEntry.Add(subPbe3);

            //Create an instance of PdfSaveOptions
            Aspose.Cells.PdfSaveOptions pdfSaveOptions = new Aspose.Cells.PdfSaveOptions();

            //Set the PDF Bookmark root object
            pdfSaveOptions.Bookmark = pbeRoot;

            //Save the pdf file
            workbook.Save(dataDir + "PDFBookmarks_test.out.pdf", pdfSaveOptions);
            //ExEnd:1
        }
コード例 #9
0
        public static void Run()
        {
            //Output directory
            string outputDir = RunExamples.Get_OutputDirectory();

            // Instantiate a new workbook
            Workbook workbook = new Workbook();

            // Get the cells in the first(default) worksheet
            Cells cells = workbook.Worksheets[0].Cells;

            // Get the A1 cell
            Aspose.Cells.Cell p = cells["A1"];

            // Enter a value
            p.PutValue("Preface");

            // Get the A10 cell
            Aspose.Cells.Cell A = cells["A10"];

            // Enter a value.
            A.PutValue("page1");

            // Get the H15 cell
            Aspose.Cells.Cell D = cells["H15"];

            // Enter a value
            D.PutValue("page1(H15)");

            // Add a new worksheet to the workbook
            workbook.Worksheets.Add();

            // Get the cells in the second sheet
            cells = workbook.Worksheets[1].Cells;

            // Get the B10 cell in the second sheet
            Aspose.Cells.Cell B = cells["B10"];

            // Enter a value
            B.PutValue("page2");

            // Add a new worksheet to the workbook
            workbook.Worksheets.Add();

            // Get the cells in the third sheet
            cells = workbook.Worksheets[2].Cells;

            // Get the C10 cell in the third sheet
            Aspose.Cells.Cell C = cells["C10"];

            // Enter a value
            C.PutValue("page3");

            // Create a main PDF Bookmark entry object
            Aspose.Cells.Rendering.PdfBookmarkEntry pbeRoot = new Aspose.Cells.Rendering.PdfBookmarkEntry();

            // Specify its text
            pbeRoot.Text = "Sections";

            // Set the destination cell/location
            pbeRoot.Destination = p;

            // Set its sub entry array list
            pbeRoot.SubEntry = new ArrayList();

            // Create a sub PDF Bookmark entry object
            Aspose.Cells.Rendering.PdfBookmarkEntry subPbe1 = new Aspose.Cells.Rendering.PdfBookmarkEntry();

            // Specify its text
            subPbe1.Text = "Section 1";

            // Set its destination cell
            subPbe1.Destination = A;

            // Define/Create a sub Bookmark entry object of "Section A"
            Aspose.Cells.Rendering.PdfBookmarkEntry ssubPbe = new Aspose.Cells.Rendering.PdfBookmarkEntry();

            // Specify its text
            ssubPbe.Text = "Section 1.1";

            // Set its destination
            ssubPbe.Destination = D;

            // Create/Set its sub entry array list object
            subPbe1.SubEntry = new ArrayList();

            // Add the object to "Section 1"
            subPbe1.SubEntry.Add(ssubPbe);

            // Add the object to the main PDF root object
            pbeRoot.SubEntry.Add(subPbe1);

            // Create a sub PDF Bookmark entry object
            Aspose.Cells.Rendering.PdfBookmarkEntry subPbe2 = new Aspose.Cells.Rendering.PdfBookmarkEntry();

            // Specify its text
            subPbe2.Text = "Section 2";

            // Set its destination
            subPbe2.Destination = B;

            // Add the object to the main PDF root object
            pbeRoot.SubEntry.Add(subPbe2);

            // Create a sub PDF Bookmark entry object
            Aspose.Cells.Rendering.PdfBookmarkEntry subPbe3 = new Aspose.Cells.Rendering.PdfBookmarkEntry();

            // Specify its text
            subPbe3.Text = "Section 3";

            // Set its destination
            subPbe3.Destination = C;

            // Add the object to the main PDF root object
            pbeRoot.SubEntry.Add(subPbe3);

            // Create an instance of PdfSaveOptions
            Aspose.Cells.PdfSaveOptions pdfSaveOptions = new Aspose.Cells.PdfSaveOptions();

            // Set the PDF Bookmark root object
            pdfSaveOptions.Bookmark = pbeRoot;


            // Save the pdf file
            workbook.Save(outputDir + "outputAddPDFBookmarks.pdf", pdfSaveOptions);

            Console.WriteLine("AddPDFBookmarks executed successfully.\r\n");
        }