// POST: api/Annotations public void Post([FromBody]Annotations value) { DocumentData documentData = new DocumentData(); documentData.UpdateAnnotation(Utility.GetUserName(), value.Data); string s1 = value.Data; }
// GET: api/RemovePage/5 public HttpResponseMessage Get(string id) { PDFNet.Initialize("CT Orthopaedic Specialists(ct-ortho.com):ENTCPU:1::W:AMS(20160714):DF4FD2223CBF58B9128E100F400DD2BC2BFD701DC22C3C2E6D83F6B6F5C7"); PDFDoc newDocument = new PDFDoc(); string[] pagesToDelete = id.Split(','); DocumentData documentData = new DocumentData(); int pageCount = 0; string pathToCurrentPdfFile = documentData.GetCurrentDocumentPathPDF(Utility.GetUserName()); string pathToCurrentPdfFileTemp = pathToCurrentPdfFile.Replace(".pdf", "temp.pdf"); string pathToCurrentXodFile = documentData.GetCurrentDocumentPathXOD(Utility.GetUserName()); PDFDoc removePagesFromDocument = new PDFDoc(pathToCurrentPdfFile); pageCount = removePagesFromDocument.GetPageCount(); for (int i = 1; i < pageCount; i++) { try { if (int.Parse(pagesToDelete[0]) == i) { PageIterator itr = removePagesFromDocument.GetPageIterator(i); removePagesFromDocument.PageRemove(itr); } else if (int.Parse(pagesToDelete[1]) == i) { PageIterator itr = removePagesFromDocument.GetPageIterator(i); removePagesFromDocument.PageRemove(itr); } else if (int.Parse(pagesToDelete[2]) == i) { PageIterator itr = removePagesFromDocument.GetPageIterator(i); removePagesFromDocument.PageRemove(itr); } else if (int.Parse(pagesToDelete[3]) == i) { PageIterator itr = removePagesFromDocument.GetPageIterator(i); removePagesFromDocument.PageRemove(itr); } else if (int.Parse(pagesToDelete[4]) == i) { PageIterator itr = removePagesFromDocument.GetPageIterator(i); removePagesFromDocument.PageRemove(itr); } else if (int.Parse(pagesToDelete[5]) == i) { PageIterator itr = removePagesFromDocument.GetPageIterator(i); removePagesFromDocument.PageRemove(itr); } } catch { } } ////PDFDoc documenToAdd = new PDFDoc(ConfigurationValues.OutboundFaxDirectory + "\\" + Utility.GetUserName() + "\\" + documents[0]); //PageIterator itr = removePagesFromDocument.GetPageIterator(); //for (; itr.HasNext(); itr.Next()) //{ // try // { // pdftron.PDF.Page page = itr.Current(); // newDocument.PageInsert(newDocument.GetPageIterator(), page); // } // catch (Exception er) // { // string s1 = er.ToString(); // } //} //try //{ // File.Delete(pathToCurrentXodFile); //} //catch { } File.Create(pathToCurrentXodFile).Dispose(); removePagesFromDocument.Save(pathToCurrentPdfFileTemp, 0); //newDocument.Save(pathToCurrentPdfFileTemp, 0); pdftron.PDF.Convert.ToXod(pathToCurrentPdfFileTemp, pathToCurrentXodFile); HttpResponseMessage result = new HttpResponseMessage(HttpStatusCode.OK); var stream = new FileStream(pathToCurrentXodFile, FileMode.Open); result.Content = new StreamContent(stream); result.Content.Headers.ContentType = new MediaTypeHeaderValue("application/octet-stream"); result.Content.Headers.ContentDisposition = new ContentDispositionHeaderValue("attachment") { FileName = ConfigurationValues.XodFileName }; return result; }
// GET: api/Annotations public HttpResponseMessage Get() { DocumentData documentData = new DocumentData(); string xmlContent = documentData.GetAnnotation(Utility.GetUserName()); return new HttpResponseMessage() { Content = new StringContent(xmlContent, Encoding.UTF8, "application/xml") }; }
public HttpResponseMessage Get(string id) { string xodFileName = Guid.NewGuid().ToString() + ".xod"; string pdfFileName = xodFileName.Replace(".xod", ".pdf"); string filePathXod = ConfigurationValues.PathToXodFile + xodFileName; string filePathPdf = ConfigurationValues.PathToXodFile + pdfFileName; PDFNet.Initialize("CT Orthopaedic Specialists(ct-ortho.com):ENTCPU:1::W:AMS(20160714):DF4FD2223CBF58B9128E100F400DD2BC2BFD701DC22C3C2E6D83F6B6F5C7"); PDFDoc newDocument = new PDFDoc(); if (string.IsNullOrEmpty(id)) { try { File.Delete(filePathXod); } catch { } File.Create(filePathXod).Dispose(); HttpResponseMessage result = new HttpResponseMessage(HttpStatusCode.OK); var stream = new FileStream(filePathXod, FileMode.Open); result.Content = new StreamContent(stream); result.Content.Headers.ContentType = new MediaTypeHeaderValue("application/octet-stream"); result.Content.Headers.ContentDisposition = new ContentDispositionHeaderValue("attachment") { FileName = ConfigurationValues.XodFileName }; return result; } else { string[] documents = id.Split('~'); for (int i = 0; i < documents.Length - 1; i++) { PDFDoc documenToAdd = new PDFDoc(ConfigurationValues.OutboundFaxDirectory + "\\" + Utility.GetUserName() + "\\" + documents[0]); PageIterator itr = documenToAdd.GetPageIterator(); for (; itr.HasNext(); itr.Next()) { try { pdftron.PDF.Page page = itr.Current(); newDocument.PageInsert(newDocument.GetPageIterator(itr.GetPageNumber()), page); } catch (Exception er) { string s1 = er.ToString(); } } } try { File.Delete(filePathXod); } catch { } DocumentData documentData = new DocumentData(); documentData.AddUpdateCurrentDocument(Utility.GetUserName(), filePathXod, filePathPdf); File.Create(filePathXod).Dispose(); newDocument.Save(filePathPdf, 0); pdftron.PDF.Convert.ToXod(newDocument, filePathXod); HttpResponseMessage result = new HttpResponseMessage(HttpStatusCode.OK); var stream = new FileStream(filePathXod, FileMode.Open); result.Content = new StreamContent(stream); result.Content.Headers.ContentType = new MediaTypeHeaderValue("application/octet-stream"); result.Content.Headers.ContentDisposition = new ContentDispositionHeaderValue("attachment") { FileName = ConfigurationValues.XodFileName }; return result; } }