public static void Main()
        {
            // The path to the documents directory.
            string dataDir = Path.GetFullPath("../../../Data/");
            //open document
            PdfContentEditor contentEditor = new PdfContentEditor();
            contentEditor.BindPdf(dataDir+ "input.pdf");

            //add attachment
            contentEditor.AddDocumentAttachment(dataDir+ "test.txt", "Attachment Description");

            //save updated PDF
            contentEditor.Save(dataDir+ "output.pdf");
        }
Example #2
0
        public static void Main()
        {
            // The path to the documents directory.
            string dataDir = Path.GetFullPath("../../../Data/");
            //open document
            PdfContentEditor contentEditor = new PdfContentEditor();

            contentEditor.BindPdf(dataDir + "input.pdf");

            //add attachment
            contentEditor.AddDocumentAttachment(dataDir + "test.txt", "Attachment Description");

            //save updated PDF
            contentEditor.Save(dataDir + "output.pdf");
        }
Example #3
0
        public static void Run()
        {
            // The path to the documents directory.
            string dataDir = RunExamples.GetDataDir_AsposePdfFacades_Attachments();
            //open document
            PdfContentEditor contentEditor = new PdfContentEditor();
            contentEditor.BindPdf(dataDir+ "AddAttachment.pdf");

            //add attachment
            contentEditor.AddDocumentAttachment(dataDir+ "test.txt", "Attachment Description");

            //save updated PDF
            contentEditor.Save(dataDir+ "AddAttachment_out.pdf");
            
        }
Example #4
0
        public static void Run()
        {
            // The path to the documents directory.
            string dataDir = RunExamples.GetDataDir_AsposePdfFacades_Attachments();
            //open document
            PdfContentEditor contentEditor = new PdfContentEditor();

            contentEditor.BindPdf(dataDir + "AddAttachment.pdf");

            //add attachment
            contentEditor.AddDocumentAttachment(dataDir + "test.txt", "Attachment Description");

            //save updated PDF
            contentEditor.Save(dataDir + "AddAttachment_out.pdf");
        }
        public static void Main()
        {
            // The path to the documents directory.
            string dataDir = Path.GetFullPath("../../../Data/");
            //open document
            PdfContentEditor contentEditor = new PdfContentEditor();

            contentEditor.BindPdf(dataDir + "input.pdf");

            //read file into stream (FileStream or MemoryStream)
            FileStream fileStream = new FileStream(dataDir + "test.txt", FileMode.Open);

            //add attachment
            contentEditor.AddDocumentAttachment(fileStream, "Attachment Name", "Attachment Description");

            //save updated PDF
            contentEditor.Save(dataDir + "output.pdf");
        }
Example #6
0
        public static void Run()
        {
            // The path to the documents directory.
            string dataDir = RunExamples.GetDataDir_AsposePdfFacades_Attachments();
            //open document
            PdfContentEditor contentEditor = new PdfContentEditor();

            contentEditor.BindPdf(dataDir + "AddAttachment-Stream.pdf");

            //read file into stream (FileStream or MemoryStream)
            FileStream fileStream = new FileStream(dataDir + "test.txt", FileMode.Open);

            //add attachment
            contentEditor.AddDocumentAttachment(fileStream, "Attachment Name", "Attachment Description");

            //save updated PDF
            contentEditor.Save(dataDir + "AddAttachment-Stream_out.pdf");
        }
        public static void Run()
        {
            // The path to the documents directory.
            string dataDir = RunExamples.GetDataDir_AsposePdfFacades_Attachments();
            //open document
            PdfContentEditor contentEditor = new PdfContentEditor();
            contentEditor.BindPdf(dataDir+ "AddAttachment-Stream.pdf");

            //read file into stream (FileStream or MemoryStream)
            FileStream fileStream = new FileStream(dataDir+ "test.txt", FileMode.Open);
            //add attachment
            contentEditor.AddDocumentAttachment(fileStream, "Attachment Name", "Attachment Description");

            //save updated PDF
            contentEditor.Save(dataDir+ "AddAttachment-Stream_out.pdf");
            
            
        }
Example #8
0
        public IHttpActionResult Upload()
        {
            var httpRequest = HttpContext.Current.Request;
            var fullPath    = Path.Combine(Config.Configuration.WorkingDirectory.Replace("/", "\\"), "Editor", httpRequest.Form["documentId"]);

            var postedFile = httpRequest.Files[0];

            if (postedFile == null)
            {
                return(InternalServerError(new Exception("")));
            }

            if (httpRequest.Form["Opp"].StartsWith("uploading"))
            {
                var guid       = Guid.NewGuid().ToString();
                var tempFolder = string.Format("{0}Editor\\{1}", Config.Configuration.WorkingDirectory.Replace("/", "\\"), guid);
                Directory.CreateDirectory(tempFolder);
                var filePath = Path.Combine(tempFolder, "document.pdf");
                postedFile.SaveAs(filePath);
                var model = new DocStatusModel
                {
                    d                = ImageConverter(filePath),
                    Path             = guid,
                    OriginalFileName = postedFile.FileName
                };
                return(Ok(model));
            }
            else if (httpRequest.Form["Opp"].StartsWith("appending"))
            {
                string appPages   = httpRequest.Form["pages"];
                string appRatios  = httpRequest.Form["ratios"];
                string appHeights = httpRequest.Form["heights"];
                var    filePath   = Path.Combine(fullPath, "append.pdf");
                postedFile.SaveAs(filePath);
                var model = new DocStatusModel
                {
                    d    = AppendConverter(fullPath, appPages, appRatios, appHeights),
                    Path = httpRequest.Form["documentId"]
                };
                return(Ok(model));
            }
            else if (httpRequest.Form["Opp"].StartsWith("addAttachment"))
            {
                var documentFileName = Path.Combine(fullPath, "document.pdf");

                PdfContentEditor contentEditor = new PdfContentEditor();
                contentEditor.BindPdf(documentFileName);
                contentEditor.AddDocumentAttachment(postedFile.InputStream, postedFile.FileName, "File added by Aspose.PDF Editor");
                contentEditor.Save(documentFileName);

                return(Ok(new DocStatusModel
                {
                    d = postedFile.FileName,
                    Path = httpRequest.Form["documentId"]
                }));
            }
            else
            {
                //Or just save it locally
                var filePath = Path.Combine(fullPath, postedFile.FileName);
                postedFile.SaveAs(filePath);

                var model = new DocStatusModel
                {
                    d    = postedFile.FileName,
                    Path = httpRequest.Form["documentId"]
                };
                return(Ok(model));
            }
        }