public static void Run() { // ExStart:ChangePageSizes // The path to the documents directory. string dataDir = RunExamples.GetDataDir_AsposePdfFacades_TechnicalArticles(); // Create PdfPageEditor object PdfPageEditor pEdit = new PdfPageEditor(); // Bind pdf file pEdit.BindPdf(dataDir + "FilledForm.pdf"); // Change page size of the selected pages pEdit.ProcessPages = new int[] { 1 }; // Here we select a member named 'LETTER' from the list of members of PageSize class and assign it to PageSize property of the PdfPageEditor class pEdit.PageSize = PageSize.PageLetter; // Save the file pEdit.Save(dataDir + "ChangePageSizes_out_.pdf"); // Find at what size a page has been assigned pEdit.BindPdf(dataDir + "FilledForm.pdf"); PageSize size = pEdit.GetPageSize(1); pEdit = null; // ExEnd:ChangePageSizes }
public static void Run() { // ExStart:SetPageProperties // The path to the documents directory. string dataDir = RunExamples.GetDataDir_AsposePdfFacades_Pages(); // Open document PdfPageEditor pageEditor = new PdfPageEditor(); pageEditor.BindPdf(dataDir + "input.pdf"); // Set page properties // Move origin from (0,0) pageEditor.MovePosition(100, 100); // Set page rotations Hashtable pageRotations = new Hashtable(); pageRotations.Add(1, 90); pageRotations.Add(2, 180); pageRotations.Add(3, 270); // PageEditor.PageRotations = pageRotations; // Set zoom where 1.0f = 100% zoom pageEditor.Zoom = 2.0f; // Save updated PDF file pageEditor.Save(dataDir + "SetPageProperties_out.pdf"); // ExEnd:SetPageProperties }
public static void Run() { // ExStart:PageRotation // The path to the documents directory. string dataDir = RunExamples.GetDataDir_AsposePdfFacades_TechnicalArticles(); // Create PdfPageEditor object PdfPageEditor pEdit = new PdfPageEditor(); // Rotate odd pages at 180 degrees pEdit.BindPdf(dataDir + "inFile1.pdf"); pEdit.ProcessPages = new int[] { 1 }; pEdit.Rotation = 180; pEdit.Save(dataDir + "Aspose.Pdf.Facades_rotate_180_out.pdf"); // Rotate even pages at 270 degrees pEdit.BindPdf(dataDir + "inFile2.pdf"); pEdit.ProcessPages = new int[] { 1 }; pEdit.Rotation = 270; pEdit.Save(dataDir + "Aspose.Pdf.Facades_rotate_270_out.pdf"); // Find at what degrees a page was rotated pEdit.BindPdf(dataDir + "inFile.pdf"); int degrees = pEdit.GetPageRotation(1); pEdit = null; // ExEnd:PageRotation }
public static void Run() { // ExStart:ZoomToPageContents // The path to the documents directory. string dataDir = RunExamples.GetDataDir_AsposePdf_Pages(); // Load source PDF file Document doc = new Document(dataDir + "input.pdf"); // Get rectangular region of first page of PDF Aspose.Pdf.Rectangle rect = doc.Pages[1].Rect; // Instantiate PdfPageEditor instance PdfPageEditor ppe = new PdfPageEditor(); // Bind source PDF ppe.BindPdf(dataDir + "input.pdf"); // Set zoom coefficient ppe.Zoom = (float)(rect.Width / rect.Height); // Update page size ppe.PageSize = new Aspose.Pdf.PageSize((float)rect.Height, (float)rect.Width); dataDir = dataDir + "ZoomToPageContents_out_.pdf"; // Save output file doc.Save(dataDir); // ExEnd:ZoomToPageContents System.Console.WriteLine("\nZoom to page contents applied successfully.\nFile saved at " + dataDir); }
public static void Run() { // ExStart:ZoomToPageContents // The path to the documents directory. string dataDir = RunExamples.GetDataDir_AsposePdf_Pages(); // Load source PDF file Document doc = new Document(dataDir + "input.pdf"); // Get rectangular region of first page of PDF Aspose.Pdf.Rectangle rect = doc.Pages[1].Rect; // Instantiate PdfPageEditor instance PdfPageEditor ppe = new PdfPageEditor(); // Bind source PDF ppe.BindPdf(dataDir + "input.pdf"); // Set zoom coefficient ppe.Zoom = (float)(rect.Width / rect.Height); // Update page size ppe.PageSize = new Aspose.Pdf.PageSize((float)rect.Height, (float)rect.Width); dataDir = dataDir + "ZoomToPageContents_out.pdf"; // Save output file doc.Save(dataDir); // ExEnd:ZoomToPageContents System.Console.WriteLine("\nZoom to page contents applied successfully.\nFile saved at " + dataDir); }
public static void Run() { // ExStart:ChangePageSizes // The path to the documents directory. string dataDir = RunExamples.GetDataDir_AsposePdfFacades_TechnicalArticles(); // Create PdfPageEditor object PdfPageEditor pEdit = new PdfPageEditor(); // Bind pdf file pEdit.BindPdf(dataDir + "FilledForm.pdf"); // Change page size of the selected pages pEdit.ProcessPages = new int[] { 1}; // Here we select a member named 'LETTER' from the list of members of PageSize class and assign it to PageSize property of the PdfPageEditor class pEdit.PageSize = PageSize.PageLetter; // Save the file pEdit.Save(dataDir + "ChangePageSizes_out.pdf"); // Find at what size a page has been assigned pEdit.BindPdf(dataDir + "FilledForm.pdf"); PageSize size = pEdit.GetPageSize(1); pEdit = null; // ExEnd:ChangePageSizes }
public static void Run() { // ExStart:GetPageProperties // The path to the documents directory. string dataDir = RunExamples.GetDataDir_AsposePdfFacades_Pages(); // Open document PdfPageEditor pageEditor = new PdfPageEditor(); pageEditor.BindPdf(dataDir + "input.pdf"); // Get page properties Console.WriteLine(pageEditor.GetPageRotation(1)); Console.WriteLine(pageEditor.GetPages()); Console.WriteLine(pageEditor.GetPageBoxSize(1, "trim")); Console.WriteLine(pageEditor.GetPageBoxSize(1, "art")); Console.WriteLine(pageEditor.GetPageBoxSize(1, "bleed")); Console.WriteLine(pageEditor.GetPageBoxSize(1, "crop")); Console.WriteLine(pageEditor.GetPageBoxSize(1, "media")); // ExEnd:GetPageProperties }
private void button1_Click(object sender, RibbonControlEventArgs e) { DateTime currentdate = System.DateTime.Now; #region get path and project info //get active project and path MSPROJECT.Project project1 = Globals.ThisAddIn.Application.ActiveProject; string projectpath = project1.Path.ToString(); projectname = project1.Name.ToString(); string datadir = projectpath; bool baseline_ = false; //project1.SaveAs(datadir + "\\" + "temp.mpp"); DialogResult result = MessageBox.Show("All Projects Will Be Saved and Closed. Proceed?", "Warning", MessageBoxButtons.YesNo, MessageBoxIcon.Warning); try { if (result == DialogResult.Yes) { Globals.ThisAddIn.Application.FileCloseAllEx(MSPROJECT.PjSaveType.pjSave); Aspose.Tasks.Project prj = new Aspose.Tasks.Project(datadir + "\\" + projectname); // Declare ChildTasksCollector class object ChildTasksCollector collector = new ChildTasksCollector(); // Use TaskUtils to get all children tasks in RootTask TaskUtils.Apply(prj.RootTask, collector, 0); //create entity SchedulingEntities db = new SchedulingEntities(); Schedule_Actual actual = new Schedule_Actual(); Schedule_Baseline baseline = new Schedule_Baseline(); #region view all tasks DialogResult baselineresult = MessageBox.Show("Create/Update Baseline?", "Warning", MessageBoxButtons.YesNo, MessageBoxIcon.Question); if (baselineresult == DialogResult.Yes) { baseline_ = true; } else { } foreach (Task tsk2 in collector.Tasks) { Calendar tskCal = tsk2.Get(Tsk.Calendar); string taskinfo = tsk2.ToString(); int id1 = tsk2.Get(Tsk.Id); if (id1 == 0) { string jobnumber = tsk2.Get(Tsk.Name); actual.job = jobnumber; actual.createdate = currentdate; if (baseline_ == true) { baseline.job = jobnumber; baseline.createdate = currentdate; } } if (tsk2.Get(Tsk.Name) == "Design") { DateTime designStart = tsk2.Get(Tsk.Start); DateTime designEnd = tsk2.Get(Tsk.Finish); actual.designend = designEnd; actual.designstart = designStart; if (baseline_ == true) { baseline.designstart = designStart; baseline.designend = designEnd; } } if (tsk2.Get(Tsk.Name) == "Processing") { DateTime processingStart = tsk2.Get(Tsk.Start); DateTime processingEnd = tsk2.Get(Tsk.Finish); actual.processingend = processingEnd; actual.processingstart = processingStart; if (baseline_ == true) { baseline.processingend = processingEnd; baseline.processingstart = processingStart; } } if (tsk2.Get(Tsk.Name) == "Weld Fab") { DateTime weldStart = tsk2.Get(Tsk.Start); DateTime weldEnd = tsk2.Get(Tsk.Finish); actual.weldstart = weldStart; actual.weldend = weldEnd; if (baseline_ == true) { baseline.weldstart = weldStart; baseline.weldend = weldEnd; } } if (tsk2.Get(Tsk.Name) == "Machine") { DateTime machineStart = tsk2.Get(Tsk.Start); DateTime machineEnd = tsk2.Get(Tsk.Finish); actual.machineend = machineEnd; actual.machinestart = machineStart; if (baseline_ == true) { baseline.machineend = machineEnd; baseline.machinestart = machineStart; } } if (tsk2.Get(Tsk.Name) == "Assembly") { DateTime assemblyStart = tsk2.Get(Tsk.Start); DateTime assemblyEnd = tsk2.Get(Tsk.Finish); actual.assemblystart = assemblyStart; actual.assemblyend = assemblyEnd; if (baseline_ == true) { baseline.assemblyend = assemblyEnd; baseline.assemblystart = assemblyStart; } } if (tsk2.Get(Tsk.Name) == "QA BUY OFF") { DateTime qaStart = tsk2.Get(Tsk.Start); DateTime qaEnd = tsk2.Get(Tsk.Finish); actual.qastart = qaStart; actual.qaend = qaEnd; if (baseline_ == true) { baseline.qaend = qaEnd; baseline.qastart = qaStart; } } if (tsk2.Get(Tsk.Name) == "Material") { DateTime matStart = tsk2.Get(Tsk.Start); DateTime matEnd = tsk2.Get(Tsk.Finish); actual.materialstart = matStart; actual.materialend = matEnd; if (baseline_ == true) { baseline.materialstart = matStart; baseline.materialend = matEnd; } } } db.Schedule_Actual.Add(actual); if (baseline_ == true) { db.Schedule_Baseline.Add(baseline); } db.SaveChanges(); SaveOptions saveOptions = new PdfSaveOptions(); saveOptions.PageSize = PageSize.Ledger; saveOptions.SaveFormat.Equals(SaveFileFormat.PDF); saveOptions.FitContent = true; saveOptions.Timescale = Timescale.ThirdsOfMonths; saveOptions.PresentationFormat = PresentationFormat.GanttChart; saveOptions.LegendOnEachPage = false; projectname = projectname.Replace("-", "_"); string filename = "R:\\wipviewer2017\\prjfiles\\" + projectname + ".pdf"; prj.Save(filename, saveOptions); email_team(filename); PdfPageEditor pEdit = new PdfPageEditor(); } #endregion else if (result == DialogResult.No) { // DO NOTHING } } catch (Exception ee) { MessageBox.Show(ee.ToString()); } #endregion }