public WindowMain() { InitializeComponent(); fAppSettings = new AppSettings(); fLastScanned = PageTypeEnum.Letter; fScanner = new Scanner(); fPrinter = new Printer(); fPdfExporter = new PdfExporter(); fPdfImporter = new PdfImporter(); fImageLoader = new ImageLoader(); fImageSaver = new ImageSaver(); fDocument = new Document(); fDocument.OnPageAdded += fDocument_OnPageAdded; fDocument.OnPageRemoved += fDocument_OnPageRemoved; fDocument.OnPageUpdated += fDocument_OnPageUpdated; fDocument.OnPageMoved += fDocument_OnPageMoved; fInsertionMark = new InsertionMark(); fDragStartItem = null; fScrollTimer = new System.Timers.Timer(150); fScrollTimer.Elapsed += fScrollTimer_Elapsed; fScrollTimer.AutoReset = false; this.KeyUp += WindowMain_KeyUp; fClosing = false; fDeleting = false; }
public void LoadDocument(Document document, string filename, bool attemptSingleImageMode, ResolutionDpi viewingResolution) { try { IntPtr docPtr = LibPdfium.LoadDocument(filename); for(int i = 0; i < LibPdfium.GetPageCount(docPtr); i++) { IntPtr pagePtr = LibPdfium.LoadPage(docPtr, i); double height = LibPdfium.GetPageHeight(pagePtr); double width = LibPdfium.GetPageWidth(pagePtr); SizeInches pageSize = new SizeInches(width, height); Page myPage = new PageFromPdf(filename, i, pageSize, attemptSingleImageMode, viewingResolution); document.AddPage(myPage); LibPdfium.ClosePage(pagePtr); } LibPdfium.CloseDocument(docPtr); } catch(Exception ex) { string msg = ex.Message; } }
public void LoadImagesFromFiles(Document document, string[] filenames, SizeInches size) { foreach(string filename in filenames) { LoadFromFile(document, filename, size); } }
public void LoadPagesFromFiles(Document document, string[] filenames, bool attemptPdfSingleImageImport, ResolutionDpi viewingResolution) { foreach(string filename in filenames) { LoadDocument(document, filename, attemptPdfSingleImageImport, viewingResolution); } }
public string GenerateReport(Model.Document documentObject) { string filePath = string.Empty; if (documentObject.documentArray != null) { string appRootDir = Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments); // Step 1: Creating System.IO.FileStream object DirectoryInfo path = Directory.CreateDirectory(appRootDir + "/LiRoInspectionDocuments"); //iTextSharp.text.Document pdfDocument = new iTextSharp.text.Document (PageSize.A4, 20f, 20f, 60f, 60f); //FillDocument (documentObject.documentArray, pdfDocument); using (FileStream fs = new FileStream(path.FullName + "/" + documentObject.documentDisplayName, FileMode.Create, FileAccess.ReadWrite, FileShare.None)) { using (StreamWriter writer = new StreamWriter(fs, Encoding.UTF8)) { byte[] buffer = documentObject.documentArray; fs.Write(buffer, 0, buffer.Length); writer.Close(); } } filePath = Path.Combine(path.FullName, documentObject.documentDisplayName); } return(filePath); }
//end protected void btnEdit_ServerClick(object sender, EventArgs e) { if (((this.txtName.Value.Length == 0) || (this.uploadurl.Value.Length == 0)) || (this.selWorkFlow.SelectedValue.Length == 0)) { MessageBox.Show(this, "请您填写完整的信息"); } else { Model.SelectRecord selectRecord = new Model.SelectRecord("WorkFlow", "", "*", "where id='" + this.selWorkFlow.SelectedValue + "'"); DataTable table = BLL.SelectRecord.SelectRecordData(selectRecord).Tables[0]; string content = File.ReadAllText(System.Web.HttpContext.Current.Request.MapPath("../") + table.Rows[0]["URL"].ToString()); //ziyunhx add 2013-8-5 workflow Persistence //old code //WorkFlowTracking.instance = engineManager.createInstance(content, null, null); //WorkFlowTracking.instance.Run(); //new code instance = engineManager.createInstance(content, null, null); if (instanceStore == null) { instanceStore = new SqlWorkflowInstanceStore(SqlHelper.strconn); view = instanceStore.Execute(instanceStore.CreateInstanceHandle(), new CreateWorkflowOwnerCommand(), TimeSpan.FromSeconds(30)); instanceStore.DefaultInstanceOwner = view.InstanceOwner; } instance.InstanceStore = instanceStore; instance.Run(); //end Model.Document documents = new Model.Document { ID = id.Trim(), Name = this.txtName.Value.Trim(), URL = this.uploadurl.Value.Trim(), Remark = this.txtReMark.Value.Trim(), WID = this.selWorkFlow.SelectedValue, WStep = "0", Result = "0", UID = this.Session["admin"].ToString(), //ziyunhx add 2013-8-5 workflow Persistence //old code //FlowInstranceID = WorkFlowTracking.instance.Id, //new code FlowInstranceID = instance.Id, //end }; if (BLL.Document.DocumentUpdate(documents) == 1) { UserOperatingManager.InputUserOperating(this.Session["admin"].ToString(), "工作流管理", "编辑工作流" + documents.Name + "的信息成功"); MessageBox.ShowAndRedirect(this, "编辑公文成功!", "/document/DocumentList.aspx"); } else { UserOperatingManager.InputUserOperating(this.Session["admin"].ToString(), "工作流管理", "编辑工作流" + documents.Name + "的信息失败"); MessageBox.Show(this, "编辑工作流失败"); } } }
public void SaveImages(Document document, string filename, List<int> pageNumbers, int compressionRate) { string directory = System.IO.Path.GetDirectoryName(filename); string extension = System.IO.Path.GetExtension(filename); System.Drawing.Imaging.ImageFormat format; switch(extension.ToUpper()) { case ".JPG": { format = System.Drawing.Imaging.ImageFormat.Jpeg; } break; case ".GIF": { format = System.Drawing.Imaging.ImageFormat.Gif; } break; case ".PNG": { format = System.Drawing.Imaging.ImageFormat.Png; } break; case ".BMP": { format = System.Drawing.Imaging.ImageFormat.Bmp; } break; default: { format = null; } break; } foreach(int num in pageNumbers) { Page page = document.GetPage(num); Image image = page.GetImage(); if (format == null) { // Since the format is not specified use the native format from the image format = image.RawFormat; } string saveName = page.Name; if(pageNumbers.Count == 1) { saveName = System.IO.Path.GetFileNameWithoutExtension(filename); } SaveImage(image, format, directory, saveName, compressionRate); } }
public static int DocumentUpdate(Model.Document documentinfo) { SqlParameter[] pars = new SqlParameter[] { new SqlParameter("@ID", SqlDbType.Int), new SqlParameter("@Name", SqlDbType.VarChar, 50), new SqlParameter("@URL", SqlDbType.VarChar, 100), new SqlParameter("@Remark", SqlDbType.VarChar, 255), new SqlParameter("@WID", SqlDbType.Int), new SqlParameter("@WStep", SqlDbType.Int), new SqlParameter("@Result", SqlDbType.TinyInt), new SqlParameter("@FlowInstranceID", SqlDbType.UniqueIdentifier) }; pars[0].Value = documentinfo.ID; pars[1].Value = documentinfo.Name; pars[2].Value = documentinfo.URL; pars[3].Value = documentinfo.Remark; pars[4].Value = documentinfo.WID; pars[5].Value = documentinfo.WStep; pars[6].Value = documentinfo.Result; pars[7].Value = documentinfo.FlowInstranceID; return(SqlHelper.ExecuteProcess("pro_Document_Update", pars)); }
public override async void ItemSelected(UICollectionView collectionView, NSIndexPath indexPath) { DocViewService service = new DocViewService(AppDelegate.DatabaseContext); this.InvokeOnMainThread(delegate { LoadOverLayPopup(); }); Model.Document doc = await Task.Run(() => service.GetDocument(documentsList [indexPath.Row].ID, token)); if (doc != null) { if (doc.documentArray == null) { UIAlertView alert = new UIAlertView(@"Alert", @"The document is not available", null, NSBundle.MainBundle.LocalizedString("OK", "OK")); alert.Show(); } string documentPath = string.Empty; if (string.IsNullOrEmpty(doc.DocumentPath)) { documentPath = this.GenerateReport(doc); doc.DocumentPath = documentPath; service.UpdateDocumentItems(doc); } else { documentPath = doc.DocumentPath; } if (File.Exists(documentPath)) { var viewer = UIDocumentInteractionController.FromUrl(NSUrl.FromFilename(documentPath)); UIDocumentInteractionControllerDelegateDerived del = new UIDocumentInteractionControllerDelegateDerived(this); //del.doneWithPreview+=(informer, eventArgs)=>{btnFinalizeSave.Hidden = false; // btnEdit.Hidden = false;}; viewer.Delegate = del; viewer.PresentPreview(true); } this.InvokeOnMainThread(delegate { HideOverLay(); }); } else { UIAlertView alert = new UIAlertView(@"Alert", @"Entire pdf not available", null, NSBundle.MainBundle.LocalizedString("OK", "OK")); alert.Show(); } }
public bool LoadFromFile(Document document, string filename, SizeInches size) { bool validFile; try { System.Drawing.Image image = Imaging.LoadImageFromFile(filename); validFile = true; } catch(Exception ex) { string msg = ex.Message; validFile = false; } if(validFile) { Page myPage = new PageFromFile(filename, size); document.AddPage(myPage); } return validFile; }
public void SaveDocument(Document document, string filename, List<int> pageNumbers, bool append, bool compressImage, int compressionFactor, bool importNativePages, ResolutionDpi exportResolution) { IntPtr pdfDocument = LibPdfium.CreateNewDocument(); if(append && File.Exists(filename)) { IntPtr sourceDoc = LibPdfium.LoadDocument(filename); for(int i = 0; i < LibPdfium.GetPageCount(sourceDoc); i++) { LibPdfium.CopyPage(pdfDocument, sourceDoc, i + 1); } LibPdfium.CloseDocument(sourceDoc); } foreach(int num in pageNumbers) { // Get the current page from document Page page = document.GetPage(num); Image image = null; if(page is PageFromPdf) { PageFromPdf pageFromPdf = page as PageFromPdf; if(pageFromPdf.SingleImageMode) { image = pageFromPdf.GetSingleImage(); } else if(importNativePages) { pageFromPdf.ExportToPdfDocument(pdfDocument); } else { image = pageFromPdf.Render(exportResolution); } } else { image = page.GetSourceImage(); } if(image != null) { if(compressImage) { image = CompressImage(image, compressionFactor, exportResolution); } DrawPage(pdfDocument, page, image); } } // Save the document... LibPdfium.SaveDocument(pdfDocument, filename); }
public ListViewPage(Document doc, int index) { fPage = doc; fIndex = index; }
public static int DocumentAdd(Model.Document documentinfo) { return(DAL.Document.DocumentAdd(documentinfo)); }
public static int DocumentUpdate(Model.Document documentinfo) { return(DAL.Document.DocumentUpdate(documentinfo)); }