public static void Run() { // ExStart:ImageAsBackground // The path to the documents directory. string dataDir = RunExamples.GetDataDir_AsposePdf_Pages(); // Create a new Document object Document doc = new Document(); // Add a new page to document object Page page = doc.Pages.Add(); // Create Background Artifact object BackgroundArtifact background = new BackgroundArtifact(); // Specify the image for backgroundartifact object background.BackgroundImage = File.OpenRead(dataDir + "aspose-total-for-net.jpg"); // Add backgroundartifact to artifacts collection of page page.Artifacts.Add(background); dataDir = dataDir + "ImageAsBackground_out_.pdf"; // Save the document doc.Save(dataDir); // ExEnd:ImageAsBackground System.Console.WriteLine("\nImage as page background added successfully.\nFile saved at " + dataDir); }
public static void Run() { // ExStart:ImageAsBackground // The path to the documents directory. string dataDir = RunExamples.GetDataDir_AsposePdf_Pages(); // Create a new Document object Document doc = new Document(); // Add a new page to document object Page page = doc.Pages.Add(); // Create Background Artifact object BackgroundArtifact background = new BackgroundArtifact(); // Specify the image for backgroundartifact object background.BackgroundImage = File.OpenRead(dataDir + "aspose-total-for-net.jpg"); // Add backgroundartifact to artifacts collection of page page.Artifacts.Add(background); dataDir = dataDir + "ImageAsBackground_out.pdf"; // Save the document doc.Save(dataDir); // ExEnd:ImageAsBackground System.Console.WriteLine("\nImage as page background added successfully.\nFile saved at " + dataDir); }
public void InsertPage(string absoluteFilePath, string outputPath) { var insertPageImgPath = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "DefaultResource", "insertPage.jpeg"); using (var pdfDocument = new Aspose.Pdf.Document(absoluteFilePath)) using (BackgroundArtifact background = new BackgroundArtifact()) { // Add a new page to document object Page page = pdfDocument.Pages.Insert(2); page.AddImage(insertPageImgPath, page.Rect); pdfDocument.Save(outputPath); } }
public void AddWaterprint(string absoluteFilePath, string outputPath) { var watermarkImgPath = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "DefaultResource", "waterMarkImg.jpeg"); using (var pdfDocument = new Aspose.Pdf.Document(absoluteFilePath)) using (BackgroundArtifact background = new BackgroundArtifact()) { foreach (Page aPdfPage in pdfDocument.Pages) { ImageStamp imageStamp = new ImageStamp(watermarkImgPath); imageStamp.XIndent = 300; imageStamp.YIndent = aPdfPage.PageInfo.Height - 200; imageStamp.Height = 81; imageStamp.Width = 80; aPdfPage.AddStamp(imageStamp); } pdfDocument.Save(outputPath); } }
public static void Run() { // The path to the documents directory. string dataDir = RunExamples.GetDataDir_AsposePdf_Pages(); // create a new Document object Document doc = new Document(); // add a new page to document object Page page = doc.Pages.Add(); // create BackgroundArtifact object BackgroundArtifact background = new BackgroundArtifact(); // specify the image for backgroundartifact object background.BackgroundImage = File.OpenRead(dataDir + "aspose-total-for-net.jpg"); // add backgroundartifact to artifacts collection of page page.Artifacts.Add(background); // save the document doc.Save(dataDir + "ImageAsBackground_out.pdf"); }
public static void Main(string[] args) { // The path to the documents directory. string dataDir = Path.GetFullPath("../../../Data/"); // create a new Document object Document doc = new Document(); // add a new page to document object Page page = doc.Pages.Add(); // create BackgroundArtifact object BackgroundArtifact background = new BackgroundArtifact(); // specify the image for backgroundartifact object background.BackgroundImage = File.OpenRead(dataDir + "aspose-total-for-net.jpg"); // add backgroundartifact to artifacts collection of page page.Artifacts.Add(background); // save the document doc.Save(dataDir + "output.pdf"); }
public static void Main(string[] args) { // The path to the documents directory. string dataDir = Path.GetFullPath("../../../Data/"); // create a new Document object Document doc = new Document(); // add a new page to document object Page page = doc.Pages.Add(); // create BackgroundArtifact object BackgroundArtifact background = new BackgroundArtifact(); // specify the image for backgroundartifact object background.BackgroundImage = File.OpenRead(dataDir + "aspose-total-for-net.jpg"); // add backgroundartifact to artifacts collection of page page.Artifacts.Add(background); // save the document doc.Save(dataDir + "output.pdf"); }
public static void Run() { // The path to the documents directory. string dataDir = RunExamples.GetDataDir_AsposePdf_Pages(); // create a new Document object Document doc = new Document(); // add a new page to document object Page page = doc.Pages.Add(); // create BackgroundArtifact object BackgroundArtifact background = new BackgroundArtifact(); // specify the image for backgroundartifact object background.BackgroundImage = File.OpenRead(dataDir + "aspose-total-for-net.jpg"); // add backgroundartifact to artifacts collection of page page.Artifacts.Add(background); // save the document doc.Save(dataDir + "ImageAsBackground_out.pdf"); }