public int SaveAsXps(string fileName) { object doc; FileInfo fileInfo = new FileInfo(fileName); using (FileStream file = fileInfo.OpenRead()) { System.Windows.Markup.ParserContext context = new System.Windows.Markup.ParserContext(); context.BaseUri = new Uri(fileInfo.FullName, UriKind.Absolute); doc = System.Windows.Markup.XamlReader.Load(file, context); } if (!(doc is IDocumentPaginatorSource)) { Console.WriteLine("DocumentPaginatorSource expected"); return(-1); } using (Package container = Package.Open(fileName + ".xps", FileMode.Create)) { using (XpsDocument xpsDoc = new XpsDocument(container, CompressionOption.Maximum)) { xpsDoc.AddFixedDocumentSequence(); FixedDocumentSequence seq = xpsDoc.GetFixedDocumentSequence(); DocumentReference reference = new DocumentReference(); //reference.SetDocument(doc); seq.References.Add(reference); FixedDocument abc = new FixedDocument(); PageContent pagecnt = new PageContent(); abc.Pages.Add(pagecnt); XpsSerializationManager rsm = new XpsSerializationManager(new XpsPackagingPolicy(xpsDoc), false); xpsDoc.AddFixedDocumentSequence(); FixedDocumentSequence aaa = xpsDoc.GetFixedDocumentSequence(); DocumentPaginator paginator = ((IDocumentPaginatorSource)doc).DocumentPaginator; // 8 inch x 6 inch, with half inch margin //paginator = new DocumentPaginatorWrapper(paginator, new Size(21*96/2.54, 29.7*96/2.54), new Size(0*96/2.54, 0*96/2.54)); //PrintDialog ptdlg = new PrintDialog(); //ptdlg.ShowDialog(); //((IDocumentPaginatorSource)doc).DocumentPaginator.PageSize = new Size(ptdlg.PrintableAreaWidth, ptdlg.PrintableAreaHeight); //paginator = new DocumentPaginatorWrapper(paginator, new Size(ptdlg.PrintableAreaWidth, ptdlg.PrintableAreaHeight), new Size(0 * 96 / 2.54, 0 * 96 / 2.54)); rsm.SaveAsXaml(paginator); rsm.Commit(); xpsDoc.Close(); container.Close(); XpsDocument tempdoc = new XpsDocument(fileName + ".xps", FileAccess.Read); //viewer.Document = tempdoc.GetFixedDocumentSequence(); } } Console.WriteLine("{0} generated.", fileName + ".xps"); return(0); }
public static RTDocument PPT2RTDocument(string pptFilename) { //Pri2: Investigate where BasePath is and where we should be putting it in more depth. // Concerned that we're creating directories there that never get cleaned up... if (!Directory.Exists(tfc.BasePath)) { Directory.CreateDirectory(tfc.BasePath); } // Initialize PowerPoint app //ApplicationClass ppt = new ApplicationClass(); // Open the PPT file //Presentation presentation = ppt.Presentations.Open(pptFilename, MsoTriState.msoTrue, MsoTriState.msoTrue, MsoTriState.msoFalse); //Slides slides = presentation.Slides; XpsDocument xpsDoc = new XpsDocument(pptFilename, FileAccess.Read); FixedDocumentSequence docSeq = new FixedDocumentSequence(); docSeq = xpsDoc.GetFixedDocumentSequence(); DocumentPaginator paginator = docSeq.DocumentPaginator; int pages = paginator.PageCount; // Set up the document RTDocument rtDoc = new RTDocument(); rtDoc.Identifier = Guid.NewGuid(); //rtDoc.Metadata.Title = GetPresentationProperty(xpsDoc, "Title"); //rtDoc.Metadata.Creator = GetPresentationProperty(xpsDoc, "Author"); // Create shared MemoryStream to minimize mem usage MemoryStream ms = new MemoryStream(); //Iterate through the pages //int i = 0; //foreach(Slide s in slides) //{ // // Set the page properties // Page p = new Page(); // p.Identifier = Guid.NewGuid(); // p.Image = GetSlideImage(s, ms); // if (p.Image is Metafile) // { // p.MimeType = "image/x-wmf"; // } // if (p.Image is Bitmap) // { // p.MimeType = "image/png"; // } // rtDoc.Resources.Pages.Add(p.Identifier, p); // // TODO, slice in RegionBuilder code from Presenter work... // // Set the TOCNode properties for the page // TOCNode tn = new TOCNode(); // tn.Title = GetSlideTitle(s); // tn.Resource = p; // tn.ResourceIdentifier = p.Identifier; // //Pri2: Shouldn't this be a byte[] containing the PNG stream instead of a System.Drawing.Image? // tn.Thumbnail = RTDocumentHelper.GetThumbnailFromImage(p.Image); // rtDoc.Organization.TableOfContents.Add(tn); // i++; //} for (int pageNum = 0; pageNum != pages; ++pageNum) { using (DocumentPage docPage = paginator.GetPage(pageNum)) { Page p = new Page(); p.Identifier = Guid.NewGuid(); p.Image = GetSlideImage(docPage, ms); if (p.Image is Metafile) { p.MimeType = "image/x-wmf"; } if (p.Image is Bitmap) { p.MimeType = "image/png"; } rtDoc.Resources.Pages.Add(p.Identifier, p); // TODO, slice in RegionBuilder code from Presenter work... // Set the TOCNode properties for the page TOCNode tn = new TOCNode(); //tn.Title = GetSlideTitle(docPage); tn.Resource = p; tn.ResourceIdentifier = p.Identifier; //Pri2: Shouldn't this be a byte[] containing the PNG stream instead of a System.Drawing.Image? tn.Thumbnail = RTDocumentHelper.GetThumbnailFromImage(p.Image); rtDoc.Organization.TableOfContents.Add(tn); } } // Close PPT xpsDoc.Close(); //if (xpsDoc. == 0) //{ // ppt.Quit(); //} //ppt = null; tfc.Delete(); return(rtDoc); }
}// end:GetContentFolder() // --------------------------- OpenDocument --------------------------- /// <summary> /// Loads, displays, and enables user annotations /// a given XPS document file.</summary> /// <param name="filename"> /// The path and filename of the XPS document /// to load, display, and annotate.</param> /// <returns> /// true if the document loads successfully; otherwise false.</returns> public bool OpenDocument(string filename) { // Load an XPS document into a DocumentViewer // and enable user Annotations. _xpsDocumentPath = filename; _packageUri = new Uri(filename, UriKind.Absolute); try { _xpsDocument = new XpsDocument(filename, FileAccess.ReadWrite); } catch (System.UnauthorizedAccessException) { string msg = filename + "\n\nThe specified file is Read-Only which " + "prevents storing user annotations."; MessageBox.Show(msg, "Read-Only file", MessageBoxButton.OK, MessageBoxImage.Error); return(false); } // Get the document's PackageStore into which // new user annotations will be added and saved. _xpsPackage = PackageStore.GetPackage(_packageUri); if ((_xpsPackage == null) || (_xpsDocument == null)) { MessageBox.Show("Unable to get Package from file."); return(false); } // Get the FixedDocumentSequence from the open document. FixedDocumentSequence fds = _xpsDocument.GetFixedDocumentSequence(); if (fds == null) { string msg = filename + "\n\nThe document package within the specified " + "file does not contain a FixedDocumentSequence."; MessageBox.Show(msg, "Package Error"); return(false); } // Load the FixedDocumentSequence to the DocumentViewer control. docViewer.Document = fds; // Enable document menu controls. menuFileClose.IsEnabled = true; menuFilePrint.IsEnabled = true; menuViewAnnotations.IsEnabled = true; menuViewIncreaseZoom.IsEnabled = true; menuViewDecreaseZoom.IsEnabled = true; // Enable user annotations on the document. Uri fixedDocumentSeqUri = GetFixedDocumentSequenceUri(); _annotHelper.SetSource(_packageUri, fixedDocumentSeqUri); if (menuViewAnnotations.IsChecked) { _annotHelper.StartAnnotations(); } // Give the DocumentViewer focus. docViewer.Focus(); return(true); }// end:OpenDocument()
//</SnippetWriteToXpsWithFixedDocument> //<SnippetWriteToXpsWithFixedDocumentSequence> private void SaveMultipleFixedContentDocuments( XpsDocumentWriter xpsdw, FixedDocumentSequence fds) { // Write the FixedDocumentSequence as a collection of documents xpsdw.Write(fds); }
public override void WriteAsync(FixedDocumentSequence fixedDocumentSequence, PrintTicket printTicket);
public abstract void WriteAsync(FixedDocumentSequence fixedDocumentSequence, PrintTicket printTicket, object userState);
//------------------------------------------------------------------- // // Constructors // //------------------------------------------------------------------- #region Constructors /// <summary> /// Constructor /// </summary> internal FixedDocumentSequencePaginator(FixedDocumentSequence document) { _document = document; }
/// <summary> /// Write a single FixedDocumentSequence and close package /// </summary> public override void Write(FixedDocumentSequence fixedDocumentSequence, PrintTicket printTicket) { SerializeObjectTree(fixedDocumentSequence); }
/// <summary> /// Asynchronous Write a single FixedDocumentSequence and close package /// </summary> public override void WriteAsync(FixedDocumentSequence fixedDocumentSequence) { throw new NotSupportedException(); }
}// end:OnOpen() // --------------------------- OpenDocument --------------------------- /// <summary> /// Loads and displays a given XPS document file.</summary> /// <param name="filename"> /// The path and filename of the XPS document /// to load and display.</param> /// <returns> /// true if the document loads successfully; otherwise false.</returns> public bool OpenDocument(string filename) { // Save the document path and filename. _xpsDocumentPath = filename; // Extract the document filename without the path. _xpsDocumentName = filename.Remove(0, filename.LastIndexOf('\\')+1); _packageUri = new Uri(filename, UriKind.Absolute); try { _xpsDocument = new XpsDocument(filename, FileAccess.Read); } catch (System.IO.FileFormatException) { string msg = filename + "\n\nThe specified file " + "in not a valid unprotected XPS document.\n\n" + "The file is possibly encrypted with rights management. " + "Please see the RightsManagedPackageViewer\nsample that " + "shows how to access and view a rights managed XPS document."; MessageBox.Show(msg, "Invalid File Format", MessageBoxButton.OK, MessageBoxImage.Error); return false; } // Get the document's PackageStore into which // new user annotations will be added and saved. _xpsPackage = PackageStore.GetPackage(_packageUri); if ((_xpsPackage == null) || (_xpsDocument == null)) { MessageBox.Show("Unable to get Package from file."); return false; } // Get the FixedDocumentSequence from the open document. FixedDocumentSequence fds = _xpsDocument.GetFixedDocumentSequence(); if (fds == null) { string msg = filename + "\n\nThe document package within the specified " + "file does not contain a FixedDocumentSequence."; MessageBox.Show(msg, "Package Error"); return false; } // Load the FixedDocumentSequence to the DocumentViewer control. docViewer.Document = fds; // Enable document menu controls. menuFileClose.IsEnabled = true; menuFilePrint.IsEnabled = true; menuFileRights.IsEnabled = true; menuViewIncreaseZoom.IsEnabled = true; menuViewDecreaseZoom.IsEnabled = true; // Give the DocumentViewer focus. docViewer.Focus(); WriteStatus("Opened '" + _xpsDocumentName + "'"); WritePrompt("Click 'File | Rights...' to select an " + "eXtensible Rights Markup (XrML) permissions file."); return true; }// end:OpenDocument()
/// <summary> /// Write a single FixedDocumentSequence and close package /// </summary> public override void Write(FixedDocumentSequence fixedDocumentSequence) { Write(fixedDocumentSequence, null); }
private void SaveXpsDocumentWithFixedDocumentSequenceTo(string outputDirectory, FixedDocumentSequence fixedDocumentSequence) { using (var xpsDocument = new XpsDocument(outputDirectory, FileAccess.ReadWrite)) { XpsDocumentWriter xpsDocumentWriter = GetXpsDocumentWriterFor(xpsDocument); xpsDocumentWriter.Write(fixedDocumentSequence); } }
private IEnumerable <FixedDocument> GetFixedDocumentsFrom(ManagedXpsDocument xpsDocument) { FixedDocumentSequence fixedDocumentSequence = xpsDocument.GetFixedDocumentSequence(); return(fixedDocumentSequence.References.Select(r => r.GetDocument(true))); }
public PrintWindow(FixedDocumentSequence document) { _document = document; InitializeComponent(); PreviewD.Document = document; }
/// <summary> /// Asynchronous Write a single FixedDocumentSequence and close package /// </summary> public abstract void WriteAsync(FixedDocumentSequence fixedDocumentSequence);
/// <summary> /// Asynchronous Write a single FixedDocumentSequence and close package /// </summary> public override void WriteAsync(FixedDocumentSequence fixedDocumentSequence, PrintTicket printTicket, object userState) { throw new NotSupportedException(); }
public abstract void WriteAsync(FixedDocumentSequence fixedDocumentSequence, PrintTicket printTicket);
// ------------------ GetAnnotationDocumentPaginator ------------------ /// <summary> /// Returns a paginator for printing annotations.</summary> /// <param name="fds"> /// The FixedDocumentSequence containing /// the annotations to print.</param> /// <returns> /// An paginator for printing the document's annotations.</returns> public AnnotationDocumentPaginator GetAnnotationDocumentPaginator( FixedDocumentSequence fds) { return(new AnnotationDocumentPaginator( fds.DocumentPaginator, _annotStore)); }
// ---------------- PrintMultipleFixedContentDocuments ---------------- /// <summary> /// Synchronously prints multiple fixed documents from a given /// FixedDocumentSequence to a specified DocumentWriter.</summary> /// <param name="xpsdw"> /// The document writer to output to.</param> /// <param name="fds"> /// The fixed document sequence to print.</param> private void PrintMultipleFixedContentDocuments( XpsDocumentWriter xpsdw, FixedDocumentSequence fds) { xpsdw.Write(fds); // Write as a collection of documents. }
public void LoadDocument(XpsDocument xpsDocument) { FixedDocumentSequence fixedDocumentSequence = xpsDocument.GetFixedDocumentSequence(); this.DocumentViewerReports.Document = fixedDocumentSequence as IDocumentPaginatorSource; }
//private FlowDocument m_doc; private void bt_printClick(object sender, RoutedEventArgs e) { try { XmlDocument xmlDoc = new XmlDocument(); xmlDoc.Load("Result/config.xml"); XmlNode xn = xmlDoc.SelectSingleNode("items/szdy"); if (xn.InnerXml == "1") { if (this.dg_ShowUserinfor.SelectedItem != null) { User user = this.dg_ShowUserinfor.SelectedItem as User; str_userID = user.id; string sql = "select * from EHR_Arch_OldHerb where ID = '" + str_userID + "'"; DBhelp.writelog(sql); DataSet datat = DBhelp.GetDataSet(sql); int i = 0; string ID = DBhelp.ObjectToString(datat.Tables["Table"].Rows[i]["ID"]); string ARCHIVEID = DBhelp.ObjectToString(datat.Tables["Table"].Rows[i]["ARCHIVEID"]); string IDENTITYNO = DBhelp.ObjectToString(datat.Tables["Table"].Rows[i]["IDENTITYNO"]); string SERVICEID = DBhelp.ObjectToString(datat.Tables["Table"].Rows[i]["SERVICEID"]); string SERVICENAME = DBhelp.ObjectToString(datat.Tables["Table"].Rows[i]["SERVICENAME"]); string FULLNAME = DBhelp.ObjectToString(datat.Tables["Table"].Rows[i]["FULLNAME"]); string ISENERGETI = strTosnum33(DBhelp.ObjectToString(datat.Tables["Table"].Rows[i]["ISENERGETI"])); string ISTIRED = strTosnum33(DBhelp.ObjectToString(datat.Tables["Table"].Rows[i]["ISTIRED"])); string ISLOSEHEART = strTosnum33(DBhelp.ObjectToString(datat.Tables["Table"].Rows[i]["ISLOSEHEART"])); string ISDEEPVOICE = strTosnum33(DBhelp.ObjectToString(datat.Tables["Table"].Rows[i]["ISDEEPVOICE"])); string ISLISTLESS = strTosnum33(DBhelp.ObjectToString(datat.Tables["Table"].Rows[i]["ISLISTLESS"])); string ISJITTER = strTosnum33(DBhelp.ObjectToString(datat.Tables["Table"].Rows[i]["ISJITTER"])); string ISALONE = strTosnum33(DBhelp.ObjectToString(datat.Tables["Table"].Rows[i]["ISALONE"])); string ISSCARE = strTosnum33(DBhelp.ObjectToString(datat.Tables["Table"].Rows[i]["ISSCARE"])); string ISHEAVY = strTosnum34(DBhelp.ObjectToString(datat.Tables["Table"].Rows[i]["ISHEAVY"])); string ISEYEDRY = strTosnum33(DBhelp.ObjectToString(datat.Tables["Table"].Rows[i]["ISEYEDRY"])); string ISEXTRECOLD = strTosnum33(DBhelp.ObjectToString(datat.Tables["Table"].Rows[i]["ISEXTRECOLD"])); string ISAFAIDCOLD = strTosnum33(DBhelp.ObjectToString(datat.Tables["Table"].Rows[i]["ISAFAIDCOLD"])); string ISRESISTCOLD = strTosnum33(DBhelp.ObjectToString(datat.Tables["Table"].Rows[i]["ISRESISTCOLD"])); string ISCATCHCOLD = strTosnum35(DBhelp.ObjectToString(datat.Tables["Table"].Rows[i]["ISCATCHCOLD"])); string ISSNORTY = strTosnum33(DBhelp.ObjectToString(datat.Tables["Table"].Rows[i]["ISSNORTY"])); string ISSTERTOROUS = strTosnum33(DBhelp.ObjectToString(datat.Tables["Table"].Rows[i]["ISSTERTOROUS"])); string ISALLERGIC = strTosnum36(DBhelp.ObjectToString(datat.Tables["Table"].Rows[i]["ISALLERGIC"])); string ISHIVES = strTosnum33(DBhelp.ObjectToString(datat.Tables["Table"].Rows[i]["ISHIVES"])); string ISENDERMICBLOOD = strTosnum33(DBhelp.ObjectToString(datat.Tables["Table"].Rows[i]["ISENDERMICBLOOD"])); string ISSCORE = strTosnum33(DBhelp.ObjectToString(datat.Tables["Table"].Rows[i]["ISSCORE"])); string ISFEVERDRY = strTosnum33(DBhelp.ObjectToString(datat.Tables["Table"].Rows[i]["ISFEVERDRY"])); string ISBODYPAIN = strTosnum33(DBhelp.ObjectToString(datat.Tables["Table"].Rows[i]["ISBODYPAIN"])); string ISFACELIGHT = strTosnum33(DBhelp.ObjectToString(datat.Tables["Table"].Rows[i]["ISFACELIGHT"])); string ISFLECK = strTosnum33(DBhelp.ObjectToString(datat.Tables["Table"].Rows[i]["ISFLECK"])); string ISTETTER = strTosnum33(DBhelp.ObjectToString(datat.Tables["Table"].Rows[i]["ISTETTER"])); string ISLIKEDRINK = strTosnum33(DBhelp.ObjectToString(datat.Tables["Table"].Rows[i]["ISLIKEDRINK"])); string ISMOUTHBITTER = strTosnum33(DBhelp.ObjectToString(datat.Tables["Table"].Rows[i]["ISMOUTHBITTER"])); string IFFAT = strTosnum37(DBhelp.ObjectToString(datat.Tables["Table"].Rows[i]["IFFAT"])); string ISSCARECOLDFOOD = strTosnum33(DBhelp.ObjectToString(datat.Tables["Table"].Rows[i]["ISSCARECOLDFOOD"])); string ISSTOOLSTICK = strTosnum33(DBhelp.ObjectToString(datat.Tables["Table"].Rows[i]["ISSTOOLSTICK"])); string ISSTOOLDRY = strTosnum33(DBhelp.ObjectToString(datat.Tables["Table"].Rows[i]["ISSTOOLDRY"])); string ISLINGUAMASSIN = strTosnum33(DBhelp.ObjectToString(datat.Tables["Table"].Rows[i]["ISLINGUAMASSIN"])); string ISLINGUAVEIN = strTosnum33(DBhelp.ObjectToString(datat.Tables["Table"].Rows[i]["ISLINGUAVEIN"])); string PHYSIQUE_QXZ = DBhelp.ObjectToString(datat.Tables["Table"].Rows[i]["PHYSIQUE_QXZ"]); string PHYSIQUE_YANGXZ = DBhelp.ObjectToString(datat.Tables["Table"].Rows[i]["PHYSIQUE_YANGXZ"]); string PHYSIQUE_YINXZ = DBhelp.ObjectToString(datat.Tables["Table"].Rows[i]["PHYSIQUE_YINXZ"]); string PHYSIQUE_TSZ = DBhelp.ObjectToString(datat.Tables["Table"].Rows[i]["PHYSIQUE_TSZ"]); string PHYSIQUE_SRZ = DBhelp.ObjectToString(datat.Tables["Table"].Rows[i]["PHYSIQUE_SRZ"]); string PHYSIQUE_XYZ = DBhelp.ObjectToString(datat.Tables["Table"].Rows[i]["PHYSIQUE_XYZ"]); string PHYSIQUE_QYZ = DBhelp.ObjectToString(datat.Tables["Table"].Rows[i]["PHYSIQUE_QYZ"]); string PHYSIQUE_TBZ = DBhelp.ObjectToString(datat.Tables["Table"].Rows[i]["PHYSIQUE_TBZ"]); string PHYSIQUE_PHZ = DBhelp.ObjectToString(datat.Tables["Table"].Rows[i]["PHYSIQUE_PHZ"]); string REPORTDATE = DBhelp.ObjectToString(datat.Tables["Table"].Rows[i]["REPORTDATE"]); string REPORTDOC = DBhelp.ObjectToString(datat.Tables["Table"].Rows[i]["REPORTDOC"]); string STATUS = DBhelp.ObjectToString(datat.Tables["Table"].Rows[i]["STATUS"]); string CREATED_BY = DBhelp.ObjectToString(datat.Tables["Table"].Rows[i]["CREATED_BY"]); string CREATED_DATE = DBhelp.ObjectToString(datat.Tables["Table"].Rows[i]["CREATED_DATE"]); string UPDATED_BY = DBhelp.ObjectToString(datat.Tables["Table"].Rows[i]["UPDATED_BY"]); string UPDATED_DATE = DBhelp.ObjectToString(datat.Tables["Table"].Rows[i]["UPDATED_DATE"]); string DISABLED_BY = DBhelp.ObjectToString(datat.Tables["Table"].Rows[i]["DISABLED_BY"]); string DUNS = DBhelp.ObjectToString(datat.Tables["Table"].Rows[i]["DUNS"]); string DISABLED_DATE = DBhelp.ObjectToString(datat.Tables["Table"].Rows[i]["DISABLED_DATE"]); string QXZ_SCORE = DBhelp.ObjectToString(datat.Tables["Table"].Rows[i]["QXZ_SCORE"]); string YANGXZ_SCORE = DBhelp.ObjectToString(datat.Tables["Table"].Rows[i]["YANGXZ_SCORE"]); string YINXZ_SCORE = DBhelp.ObjectToString(datat.Tables["Table"].Rows[i]["YINXZ_SCORE"]); string TSZ_SCORE = DBhelp.ObjectToString(datat.Tables["Table"].Rows[i]["TSZ_SCORE"]); string SRZ_SCORE = DBhelp.ObjectToString(datat.Tables["Table"].Rows[i]["SRZ_SCORE"]); string XYZ_SCORE = DBhelp.ObjectToString(datat.Tables["Table"].Rows[i]["XYZ_SCORE"]); string QYZ_SCORE = DBhelp.ObjectToString(datat.Tables["Table"].Rows[i]["QYZ_SCORE"]); string TBZ_SCORE = DBhelp.ObjectToString(datat.Tables["Table"].Rows[i]["TBZ_SCORE"]); string PHZ_SCORE = DBhelp.ObjectToString(datat.Tables["Table"].Rows[i]["PHZ_SCORE"]); string QXZ_GUIDE = DBhelp.ObjectToString(datat.Tables["Table"].Rows[i]["QXZ_GUIDE"]); string YANGXZ_GUIDE = DBhelp.ObjectToString(datat.Tables["Table"].Rows[i]["YANGXZ_GUIDE"]); string YINXZ_GUIDE = DBhelp.ObjectToString(datat.Tables["Table"].Rows[i]["YINXZ_GUIDE"]); string TSZ_GUIDE = DBhelp.ObjectToString(datat.Tables["Table"].Rows[i]["TSZ_GUIDE"]); string SRZ_GUIDE = DBhelp.ObjectToString(datat.Tables["Table"].Rows[i]["SRZ_GUIDE"]); string XYZ_GUIDE = DBhelp.ObjectToString(datat.Tables["Table"].Rows[i]["XYZ_GUIDE"]); string QYZ_GUIDE = DBhelp.ObjectToString(datat.Tables["Table"].Rows[i]["QYZ_GUIDE"]); string TBZ_GUIDE = DBhelp.ObjectToString(datat.Tables["Table"].Rows[i]["TBZ_GUIDE"]); string PHZ_GUIDE = DBhelp.ObjectToString(datat.Tables["Table"].Rows[i]["PHZ_GUIDE"]); string QXZ_GUIDE_OTHER = DBhelp.ObjectToString(datat.Tables["Table"].Rows[i]["QXZ_GUIDE_OTHER"]); string YANGXZ_GUIDE_OTHER = DBhelp.ObjectToString(datat.Tables["Table"].Rows[i]["YANGXZ_GUIDE_OTHER"]); string YINXZ_GUIDE_OTHER = DBhelp.ObjectToString(datat.Tables["Table"].Rows[i]["YINXZ_GUIDE_OTHER"]); string TSZ_GUIDE_OTHER = DBhelp.ObjectToString(datat.Tables["Table"].Rows[i]["TSZ_GUIDE_OTHER"]); string SRZ_GUIDE_OTHER = DBhelp.ObjectToString(datat.Tables["Table"].Rows[i]["SRZ_GUIDE_OTHER"]); string XYZ_GUIDE_OTHER = DBhelp.ObjectToString(datat.Tables["Table"].Rows[i]["XYZ_GUIDE_OTHER"]); string QYZ_GUIDE_OTHER = DBhelp.ObjectToString(datat.Tables["Table"].Rows[i]["QYZ_GUIDE_OTHER"]); string TBZ_GUIDE_OTHER = DBhelp.ObjectToString(datat.Tables["Table"].Rows[i]["TBZ_GUIDE_OTHER"]); string PHZ_GUIDE_OTHER = DBhelp.ObjectToString(datat.Tables["Table"].Rows[i]["PHZ_GUIDE_OTHER"]); string sql1 = "select docname from EHR_His_doc where card_id = '" + REPORTDOC + "'"; DataSet doc = DBhelp.GetDataSet(sql1); string docname = DBhelp.ObjectToString(doc.Tables["Table"].Rows[0]["docname"]); DBhelp.writelog(docname); string str1 = ID + "$" + ARCHIVEID + "$" + IDENTITYNO + "$" + SERVICEID + "$" + SERVICENAME + "$" + FULLNAME + "$" + ISENERGETI + "$" + ISTIRED + "$" + ISLOSEHEART + "$" + ISDEEPVOICE + "$" + ISLISTLESS + "$" + ISJITTER + "$" + ISALONE + "$" + ISSCARE + "$" + ISHEAVY + "$" + ISEYEDRY + "$" + ISEXTRECOLD + "$" + ISAFAIDCOLD + "$" + ISRESISTCOLD + "$" + ISCATCHCOLD + "$" + ISSNORTY + "$" + ISSTERTOROUS + "$" + ISALLERGIC + "$" + ISHIVES + "$" + ISENDERMICBLOOD + "$" + ISSCORE + "$" + ISFEVERDRY + "$" + ISBODYPAIN + "$" + ISFACELIGHT; string str2 = ISFLECK + "$" + ISTETTER + "$" + ISLIKEDRINK + "$" + ISMOUTHBITTER + "$" + IFFAT + "$" + ISSCARECOLDFOOD + "$" + ISSTOOLSTICK + "$" + ISSTOOLDRY + "$" + ISLINGUAMASSIN + "$" + ISLINGUAVEIN + "$" + QXZ_SCORE + "$" + YANGXZ_SCORE + "$" + YINXZ_SCORE + "$" + TSZ_SCORE + "$" + SRZ_SCORE + "$" + XYZ_SCORE + "$" + QYZ_SCORE + "$" + TBZ_SCORE + "$" + PHZ_SCORE + "$" + REPORTDATE + "$" + docname + "$" + PHYSIQUE_QXZ + "$" + PHYSIQUE_YANGXZ + "$" + PHYSIQUE_YINXZ + "$" + PHYSIQUE_TSZ + "$" + PHYSIQUE_SRZ + "$" + PHYSIQUE_XYZ + "$" + PHYSIQUE_QYZ + "$" + PHYSIQUE_TBZ + "$" + PHYSIQUE_PHZ; ; //DBhelp.writelog(str1); //DBhelp.writelog(str2); // m_doc = LoadDocumentAndRender("OrderDocument.xaml", tabPage); //OrderDocument orderDoc = (OrderDocument)m_doc; //string strPath = FileHelper.SaveXPS(m_doc, false, "w2"); //XpsDocument xpsDocument = new XpsDocument(strPath, FileAccess.Read); //FixedDocumentSequence fixedDocSeq = xpsDocument.GetFixedDocumentSequence(); System.Windows.Controls.PrintDialog dialog = new System.Windows.Controls.PrintDialog(); dialog.PrintQueue = LocalPrintServer.GetDefaultPrintQueue(); //dialog.PrintDocument(fixedDocSeq.DocumentPaginator, "Test print"); //xpsDocument.Close(); //string qustionstrs1 = "201605186110240000202$612525195001181417$58$男$15463216531$苗留成$1$1$1$1$1$1$1$1$1$1$1$1$1$1$1$1$1$1$1$1$1$1$1"; H_Print_trouble h_pr = new H_Print_trouble(str1); string strPath1 = FileHelper.SaveXPS1(h_pr.printArea, false, "w2"); XpsDocument xpsDocument1 = new XpsDocument(strPath1, FileAccess.Read); FixedDocumentSequence fixedDocSeq1 = xpsDocument1.GetFixedDocumentSequence(); System.Windows.Controls.PrintDialog dialog1 = new System.Windows.Controls.PrintDialog(); dialog1.PrintQueue = LocalPrintServer.GetDefaultPrintQueue(); dialog1.PrintDocument(fixedDocSeq1.DocumentPaginator, FULLNAME + ""); xpsDocument1.Close(); //string qustionstrs2 = "1$1$1$1$1$1$1$1$1$1$4$4$4$4$4$4$4$4$21$2017/4/17$612525195001181417$$$$$SX0088_1$$$$SX0401_1"; H_Print_trouble1 h_pr1 = new H_Print_trouble1(str2); string strPath2 = FileHelper.SaveXPS1(h_pr1.p2, false, "w2"); XpsDocument xpsDocument2 = new XpsDocument(strPath2, FileAccess.Read); FixedDocumentSequence fixedDocSeq2 = xpsDocument2.GetFixedDocumentSequence(); System.Windows.Controls.PrintDialog dialog2 = new System.Windows.Controls.PrintDialog(); dialog2.PrintQueue = LocalPrintServer.GetDefaultPrintQueue(); dialog2.PrintDocument(fixedDocSeq2.DocumentPaginator, FULLNAME + "_2"); xpsDocument2.Close(); H_Print_trouble arv = new H_Print_trouble(str1); string strPath = FileHelper.SaveXPS1(arv.printArea, false, "w2"); XpsDocument xpsDocument = new XpsDocument(strPath, FileAccess.Read); FixedDocumentSequence fixedDocSeq = xpsDocument.GetFixedDocumentSequence(); RenderTargetBitmap targetBitmap = new RenderTargetBitmap(1240, 1750, 150d, 150d, PixelFormats.Pbgra32); targetBitmap.Render(arv.printArea); PngBitmapEncoder encoder = new PngBitmapEncoder(); encoder.Frames.Add(BitmapFrame.Create(targetBitmap)); FileStream fs = File.Open(System.AppDomain.CurrentDomain.BaseDirectory + @"\Result\" + FULLNAME + "_1.png", FileMode.Create); encoder.Save(fs); fs.Close(); xpsDocument.Close(); H_Print_trouble1 arv1 = new H_Print_trouble1(str2); strPath = FileHelper.SaveXPS1(arv1.p2, false, "w2"); xpsDocument = new XpsDocument(strPath, FileAccess.Read); fixedDocSeq = xpsDocument.GetFixedDocumentSequence(); targetBitmap = new RenderTargetBitmap(1240, 1750, 150d, 150d, PixelFormats.Pbgra32); targetBitmap.Render(arv1.p2); encoder = new PngBitmapEncoder(); encoder.Frames.Add(BitmapFrame.Create(targetBitmap)); fs = File.Open(System.AppDomain.CurrentDomain.BaseDirectory + @"\Result\" + FULLNAME + "_2.png", FileMode.Create); encoder.Save(fs); fs.Close(); xpsDocument.Close(); } else { MessageBox.Show("请选择要打印人员!!"); } } //IsUserInforShowPrint = false ; } catch (Exception ex) { MessageBox.Show(ex.Message); } }
}// end:OnOpen() //<SnippetRmPkgViewOpenDoc> // --------------------------- OpenDocument --------------------------- /// <summary> /// Loads and displays a given XPS document file.</summary> /// <param name="filename"> /// The path and file name of the XPS /// document to load and display.</param> /// <returns> /// true if the document loads successfully; otherwise false.</returns> public bool OpenDocument(string xpsFile) { // Check to see if the document is encrypted. // If encrypted, use OpenEncryptedDocument(). if (EncryptedPackageEnvelope.IsEncryptedPackageEnvelope(xpsFile)) { return(OpenEncryptedDocument(xpsFile)); } // Document is not encrypted, open normally. ShowStatus("Opening '" + Filename(xpsFile) + "'"); _packageUri = new Uri(xpsFile, UriKind.Absolute); try { _xpsDocument = new XpsDocument(xpsFile, FileAccess.Read); } catch (System.IO.FileFormatException ex) { MessageBox.Show(xpsFile + "\n\nThe file " + "is not a valid XPS document.\n\n" + "Exception: " + ex.Message + "\n\n" + ex.GetType().ToString() + "\n\n" + ex.StackTrace, "Invalid File Format", MessageBoxButton.OK, MessageBoxImage.Error); return(false); } // Get the document's PackageStore into which // new user annotations will be added and saved. _xpsPackage = PackageStore.GetPackage(_packageUri); if ((_xpsPackage == null) || (_xpsDocument == null)) { MessageBox.Show("Unable to get Package from file."); return(false); } // Get the FixedDocumentSequence from the open document. FixedDocumentSequence fds = _xpsDocument.GetFixedDocumentSequence(); if (fds == null) { MessageBox.Show(xpsFile + "\n\nThe document package within " + "the specified file does not contain a " + "FixedDocumentSequence.", "Package Error"); return(false); } // Load the FixedDocumentSequence to the DocumentViewer control. DocViewer.Document = fds; // Enable document menu controls. menuFileClose.IsEnabled = true; menuFilePrint.IsEnabled = true; menuViewIncreaseZoom.IsEnabled = true; menuViewDecreaseZoom.IsEnabled = true; // Give the DocumentViewer focus. docViewer.Focus(); this.Title = "RightsManagedPackageViewer SDK Sample - " + Filename(xpsFile); return(true); }// end:OpenDocument()
public override void WriteAsync(FixedDocumentSequence fixedDocumentSequence);
private void Window_Closing(object sender, System.ComponentModel.CancelEventArgs e) { _document = null; }
public override void WriteAsync(FixedDocumentSequence fixedDocumentSequence, PrintTicket printTicket, object userSuppliedState);
public new FixedDocumentSequence GetFixedDocumentSequence() { FixedDocumentSequence fixedDocumentSequence = base.GetFixedDocumentSequence(); return(fixedDocumentSequence ?? new FixedDocumentSequence()); }