public void LinkCustomDocumentPropertiesToBookmark() { //ExStart //ExFor:CustomDocumentProperties.AddLinkToContent(String, String) //ExFor:DocumentProperty.IsLinkToContent //ExFor:DocumentProperty.LinkSource //ExSummary:Shows how to link a custom document property to a bookmark. Document doc = new Document(); DocumentBuilder builder = new DocumentBuilder(doc); builder.StartBookmark("MyBookmark"); builder.Write("MyBookmark contents."); builder.EndBookmark("MyBookmark"); // Add linked to content property CustomDocumentProperties customProperties = doc.CustomDocumentProperties; DocumentProperty customProperty = customProperties.AddLinkToContent("Bookmark", "MyBookmark"); // Check whether the property is linked to content Assert.AreEqual(true, customProperty.IsLinkToContent); Assert.AreEqual("MyBookmark", customProperty.LinkSource); Assert.AreEqual("MyBookmark contents.", customProperty.Value); doc.Save(ArtifactsDir + "Properties.LinkCustomDocumentPropertiesToBookmark.docx"); //ExEnd doc = new Document(ArtifactsDir + "Properties.LinkCustomDocumentPropertiesToBookmark.docx"); customProperty = doc.CustomDocumentProperties["Bookmark"]; Assert.AreEqual(true, customProperty.IsLinkToContent); Assert.AreEqual("MyBookmark", customProperty.LinkSource); Assert.AreEqual("MyBookmark contents.", customProperty.Value); }
internal void method_0(Class1089 A_0, BuiltinDocumentProperties A_1, CustomDocumentProperties A_2) { this.builtinDocumentProperties_0 = A_1; this.customDocumentProperties_0 = A_2; this.method_1(A_0); this.method_2(A_0); }
private void button1_Click(object sender, EventArgs e) { //Create Word document. Document document = new Document(); //Load the file from disk. document.LoadFromFile(@"..\..\..\..\..\..\Data\RemoveCustomPropertyFields.docx"); //Get custom document properties object. CustomDocumentProperties cdp = document.CustomDocumentProperties; //Remove all custom property fields in the document. for (int i = 0; i < cdp.Count;) { cdp.Remove(cdp[i].Name); } document.IsUpdateFields = true; String result = "Result-RemoveCustomPropertyFields.docx"; //Save to file. document.SaveToFile(result, FileFormat.Docx2013); //Launch the MS Word file. WordDocViewer(result); }
internal void method_6(BuiltinDocumentProperties A_0, CustomDocumentProperties A_1, Class1089 A_2) { int num = 0; this.builtinDocumentProperties_0 = A_0; this.customDocumentProperties_0 = A_1; Class1046 class2 = new Class1046(); this.class520_0 = new Class520(Class520.guid_0, 0x4b0); class2.method_0().Add(this.class520_0); Class1046 class3 = new Class1046(); this.class520_1 = new Class520(Class520.guid_1, 0x4b0); class3.method_0().Add(this.class520_1); this.class520_2 = new Class520(Class520.guid_2, 0x4b0); class3.method_0().Add(this.class520_2); this.int_2 = 2; this.method_7(); this.method_13(); if (this.class520_2.method_0().method_2() == 0) { class3.method_0().Remove(this.class520_2); } MemoryStream stream = new MemoryStream(); class2.method_1(stream); A_2[BookmarkStart.b("⌥笧弩䄫䌭儯䀱䴳缵嘷尹医䰽ⴿ⍁ぃ⽅❇⑉", num)] = stream; MemoryStream stream2 = new MemoryStream(); class3.method_1(stream2); A_2[BookmarkStart.b("⌥氧䔩伫嬭崯圱娳䈵欷伹儻匽ℿぁ㵃ཅ♇ⱉ⍋㱍㵏㍑⁓㽕㝗㑙", num)] = stream2; }
public void CustomAdd() { //ExStart //ExFor:CustomDocumentProperties.Add(String,String) //ExFor:CustomDocumentProperties.Add(String,Boolean) //ExFor:CustomDocumentProperties.Add(String,int) //ExFor:CustomDocumentProperties.Add(String,DateTime) //ExFor:CustomDocumentProperties.Add(String,Double) //ExId:AddCustomProperties //ExSummary:Checks if a custom property with a given name exists in a document and adds few more custom document properties. Document doc = new Document(MyDir + "Properties.doc"); CustomDocumentProperties docProperties = doc.CustomDocumentProperties; if (docProperties["Authorized"] == null) { docProperties.Add("Authorized", true); docProperties.Add("Authorized By", "John Smith"); docProperties.Add("Authorized Date", DateTime.Today); docProperties.Add("Authorized Revision", doc.BuiltInDocumentProperties.RevisionNumber); docProperties.Add("Authorized Amount", 123.45); } //ExEnd }
public void DocumentPropertyCollection() { //ExStart //ExFor:CustomDocumentProperties.Add(String,String) //ExFor:CustomDocumentProperties.Add(String,Boolean) //ExFor:CustomDocumentProperties.Add(String,int) //ExFor:CustomDocumentProperties.Add(String,DateTime) //ExFor:CustomDocumentProperties.Add(String,Double) //ExFor:Properties.DocumentPropertyCollection //ExFor:Properties.DocumentPropertyCollection.Clear //ExFor:Properties.DocumentPropertyCollection.Contains(System.String) //ExFor:Properties.DocumentPropertyCollection.GetEnumerator //ExFor:Properties.DocumentPropertyCollection.IndexOf(System.String) //ExFor:Properties.DocumentPropertyCollection.RemoveAt(System.Int32) //ExFor:Properties.DocumentPropertyCollection.Remove //ExSummary:Shows how to add custom properties to a document. // Create a blank document and get its custom property collection Document doc = new Document(); CustomDocumentProperties properties = doc.CustomDocumentProperties; // The collection will be empty by default Assert.AreEqual(0, properties.Count); // We can populate it with key/value pairs with a variety of value types properties.Add("Authorized", true); properties.Add("Authorized By", "John Doe"); properties.Add("Authorized Date", DateTime.Today); properties.Add("Authorized Revision", doc.BuiltInDocumentProperties.RevisionNumber); properties.Add("Authorized Amount", 123.45); // Custom properties are automatically sorted in alphabetic order Assert.AreEqual(1, properties.IndexOf("Authorized Amount")); Assert.AreEqual(5, properties.Count); // Enumerate and print all custom properties using (IEnumerator <DocumentProperty> enumerator = properties.GetEnumerator()) { while (enumerator.MoveNext()) { Console.WriteLine($"Name: \"{enumerator.Current.Name}\", Type: \"{enumerator.Current.Type}\", Value: \"{enumerator.Current.Value}\""); } } // We can view/edit custom properties by opening the document and looking in File > Properties > Advanced Properties > Custom doc.Save(ArtifactsDir + "Properties.DocumentPropertyCollection.docx"); // We can remove elements from the property collection by index or by name properties.RemoveAt(1); Assert.False(properties.Contains("Authorized Amount")); Assert.AreEqual(4, properties.Count); properties.Remove("Authorized Revision"); Assert.False(properties.Contains("Authorized Revision")); Assert.AreEqual(3, properties.Count); // We can also empty the entire custom property collection at once properties.Clear(); Assert.AreEqual(0, properties.Count); //ExEnd }
public void LinkCustomDocumentPropertiesToBookmark() { //ExStart //ExFor:CustomDocumentProperties.AddLinkToContent(String, String) //ExFor:DocumentProperty.IsLinkToContent //ExFor:DocumentProperty.LinkSource //ExSummary:Shows how to link a custom document property to a bookmark. Document doc = new Document(); DocumentBuilder builder = new DocumentBuilder(doc); builder.StartBookmark("MyBookmark"); builder.Write("Hello world!"); builder.EndBookmark("MyBookmark"); // Link a new custom property to a bookmark. The value of this property // will be the contents of the bookmark that it references in the "LinkSource" member. CustomDocumentProperties customProperties = doc.CustomDocumentProperties; DocumentProperty customProperty = customProperties.AddLinkToContent("Bookmark", "MyBookmark"); Assert.AreEqual(true, customProperty.IsLinkToContent); Assert.AreEqual("MyBookmark", customProperty.LinkSource); Assert.AreEqual("Hello world!", customProperty.Value); doc.Save(ArtifactsDir + "DocumentProperties.LinkCustomDocumentPropertiesToBookmark.docx"); //ExEnd doc = new Document(ArtifactsDir + "DocumentProperties.LinkCustomDocumentPropertiesToBookmark.docx"); customProperty = doc.CustomDocumentProperties["Bookmark"]; Assert.AreEqual(true, customProperty.IsLinkToContent); Assert.AreEqual("MyBookmark", customProperty.LinkSource); Assert.AreEqual("Hello world!", customProperty.Value); }
private void button1_Click(object sender, EventArgs e) { //Create a document Document document = new Document(); //Load the document from disk. document.LoadFromFile(@"..\..\..\..\..\..\Data\Sample.docx"); //Set the build-in Properties. document.BuiltinDocumentProperties.Title = "Document Demo Document"; document.BuiltinDocumentProperties.Author = "James"; document.BuiltinDocumentProperties.Company = "e-iceblue"; document.BuiltinDocumentProperties.Keywords = "Document, Property, Demo"; document.BuiltinDocumentProperties.Comments = "This document is just a demo."; //Set the custom properties. CustomDocumentProperties custom = document.CustomDocumentProperties; custom.Add("e-iceblue", true); custom.Add("Authorized By", "John Smith"); custom.Add("Authorized Date", DateTime.Today); //Save the document. document.SaveToFile("Output.docx", FileFormat.Docx); //Launch the Word file. WordDocViewer("Output.docx"); }
public void PropertyTypes() { //ExStart //ExFor:DocumentProperty.ToBool //ExFor:DocumentProperty.ToInt //ExFor:DocumentProperty.ToDouble //ExFor:DocumentProperty.ToString //ExFor:DocumentProperty.ToDateTime //ExSummary:Shows various type conversion methods of custom document properties. Document doc = new Document(); CustomDocumentProperties properties = doc.CustomDocumentProperties; DateTime authDate = DateTime.Today; properties.Add("Authorized", true); properties.Add("Authorized By", "John Doe"); properties.Add("Authorized Date", authDate); properties.Add("Authorized Revision", doc.BuiltInDocumentProperties.RevisionNumber); properties.Add("Authorized Amount", 123.45); Assert.AreEqual(true, properties["Authorized"].ToBool()); Assert.AreEqual("John Doe", properties["Authorized By"].ToString()); Assert.AreEqual(authDate, properties["Authorized Date"].ToDateTime()); Assert.AreEqual(1, properties["Authorized Revision"].ToInt()); Assert.AreEqual(123.45d, properties["Authorized Amount"].ToDouble()); //ExEnd }
public static void CustomAdd(string dataDir) { // ExStart:CustomAdd Document doc = new Document(dataDir + "Properties.doc"); CustomDocumentProperties props = doc.CustomDocumentProperties; if (props["Authorized"] == null) { props.Add("Authorized", true); props.Add("Authorized By", "John Smith"); props.Add("Authorized Date", DateTime.Today); props.Add("Authorized Revision", doc.BuiltInDocumentProperties.RevisionNumber); props.Add("Authorized Amount", 123.45); } // ExEnd:CustomAdd }
internal static bool smethod_7(CustomDocumentProperties A_0) { if (A_0 != null) { int num = 0; int count = A_0.Count; while (num < count) { DocumentProperty property = A_0[num]; if (smethod_8(property)) { return(true); } num++; } } return(false); }
public void AddCustomDocumentProperties() { //ExStart:AddCustomDocumentProperties Document doc = new Document(MyDir + "Properties.docx"); CustomDocumentProperties customDocumentProperties = doc.CustomDocumentProperties; if (customDocumentProperties["Authorized"] != null) { return; } customDocumentProperties.Add("Authorized", true); customDocumentProperties.Add("Authorized By", "John Smith"); customDocumentProperties.Add("Authorized Date", DateTime.Today); customDocumentProperties.Add("Authorized Revision", doc.BuiltInDocumentProperties.RevisionNumber); customDocumentProperties.Add("Authorized Amount", 123.45); //ExEnd:AddCustomDocumentProperties }
private static void smethod_4(CustomDocumentProperties A_0, Class398 A_1, bool A_2) { int num = 5; if (smethod_7(A_0)) { A_1.method_4(BookmarkStart.b("䐪ᜬ氮䐰䀲䄴堶吸缺刼尾㑀⹂⁄⥆㵈ᭊ㽌⁎⅐㙒❔⍖じ㹚⹜", num)); int num2 = 0; int count = A_0.Count; while (num2 < count) { DocumentProperty property = A_0[num2]; if (smethod_8(property)) { smethod_5(property, A_1, A_2); } num2++; } A_1.method_5(); } }
public static void ConfiguringLinkToContent(string dataDir) { // ExStart:ConfiguringLinkToContent Document doc = new Document(dataDir + "test.docx"); // Retrieve a list of all custom document properties from the file. CustomDocumentProperties customProperties = doc.CustomDocumentProperties; // Add linked to content property. DocumentProperty customProperty = customProperties.AddLinkToContent("PropertyName", "BookmarkName"); // Also, accessing the custom document property can be performed by using the property name. customProperty = customProperties["PropertyName"]; // Check whether the property is linked to content. bool isLinkedToContent = customProperty.IsLinkToContent; // Get the source of the property. string source = customProperty.LinkSource; // Get the value of the property. string value = customProperty.Value.ToString(); // ExEnd:ConfiguringLinkToContent }
public void ConfiguringLinkToContent() { //ExStart:ConfiguringLinkToContent Document doc = new Document(); DocumentBuilder builder = new DocumentBuilder(doc); builder.StartBookmark("MyBookmark"); builder.Writeln("Text inside a bookmark."); builder.EndBookmark("MyBookmark"); // Retrieve a list of all custom document properties from the file. CustomDocumentProperties customProperties = doc.CustomDocumentProperties; // Add linked to content property. DocumentProperty customProperty = customProperties.AddLinkToContent("Bookmark", "MyBookmark"); customProperty = customProperties["Bookmark"]; bool isLinkedToContent = customProperty.IsLinkToContent; string linkSource = customProperty.LinkSource; string customPropertyValue = customProperty.Value.ToString(); //ExEnd:ConfiguringLinkToContent }
internal static void smethod_1(Class582 A_0) { int num = 4; CustomDocumentProperties customDocumentProperties = A_0.Interface50.imethod_0().CustomDocumentProperties; Class394 class2 = A_0.imethod_1(); while (class2.method_9(BookmarkStart.b("椩夫崭䐯崱夳爵圷夹䤻匽┿ⱁぃᙅ㩇╉㱋⭍≏♑㵓㍕⭗", num))) { string name = smethod_2(class2.method_1()); string str5 = null; string str6 = null; while (class2.method_19()) { string str3 = class2.method_1(); if (str3 != null) { if (!(str3 == BookmarkStart.b("丩堫", num))) { if (str3 == BookmarkStart.b("䘩䔫䀭嬯", num)) { str5 = class2.method_3(); } } else { str6 = class2.method_3(); } } } string str4 = class2.method_21(); string str = str6; if (str != null) { if (str != BookmarkStart.b("天堫尭夯就匳", num)) { if (str != BookmarkStart.b("䰩䀫䄭儯䘱", num)) { if (str != BookmarkStart.b("䠩䌫䄭尯圱唳堵", num)) { if ((str == BookmarkStart.b("丩䴫娭唯昱崳嬵崷", num)) || (str == BookmarkStart.b("丩䴫娭唯昱崳嬵崷ᐹ䠻䐽", num))) { customDocumentProperties.Add(name, Class1041.smethod_3(str4)); } } else { customDocumentProperties.Add(name, class2.method_70(str4)); } } else { double num2 = Class1041.smethod_12(str4); if (((int)num2) == num2) { customDocumentProperties.Add(name, (int)num2); } else { customDocumentProperties.Add(name, num2); } } } else { DocumentProperty property = customDocumentProperties.Add(name, str4); if (Class567.smethod_16(str5)) { property.LinkSource = str5; } } } } }
public PropertiesResponse(Document doc) { BuiltIn = doc.BuiltInDocumentProperties; Custom = doc.CustomDocumentProperties; }
public void DocumentPropertyCollection() { //ExStart //ExFor:CustomDocumentProperties.Add(String,String) //ExFor:CustomDocumentProperties.Add(String,Boolean) //ExFor:CustomDocumentProperties.Add(String,int) //ExFor:CustomDocumentProperties.Add(String,DateTime) //ExFor:CustomDocumentProperties.Add(String,Double) //ExFor:DocumentProperty.Type //ExFor:Properties.DocumentPropertyCollection //ExFor:Properties.DocumentPropertyCollection.Clear //ExFor:Properties.DocumentPropertyCollection.Contains(System.String) //ExFor:Properties.DocumentPropertyCollection.GetEnumerator //ExFor:Properties.DocumentPropertyCollection.IndexOf(System.String) //ExFor:Properties.DocumentPropertyCollection.RemoveAt(System.Int32) //ExFor:Properties.DocumentPropertyCollection.Remove //ExFor:PropertyType //ExSummary:Shows how to work with a document's custom properties. Document doc = new Document(); CustomDocumentProperties properties = doc.CustomDocumentProperties; Assert.AreEqual(0, properties.Count); // Custom document properties are key-value pairs that we can add to the document. properties.Add("Authorized", true); properties.Add("Authorized By", "John Doe"); properties.Add("Authorized Date", DateTime.Today); properties.Add("Authorized Revision", doc.BuiltInDocumentProperties.RevisionNumber); properties.Add("Authorized Amount", 123.45); // The collection sorts the custom properties in alphabetic order. Assert.AreEqual(1, properties.IndexOf("Authorized Amount")); Assert.AreEqual(5, properties.Count); // Print every custom property in the document. using (IEnumerator <DocumentProperty> enumerator = properties.GetEnumerator()) { while (enumerator.MoveNext()) { Console.WriteLine($"Name: \"{enumerator.Current.Name}\"\n\tType: \"{enumerator.Current.Type}\"\n\tValue: \"{enumerator.Current.Value}\""); } } // Display the value of a custom property using a DOCPROPERTY field. DocumentBuilder builder = new DocumentBuilder(doc); FieldDocProperty field = (FieldDocProperty)builder.InsertField(" DOCPROPERTY \"Authorized By\""); field.Update(); Assert.AreEqual("John Doe", field.Result); // We can find these custom properties in Microsoft Word via "File" -> "Properties" > "Advanced Properties" > "Custom". doc.Save(ArtifactsDir + "DocumentProperties.DocumentPropertyCollection.docx"); // Below are three ways or removing custom properties from a document. // 1 - Remove by index: properties.RemoveAt(1); Assert.False(properties.Contains("Authorized Amount")); Assert.AreEqual(4, properties.Count); // 2 - Remove by name: properties.Remove("Authorized Revision"); Assert.False(properties.Contains("Authorized Revision")); Assert.AreEqual(3, properties.Count); // 3 - Empty the entire collection at once: properties.Clear(); Assert.AreEqual(0, properties.Count); //ExEnd }
public ActionResult Index(int fid = 0, string token_key = "", int uid = 0) { var PROPOSAL_ID = fid; var USER_ID = uid; var DataUserDownload = db.Database.SqlQuery <VIEW_USERS_PUBLIC>("SELECT * FROM VIEW_USERS_PUBLIC WHERE USER_ID = " + USER_ID + " AND USER_PUBLIC_ACTIVATION_KEY = '" + token_key + "'").FirstOrDefault(); if (DataUserDownload != null) { var Data = db.Database.SqlQuery <VIEW_SNI>("SELECT * FROM VIEW_SNI WHERE SNI_PROPOSAL_ID = " + PROPOSAL_ID).SingleOrDefault(); if (Data.DSNI_DOC_FILETYPE.ToLower() == "docx" || Data.DSNI_DOC_FILETYPE.ToLower() == "doc") { string dataDir = Server.MapPath("~" + Data.DSNI_DOC_FILE_PATH); Stream stream = System.IO.File.OpenRead(dataDir + "" + Data.DSNI_DOC_FILE_NAME + ".DOCX"); var IS_LIMIT_DOWNLOAD = Data.IS_LIMIT_DOWNLOAD; Aspose.Words.Document doc = new Aspose.Words.Document(stream); CustomDocumentProperties props = doc.CustomDocumentProperties; var USER_FULL_NAME = ((Convert.ToString(DataUserDownload.USER_PUBLIC_NAMA_LENGKAP) == "") ? "-" : Convert.ToString(DataUserDownload.USER_PUBLIC_NAMA_LENGKAP)); var ACCESS_NAME = ((Convert.ToString(DataUserDownload.ACCESS_NAME) == "") ? "-" : Convert.ToString(DataUserDownload.ACCESS_NAME)); //query tag doc untuk masyarakat var STYLE_LIST = db.Database.SqlQuery <string>("SELECT * FROM VIEW_SNI_STYLE_GROUP").SingleOrDefault(); var AksesSelect = db.Database.SqlQuery <SYS_DOC_ACCESS_DETAIL_SELECT>("SELECT * FROM SYS_DOC_ACCESS_DETAIL_SELECT WHERE DOC_ACCESS_DETAIL_STYLE_STATUS = 0 AND DOC_ACCESS_DETAIL_ACCESS_ID = 3 ORDER BY SNI_STYLE_SORT ASC").ToList(); var kacang = ((STYLE_LIST != null) ? STYLE_LIST : ""); if (AksesSelect.Count() > 0) { foreach (var i in AksesSelect) { // Get a collection of all paragraph nodes in the document Node[] paragraphs = doc.GetChildNodes(NodeType.Paragraph, true).ToArray(); ArrayList nodesToBeDeleted = new ArrayList(); bool isParagraphFound = false; var SNI_STYLE_VALUE = Convert.ToString(i.SNI_STYLE_VALUE); var SNI_STYLE_NAME = Convert.ToString(i.SNI_STYLE_NAME); foreach (Paragraph paragraph in paragraphs) { if (paragraph.ParagraphFormat.Style.Name == SNI_STYLE_VALUE) { // Filter Heading 1 paras and find one that contains the search string //if (paragraph.Range.Text.ToLower().StartsWith(SNI_STYLE_NAME.ToLower())) if (RemoveSpecialCharacters(paragraph.Range.Text.ToLower()).StartsWith(RemoveSpecialCharacters(SNI_STYLE_NAME).ToLower())) { isParagraphFound = true; // We need to delete all nodes present in between the startPara node // and the next Paragraph with Heading 1 Paragraph startPara = paragraph; nodesToBeDeleted.Add(startPara); startPara = startPara.NextSibling as Paragraph; var styleName = startPara.ParagraphFormat.Style.Name; try { while (!kacang.Contains(startPara.ParagraphFormat.Style.Name) && startPara.ParagraphFormat.Style.Name != "" && startPara.ParagraphFormat.Style.Name != null) { nodesToBeDeleted.Add(startPara); startPara = startPara.NextSibling as Paragraph; } } catch (Exception e) { Console.WriteLine("An error occurred: '{0}'", e); break; } if (isParagraphFound) { break; } } } } // Remove all nodes foreach (Node node in nodesToBeDeleted) { node.Remove(); } } } //END query tag doc untuk masyarakat var DataJmlDownload = db.Database.SqlQuery <SYS_CONFIG>("SELECT * FROM SYS_CONFIG WHERE CONFIG_ID = 10").FirstOrDefault(); var DataWatermark = db.Database.SqlQuery <SYS_CONFIG>("SELECT * FROM SYS_CONFIG WHERE CONFIG_ID = 9").FirstOrDefault(); PdfSaveOptions options = new Aspose.Words.Saving.PdfSaveOptions(); if (IS_LIMIT_DOWNLOAD == 1) { options.PageCount = Convert.ToInt32(DataJmlDownload.CONFIG_VALUE); } var watermarkText = DataWatermark.CONFIG_VALUE; string watermark2Text = "SNI ini di download Oleh " + USER_FULL_NAME + " Sebagai " + ACCESS_NAME; Shape watermark = new Shape(doc, ShapeType.TextPlainText); watermark.TextPath.Text = watermarkText + "\r\n" + watermark2Text; watermark.TextPath.FontFamily = "Arial"; double fontSize = 11; watermark.TextPath.Size = fontSize; watermark.Height = fontSize; watermark.Width = watermarkText.Length * fontSize / 2; watermark.Rotation = 90; watermark.Fill.Color = Color.Pink; // Try LightGray to get more Word-style watermark watermark.StrokeColor = Color.Pink; // Try LightGray to get more Word-style watermark watermark.RelativeHorizontalPosition = RelativeHorizontalPosition.RightMargin; watermark.RelativeVerticalPosition = RelativeVerticalPosition.Page; watermark.WrapType = WrapType.None; watermark.VerticalAlignment = VerticalAlignment.Center; watermark.HorizontalAlignment = HorizontalAlignment.Center; watermark.Fill.Opacity = 0.8; Paragraph watermarkPara = new Paragraph(doc); watermarkPara.AppendChild(watermark); foreach (Section sect in doc.Sections) { InsertWatermarkIntoHeader(watermarkPara, sect, HeaderFooterType.HeaderPrimary); InsertWatermarkIntoHeader(watermarkPara, sect, HeaderFooterType.HeaderFirst); InsertWatermarkIntoHeader(watermarkPara, sect, HeaderFooterType.HeaderEven); } stream.Close(); MemoryStream dstStream = new MemoryStream(); var mime = ""; doc.Save(dstStream, options); mime = "application/pdf"; byte[] byteInfo = dstStream.ToArray(); dstStream.Write(byteInfo, 0, byteInfo.Length); dstStream.Position = 0; Response.ContentType = mime; Response.AddHeader("content-disposition", "attachment; filename=SNI_" + Data.DSNI_DOC_FILE_NAME + ".PDF"); Response.BinaryWrite(byteInfo); Response.End(); return(new FileStreamResult(dstStream, mime)); } else { var filePath = Server.MapPath("~" + Data.DSNI_DOC_FILE_PATH); var fileName = Data.DSNI_DOC_FILE_NAME; var fileType = "PDF"; string dataDir = Server.MapPath("~" + Data.DSNI_DOC_FILE_PATH); Stream stream = System.IO.File.OpenRead(dataDir + "" + Data.DSNI_DOC_FILE_NAME + "." + Data.DSNI_DOC_FILETYPE); Directory.CreateDirectory(Server.MapPath("~/Upload/Temp")); var destPath = Server.MapPath("~/Upload/Temp/"); if (System.IO.File.Exists(destPath + Data.DSNI_DOC_FILE_NAME.Replace("/", "-").Replace(":", "-") + "." + Data.DSNI_DOC_FILETYPE)) { System.IO.File.Delete(destPath + Data.DSNI_DOC_FILE_NAME.Replace("/", "-").Replace(":", "-") + "." + Data.DSNI_DOC_FILETYPE); } System.IO.File.Copy(filePath + fileName + "." + fileType, destPath + Data.DSNI_DOC_FILE_NAME.Replace("/", "-").Replace(":", "-") + "." + fileType); return(Redirect("/Upload/Temp/" + Data.DSNI_DOC_FILE_NAME.Replace("/", "-").Replace(":", "-") + "." + fileType)); } } else { var Link = db.Database.SqlQuery <SYS_LINK>("SELECT * FROM SYS_LINK WHERE LINK_ID = 1 AND LINK_IS_USE = 1 AND LINK_STATUS = 1").SingleOrDefault(); return(Redirect(Link.LINK_NAME + "/auth/index")); } //return Json(new { Data, wew = "SELECT * FROM VIEW_SNI WHERE SNI_PROPOSAL_ID = " + PROPOSAL_ID, dataDir }, JsonRequestBehavior.AllowGet); }