/// <summary> /// Triggered when the user clicks either the "Apply Timestamp" or "Apply signature" button /// It retrives the native document depending on its type (image or PDF), create and initialize /// the proper AnnotationManager object that will be used to draw the annotations. /// </summary> /// <param name="customActionEventArgs">The arguments received from the Global.asax.cs custom actions handler</param> public static void HandleAnnotationAction(CustomActionEventArgs customActionEventArgs) { if (customActionEventArgs.docuVieware.PageCount > 0) { DocumentType docType = customActionEventArgs.docuVieware.GetDocumentType(); switch (docType) { case DocumentType.DocumentTypeBitmap: AnnotateImageDocument(customActionEventArgs); break; case DocumentType.DocumentTypePDF: AnnotatePdfDocument(customActionEventArgs); break; //case DocumentType.DocumentTypeOpenXMLWord: // break; default: customActionEventArgs.message = new DocuViewareMessage("Document format not supported", icon: DocuViewareMessageIcon.Error); break; } } else { customActionEventArgs.message = GetMessage("Please open a filee first." + ".", DocuViewareMessageIcon.Error); } return; }
// // Custom Actions // private void codeTextBox_CustomAction(object sender, CustomActionEventArgs e) { switch (e.Action) { case FCTBAction.CustomAction1: //save saveToolButton.PerformClick(); break; case FCTBAction.CustomAction2: //compile compileToolButton.PerformClick(); break; case FCTBAction.CustomAction3: //execute runtestToolButton.PerformClick(); break; case FCTBAction.CustomAction4: //compile and execute buildRunToolButton.PerformClick(); break; case FCTBAction.CustomAction5: //hide or show compiler ToggleCompilerOutput(); break; } }
// // Input Text Box // private void inputTextBox_CustomAction(object sender, CustomActionEventArgs e) { if (e.Action == FCTBAction.CustomAction1) { saveInputTool.PerformClick(); } }
// // Correct Output // private void correctOutputTextBox_CustomAction(object sender, CustomActionEventArgs e) { if (e.Action == FCTBAction.CustomAction1) { saveCorrectToolButton.PerformClick(); } }
private static void CustomActionDispatcher(object sender, CustomActionEventArgs e) { GdPicturePDF oPDF = new GdPicturePDF(); AnnotationManager oAnnotationsManager = new AnnotationManager(); Annotation oAnnotation; switch (e.actionName) { case "tooltip": e.docuVieware.GetNativePDF(out oPDF); oAnnotationsManager.InitFromGdPicturePDF(oPDF); for (int y = 1; y <= oPDF.GetPageCount(); y++) { oAnnotationsManager.SelectPage(y); oPDF.SetOrigin(PdfOrigin.PdfOriginTopLeft); oPDF.SetMeasurementUnit(PdfMeasurementUnit.PdfMeasurementUnitInch); int AnnotationCount = oAnnotationsManager.GetAnnotationCount(); if (AnnotationCount > 0) { for (int c = 0; c < AnnotationCount; c++) { oAnnotation = oAnnotationsManager.GetAnnotationFromIdx(c); if (oAnnotation.Guid == e.args.ToString()) { e.result = oAnnotation; } } } } break; } }
private static void CustomActionDispatcher(object sender, CustomActionEventArgs e) { switch (e.actionName) { case "load": GalleryDemo.HandleLoadDocumentAction(e); break; //case "automaticRemoveBlackBorders": //case "autoDeskew": //case "punchHoleRemoval": //case "negative": //case "despeckle": //case "rotate-90": //case "rotate+90": // ImageCleanupDemo.HandleImageCleanupAction(e); // break; //case "barcodeRecognition": // BarcodeRecognitionDemo.HandleBarCodeRecognitionAction(e); // break; //case "Calculate": //case "SaveAsPdf": // FormFieldsDemo.HandleFormFieldsAction(e); // break; //case "generatePDFA": // TwainAcquisitionDemo.HandleTwainGeneratePdfaAction(e); // break; //case "addTimestamp": //case "addSignature": // LeaveRequestApprovalDemo.HandleAnnotationAction(e); // break; } }
// // Correct Output // private void correctOutputTextBox_CustomAction(object sender, CustomActionEventArgs e) { if (e.Action == FCTBAction.CustomAction1) { saveInputOutputData(); } }
/// <summary> /// Draws the "Rejected" stamp /// </summary> /// <param name="customActionEventArgs"></param> /// <param name="annotationMngr"></param> private static void AddRejecteStampAnnotation(CustomActionEventArgs customActionEventArgs, AnnotationManager annotationMngr) { ClearAnnotation(annotationMngr, "rejected"); AnnotationRubberStamp approvedStamp = getRubberStamp(annotationMngr, "Rejected"); approvedStamp.Tag = "rejected"; annotationMngr.SaveAnnotationsToPage(); customActionEventArgs.docuVieware.ReloadAnnotations(); }
private static void CustomActionDispatcher(object sender, CustomActionEventArgs e) { switch (e.actionName) { case "load": string path = e.args.ToString(); e.docuVieware.LoadFromStream(new FileStream(HttpRuntime.AppDomainAppPath + "\\Images\\" + path, FileMode.Open)); e.docuVieware.Dispose(); break; } }
/// <summary> /// Draw the signature at the given location with a given size from a base64 encoded PNG image /// </summary> /// <param name="customActionEventArgs">The arguments received from the custom action handler</param> /// <param name="annotationManager">The annotation manager object</param> private static void AddSignatureAnnotation(CustomActionEventArgs customActionEventArgs, AnnotationManager annotationMngr) { ClearAnnotation(annotationMngr, "signature"); const string BASE64_SIGNATURE_IMAGE = "/9j/4AAQSkZJRgABAgAAAQABAAD//gAEKgD/4gIcSUNDX1BST0ZJTEUAAQEAAAIMbGNtcwIQAABtbnRyUkdCIFhZWiAH3AABABkAAwApADlhY3NwQVBQTAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA9tYAAQAAAADTLWxjbXMAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAApkZXNjAAAA/AAAAF5jcHJ0AAABXAAAAAt3dHB0AAABaAAAABRia3B0AAABfAAAABRyWFlaAAABkAAAABRnWFlaAAABpAAAABRiWFlaAAABuAAAABRyVFJDAAABzAAAAEBnVFJDAAABzAAAAEBiVFJDAAABzAAAAEBkZXNjAAAAAAAAAANjMgAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAB0ZXh0AAAAAEZCAABYWVogAAAAAAAA9tYAAQAAAADTLVhZWiAAAAAAAAADFgAAAzMAAAKkWFlaIAAAAAAAAG+iAAA49QAAA5BYWVogAAAAAAAAYpkAALeFAAAY2lhZWiAAAAAAAAAkoAAAD4QAALbPY3VydgAAAAAAAAAaAAAAywHJA2MFkghrC/YQPxVRGzQh8SmQMhg7kkYFUXdd7WtwegWJsZp8rGm/fdPD6TD////bAEMABQMEBAQDBQQEBAUFBQYHDAgHBwcHDwsLCQwRDxISEQ8RERMWHBcTFBoVEREYIRgaHR0fHx8TFyIkIh4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AERACFBMVEQYaHB8CAwQHGRUICB/9oACAEAAAE/EPZigvGZRI34vPIganAFiy7PxHTptEwakCCfziGhgWDIJkd+Dq0dsdcC8Df2mQGyGDtIc6/BkEJmSZmvKLomH31qCxIJyS6WiuYoHyCETE9a8X7VCAKGDF1rxfvXi/evF+9eL968X714v3rt3Gv9tJ/yvF+1eEG8RBRJDYDF2lOVSQalhiyFeL9q5igfMIRMR0pYLIEImonDosUhOkm1ZNvBSBES7cYqxH1OMzyrBt4KRZmHbhXQYtAdIbevqsUlGsO/Cvsf4uBMatawbeSgSIk3rqsUlOku/HKu9Fy+RyY9WFgwzTASN6iBqcASbBu+gq/GSDAAaq4rGSZi0mLNH84DRXCcdFAIWExydvREAeNMBkb1ATRwAmwbvtYYeb3+7CYA1hoCLKmU2qQYcCFil4Xb04SDDgVuEvCb01hoChAmV34o8oaAnN5jLj4MJgGAKYMgZgEZ5ei5ZZmABLU/IiybNQ2fgwmAeSUkZNQi4bn9N4TAITAITAITAITAITAITAITAITAITAITAITAITALEgHWFVgu2MVjqMRaTF2r+8EGuL7QGgQmw3v/Bf/2Q=="; AnnotationEmbeddedImage signature = annotationMngr.AddEmbeddedImageAnnotFromBase64(BASE64_SIGNATURE_IMAGE, 5.38f, 7.9f, 0.86f, 0.86f); signature.CanRotate = false; signature.Tag = "signature"; annotationMngr.SaveAnnotationsToPage(); customActionEventArgs.docuVieware.ReloadAnnotations(); }
/// <summary> /// easter egg for open XML and XSD /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void EditorBox_CustomAction(object sender, CustomActionEventArgs e) { switch (e.Action) { case FCTBAction.CustomAction1: openToolStripMenuItem_Click(null, null); break; case FCTBAction.CustomAction2: openXSDToolStripMenuItem_Click(null, null); break; } }
/// <summary> /// Entry point for the custom action handler /// </summary> public static void HandleLoadDocumentAction(CustomActionEventArgs e) { string docRef = (string)e.args; List <FileDetailsModel> DetList = new List <FileDetailsModel>(); string constr = ConfigurationManager.ConnectionStrings["dbcon"].ToString(); SqlConnection con = new SqlConnection(constr); con.Open(); DynamicParameters parameters = new DynamicParameters(); parameters.Add("@Id", docRef); DetList = SqlMapper.Query <FileDetailsModel>(con, "GetFileDetails", parameters, commandType: CommandType.StoredProcedure).ToList(); con.Close(); e.docuVieware.LoadFromStream(new System.IO.MemoryStream(DetList[0].FileContent), true, DetList[0].FileName); }
protected void docuView_CustomAction(object sender, CustomActionEventArgs e) { // If file type/format, is not allowed if ((sender.ToString() == "OnlyPDF_DOCX")) { // Display an ERROR msg of ONLY Opening allowed Allowed Files DocuViewareMessage docMsg = new DocuViewareMessage ("Only PDF & DOCX file formsts supported.", "#ff5656", 2500, 300, 300, false, "130%", "normal", "#ffffff", "none", "none", "48px", DocuViewareMessageIcon.Error); // EXCEP - CustomActionEventArgs is null e.message = docMsg; } }
void fctb_CustomAction(object sender, CustomActionEventArgs e) { if (e.Action == FCTBAction.CustomAction1) { //this.ExecuteSelectionCSharp(true); this.ExecuteSelectionCSharp(SPCoderForm.AsynchronousExecution); } else if (e.Action == FCTBAction.CustomAction2) { this.SaveCurrentCode(); } else if (e.Action == FCTBAction.CustomAction3) { this.CloseCodeWindow(); } }
/// <summary> /// Releases file from the Memory & Closes the file /// </summary> /// <param name="e"></param> public static void HandleCloseDocument(CustomActionEventArgs e) { // Release from memory int imgId; if (e.docuVieware.GetNativeImage(out imgId) == GdPictureStatus.OK) { GdPictureImaging gdImg = new GdPictureImaging(); gdImg.ReleaseGdPictureImage(imgId); } // Close the document e.docuVieware.Close(); return; }
public void SetStar(CustomActionEventArgs e) { var status = e.docuVieware.GetNativePDF(out GdPicturePDF pdf); ThrowIfFailed(status, "Opening the PDF"); string imageId = pdf.AddJpegImageFromFile(Path.Combine(env.WebRootPath, "Images", "star.jpg")); status = pdf.DrawImage(imageId, 1, 1, 100, 100); ThrowIfFailed(status, "Setting the image"); status = e.docuVieware.RedrawPage(); ThrowIfFailed(status, "Redrawing page"); e.message = new DocuViewareMessage("Star was set successfully!"); e.result = "This result is returned to the front-end."; }
/// <summary> /// Draw the annotation timestamp with custom parameters and custom content /// </summary> /// <param name="customActionEventArgs">The arguments received from the custom action handler</param> /// <param name="annotationManager">The annotation manager object</param> private static void AddTimestampAnnotation(CustomActionEventArgs customActionEventArgs, AnnotationManager annotationMngr) { // Remove timestamp if added on page ClearAnnotation(annotationMngr, "timestamp"); AnnotationText timestamp = annotationMngr.AddTextAnnot(0.2f, 0.2f, 3.0f, 0.2f, DateTime.Now.ToString("G")); timestamp.AutoSize = true; timestamp.Fill = false; timestamp.Stroke = false; timestamp.FontName = "Courier New"; timestamp.ForeColor = Color.OrangeRed; timestamp.FontSize = 10; timestamp.CanEditText = false; timestamp.Tag = "timestamp"; annotationMngr.SaveAnnotationsToPage(); customActionEventArgs.docuVieware.ReloadAnnotations(); }
/// <summary> /// Dedicated to process image documents /// It retrieves the currently loaded native image handle and initializes an annotation manager object from it. /// </summary> /// <param name="customActionEventArgs">The arguments received from the custom action handler</param> private static void AnnotatePdfDocument(CustomActionEventArgs customActionEventArgs) { GdPicturePDF gdPicturePdf; GdPictureStatus status = customActionEventArgs.docuVieware.GetNativePDF(out gdPicturePdf); if (status == GdPictureStatus.OK) { using (AnnotationManager annotateMngr = new AnnotationManager()) { status = annotateMngr.InitFromGdPicturePDF(gdPicturePdf); if (status == GdPictureStatus.OK) { if (customActionEventArgs.actionName == "addTimestamp") { AddTimestampAnnotation(customActionEventArgs, annotateMngr); } else if (customActionEventArgs.actionName == "addSignature") { AddSignatureAnnotation(customActionEventArgs, annotateMngr); } else if (customActionEventArgs.actionName == "addApprovedStamp") { AddApprovedStampAnnotation(customActionEventArgs, annotateMngr); } else if (customActionEventArgs.actionName == "addRejectedStamp") { AddRejecteStampAnnotation(customActionEventArgs, annotateMngr); } } else { customActionEventArgs.message = new DocuViewareMessage("Failed to initialize Annotation Manager. Status is : " + status + ".", icon: DocuViewareMessageIcon.Error); } } } else { customActionEventArgs.message = new DocuViewareMessage("Failed to retrieve native document. Status is : " + status + ".", icon: DocuViewareMessageIcon.Error); } return; }
private void MarkedFastTextBox_CustomAction(object?sender, CustomActionEventArgs e) { Keys key = e.Action switch { FCTBAction.CustomAction1 => Keys.Left, FCTBAction.CustomAction2 => Keys.Right, _ => Keys.Escape }; if ((key == Keys.Left || key == Keys.Right) && markerCaret != null) { int caret = SelectionStart; int nodeIndex = Array.IndexOf(markerSequence !, markerCaret); MarkerNode?targetNode = null; if (key == Keys.Left) { while (--nodeIndex >= 0) { targetNode = markerSequence ![nodeIndex];
/// <summary> /// Deletes current page of Image and/or PDF file formats /// </summary> /// <param name="e"></param> public static void HandleRemovePage(CustomActionEventArgs e) { RotateActionParameters rotateParams = JsonConvert.DeserializeObject <RotateActionParameters>(e.args.ToString()); int currPage = rotateParams.CurrentPage; rotateParams = null; // For PDF FILES if (e.docuVieware.GetDocumentType() == DocumentType.DocumentTypePDF) { GdPicturePDF gdPdf = null; if (e.docuVieware.GetNativePDF(out gdPdf) == GdPictureStatus.OK) { gdPdf.DeletePage(currPage); e.message = GetMessage("Page Deleted Successfully ", DocuViewareMessageIcon.Information); } } // For Image Files, Scanned docs int imgId; if (e.docuVieware.GetNativeImage(out imgId) == GdPictureStatus.OK) { GdPictureImaging gdImg = new GdPictureImaging(); if (gdImg.SelectPage(imgId, currPage) == GdPictureStatus.OK) { if (gdImg.TiffDeletePage(imgId, currPage) == GdPictureStatus.OK) //gdImg.ReleaseGdPictureImage(imgId) == GdPictureStatus.OK) { e.message = GetMessage("Document was rejected successfully.", DocuViewareMessageIcon.Information); } } } else { e.message = GetMessage("Remove Page : File Type not supported ! ", DocuViewareMessageIcon.Warning); } return; }
private static void CustomActionDispatcher(object sender, CustomActionEventArgs e) { switch (e.actionName) { case "delete": if (e.docuVieware.GetDocumentType() == DocumentType.DocumentTypePDF) { GdPicturePDF oGdPicturePDF = new GdPicturePDF(); //prepare array of selected pages List <int> selectedPages = JsonConvert.DeserializeObject <List <int> >(e.args.ToString()); selectedPages = selectedPages.OrderByDescending(t => t).ToList(); //delete pages from the native PDF if (e.docuVieware.GetNativePDF(out oGdPicturePDF) == GdPictureStatus.OK) { foreach (int page in selectedPages) { if (oGdPicturePDF.DeletePage(page) != GdPictureStatus.OK) { e.result = oGdPicturePDF.GetStat().ToString(); break; } } } e.docuVieware.RedrawPage(); } else { e.message = new DocuViewareMessage("Wrong document format"); } break; } }
private void fastRichTextBoxQuery_CustomAction(object sender, CustomActionEventArgs e) { MessageBox.Show(e.Action.ToString()); }
private void fctb_CustomAction(object sender, CustomActionEventArgs e) { MessageBox.Show(e.Action.ToString()); }
private static void Dispatcher(object sender, CustomActionEventArgs e) { GdPicturePDF oPdf = new GdPicturePDF(); switch (e.actionName) { //loading document and setting annotations access control //the workflow is designed for PDF files, you can apply similar workflow on the other formats using GdPictureImaging class case "load": load oLoad = JsonConvert.DeserializeObject <load>(e.args.ToString()); GdPictureStatus status = oPdf.LoadFromFile(HttpRuntime.AppDomainAppPath + "\\Files\\" + oLoad.Path, true); AnnotationManager oAnnotationmanager = new AnnotationManager(); oAnnotationmanager.InitFromGdPicturePDF(oPdf); for (int i = 1; i < oAnnotationmanager.PageCount; i++) { oAnnotationmanager.SelectPage(i); for (int y = 0; y < oAnnotationmanager.GetAnnotationCount(); y++) { Annotation annot = oAnnotationmanager.GetAnnotationFromIdx(y); if (oLoad.UserType == "user") //case for external user member { if (annot.Tag != oLoad.UserType) //annotation is not vissible if not added by external group memebr { annot.Visible = false; } } else if (oLoad.UserType == "staff") //case for staff member { annot.Visible = true; //all annot are visible } } oAnnotationmanager.SaveAnnotationsToPage(); } e.docuVieware.LoadFromGdPicturePdf(oPdf); e.docuVieware.DisplayPage(1); break; //setting annotation tag that represents access group and saving annotation to PDF //the workflow is designed for PDF files, you can apply similar workflow on the other formats using GdPictureImaging class case "setAnnotationTag": e.docuVieware.GetNativePDF(out oPdf); AnnotationManager manager = new AnnotationManager(); manager.InitFromGdPicturePDF(oPdf); details oDetails = JsonConvert.DeserializeObject <details>(e.args.ToString()); manager.SelectPage(oDetails.annot.pageNo); int pages = manager.GetAnnotationCount(); for (int i = 0; i < pages; i++) { Annotation oAnnotation = manager.GetAnnotationFromIdx(i); if (oAnnotation.Guid == oDetails.annot.id) { oAnnotation.Tag = oDetails.type; } } manager.SaveAnnotationsToPage(); status = oPdf.SaveToFile(HttpRuntime.AppDomainAppPath + "\\Files\\DocuViewareFlyer.pdf", true); break; } }
/// <summary> /// /// </summary> /// <param name="e"></param> public static void HandleUnsupportedFileTypeAction(CustomActionEventArgs e) { e.message = GetMessage("Only PDF & DOCX file formsts supported.", DocuViewareMessageIcon.Warning); }
private void Editor_CustomAction(object sender, CustomActionEventArgs e) { switch (e.Action) { // New case FCTBAction.CustomAction1: tsNew_Click(tsNew, null); break; // Open case FCTBAction.CustomAction2: tsOpen_Click(tsOpen, null); break; // Save case FCTBAction.CustomAction3: tsSave_Click(tsSave, null); break; // Debug case FCTBAction.CustomAction4: tsDebug_Click(tsDebug, null); break; // Run case FCTBAction.CustomAction5: tsRun_Click(tsRun, null); break; } }
// // Input Text Box // private void inputTextBox_CustomAction(object sender, CustomActionEventArgs e) { if (e.Action == FCTBAction.CustomAction1) { saveInputOutputData(); } }
/// <summary> /// Handles Image Cleaup Actions /// </summary> /// <param name="e"></param> public static void HandleImageCleanupAction(CustomActionEventArgs e) { if (e.docuVieware.PageCount > 0) { if (e.docuVieware.GetDocumentType() == DocumentType.DocumentTypeBitmap) { int imageId; GdPictureStatus status = e.docuVieware.GetNativeImage(out imageId); if (status == GdPictureStatus.OK) { status = GdPictureStatus.GenericError; using (GdPictureImaging gdPictImg = new GdPictureImaging()) { RotateActionParameters parameters = JsonConvert.DeserializeObject <RotateActionParameters>(e.args.ToString()); if (parameters.RegionOfInterest != null && parameters.RegionOfInterest.Width > 0 && parameters.RegionOfInterest.Height > 0) { gdPictImg.SetROI((int)Math.Round(parameters.RegionOfInterest.Left * gdPictImg.GetHorizontalResolution(imageId), 0), (int)Math.Round(parameters.RegionOfInterest.Top * gdPictImg.GetVerticalResolution(imageId), 0), (int)Math.Round(parameters.RegionOfInterest.Width * gdPictImg.GetHorizontalResolution(imageId), 0), (int)Math.Round(parameters.RegionOfInterest.Height * gdPictImg.GetVerticalResolution(imageId), 0)); } if (e.actionName != "punchHoleRemoval" || (e.actionName == "punchHoleRemoval" && gdPictImg.GetBitDepth(imageId) == 1)) { foreach (var page in parameters.Pages) { status = gdPictImg.SelectPage(imageId, page); if (status == GdPictureStatus.OK) { switch (e.actionName) { case "automaticRemoveBlackBorders": status = gdPictImg.DeleteBlackBorders(imageId, 10, false); break; case "autoDeskew": status = gdPictImg.AutoDeskew(imageId); break; case "punchHoleRemoval": status = gdPictImg.RemoveHolePunch(imageId, HolePunchMargins.MarginLeft | HolePunchMargins.MarginRight | HolePunchMargins.MarginBottom | HolePunchMargins.MarginTop); break; case "despeckle": status = gdPictImg.FxDespeckle(imageId); break; } if (status != GdPictureStatus.OK) { e.message = GetMessage("Error during apply filter: " + status + " on page " + page, DocuViewareMessageIcon.Error); break; } } else { e.message = GetMessage("Error during page selectionr: " + status + "." + page, DocuViewareMessageIcon.Error); break; } } // foreach if (status == GdPictureStatus.OK) { status = e.docuVieware.RedrawPages(parameters.Pages); e.message = status == GdPictureStatus.OK ? new DocuViewareMessage("Filter successfuly applied.", icon: DocuViewareMessageIcon.Ok) : GetMessage("Error during redraw pages : " + status + ".", DocuViewareMessageIcon.Error); } } else { e.message = GetMessage("Your image must be 1 bit-depth to apply this filter!", DocuViewareMessageIcon.Error); } } // using } else { e.message = GetMessage("Error during get native image : " + status + ".", DocuViewareMessageIcon.Error); } } else { e.message = GetMessage("Only raster formats are supported!", DocuViewareMessageIcon.Error); } } else { e.message = GetMessage("Please open an image first." + ".", DocuViewareMessageIcon.Error); } return; }
private void fct_box_CustomAction(object sender, CustomActionEventArgs e) { }
/* * /// <summary> * /// * /// </summary> * /// <param name="e"></param> * public static void HandleSaveFile(CustomActionEventArgs customActionEventArgs) * { * * DocumentType docType = customActionEventArgs.docuVieware.GetDocumentType(); * if (docType == DocumentType.DocumentTypeTXT) * { * MemoryStream memStream = null; * GdPictureStatus status; * * status = customActionEventArgs.docuVieware.GetDocumentData(out memStream); * * if (status == GdPictureStatus.OK) * { * string nm = customActionEventArgs.docuVieware.GetDocumentName(); * int indexOf = nm.IndexOf('.'); * if (indexOf > 0) * nm = nm.Substring(0, indexOf); * * nm = nm + ".tiff"; * string fileName = HttpRuntime.AppDomainAppPath + "\\" + nm; * FileStream fs = new FileStream(fileName, FileMode.CreateNew, FileAccess.ReadWrite); * fs.Write(memStream.GetBuffer(), 0, (int)memStream.Length); * customActionEventArgs.docuVieware.SaveAsTIFF(memStream); * * fs = null; * } else * { * customActionEventArgs.message = GetMessage("Save : Fail to get Stream data.", DocuViewareMessageIcon.Error); * } * * memStream = null; * } * } */ /// <summary> /// Triggers when user clicks on Rotate -90 or Rotate +90. Rotates the image file as per the request. /// </summary> /// <remarks> /// Only image file formats can be Rotated. Shows error message if File is not Supported, File is not of proper format, /// Cannot select Page, Failed to Rotate the file contents. /// </remarks> /// <param name="e">The CustomActionEventArgs received from the Global.asax.cs custom actions handler</param> public static void HandleRotationAction(CustomActionEventArgs e) { GdPictureStatus status = GdPictureStatus.Aborted; // For Images if (e.docuVieware.GetDocumentType() == DocumentType.DocumentTypeBitmap) { int imageId; status = e.docuVieware.GetNativeImage(out imageId); if (status == GdPictureStatus.OK) { GdPictureImaging gdPictureImaging = new GdPictureImaging(); RotateActionParameters rotateParams = JsonConvert.DeserializeObject <RotateActionParameters>(e.args.ToString()); int currPage = rotateParams.CurrentPage; status = gdPictureImaging.SelectPage(imageId, currPage); // rotateParams.CurrentPage); if (status == GdPictureStatus.OK) { switch (e.actionName) { case "rotateM90": status = gdPictureImaging.Rotate(imageId, RotateFlipType.Rotate270FlipNone); break; case "rotateP90": status = gdPictureImaging.Rotate(imageId, RotateFlipType.Rotate90FlipNone); break; } if (status != GdPictureStatus.OK) { e.message = new DocuViewareMessage("Error during rotating: " + status + ".", icon: DocuViewareMessageIcon.Error); } else { status = e.docuVieware.RedrawPage(); e.message = status == GdPictureStatus.OK ? new DocuViewareMessage("Rotation successfuly applied.", icon: DocuViewareMessageIcon.Ok) : new DocuViewareMessage("Error during redraw pages : " + status + ".", icon: DocuViewareMessageIcon.Error); } } else { e.message = new DocuViewareMessage("Error during page selection: " + status + ".", icon: DocuViewareMessageIcon.Error); } rotateParams = null; gdPictureImaging = null; } else { e.message = new DocuViewareMessage("Error during get native image : " + status + ".", icon: DocuViewareMessageIcon.Error); } } else if (e.docuVieware.GetDocumentType() == DocumentType.DocumentTypePDF) { GdPicturePDF gdPdf = null; if (e.docuVieware.GetNativePDF(out gdPdf) == GdPictureStatus.OK) { RotateActionParameters rotateParams = JsonConvert.DeserializeObject <RotateActionParameters>(e.args.ToString()); int currPage = rotateParams.CurrentPage; gdPdf.SelectPage(currPage); switch (e.actionName) { case "rotateM90": status = gdPdf.RotatePage(-90); break; case "rotateP90": status = gdPdf.RotatePage(90); break; } if (status != GdPictureStatus.OK) { e.message = GetMessage("Error during rotating: " + status + ".", DocuViewareMessageIcon.Error); } else { status = e.docuVieware.RedrawPage(); e.message = status == GdPictureStatus.OK ? GetMessage("Rotation successfuly applied.", DocuViewareMessageIcon.Ok) : GetMessage("Error during redraw pages : " + status + ".", DocuViewareMessageIcon.Error); } rotateParams = null; gdPdf = null; } else { e.message = GetMessage("Error during get native image : " + status + ".", DocuViewareMessageIcon.Error); } } else { e.message = GetMessage("Only Images & PDF formats Rotation supported", DocuViewareMessageIcon.Error); } return; }