static void Main(string[] args) { var p = new PaperSize(); string text = "显示A4纸宽度"; string text2 = "显示A4纸宽度"; Console.WriteLine(text); Console.WriteLine("A4纸宽{0}厘米",p.Getwidth(PaperTest.PaperSize.PaperMode.A4,PaperSize.SizeMode.Cm)); Console.WriteLine(text2); Console.WriteLine("A4纸长{0}厘米",p.Getlenght(PaperSize.PaperMode.A4,PaperSize.SizeMode.Cm)); Console.ReadKey(true); }
private static int[] paperDimensions(PaperSize paperSize) { switch(paperSize) { case PaperSize.A4: return new int[] { 11906, 16838 }; case PaperSize.Letter: return new int[] { 15840, 12240 }; case PaperSize.A3: return new int[] { 16838, 23811 }; default: throw new Exception("Unknow paper size."); } }
public static int paperHeightInTwip(PaperSize paperSize, PaperOrientation orientation) { int[] d = paperDimensions(paperSize); if (orientation == PaperOrientation.Portrait) { if (d[0] < d[1]) { return d[1]; } else { return d[0]; } } else { // landscape if (d[0] < d[1]) { return d[0]; } else { return d[1]; } } }
public RtfDocument(PaperSize paper, PaperOrientation orientation, Lcid lcid) { _paper = paper; _orientation = orientation; _margins = new Margins(); if (_orientation == PaperOrientation.Portrait) { _margins[Direction.Top] = DefaultValue.MarginSmall; _margins[Direction.Right] = DefaultValue.MarginLarge; _margins[Direction.Bottom] = DefaultValue.MarginSmall; _margins[Direction.Left] = DefaultValue.MarginLarge; } else { // landscape _margins[Direction.Top] = DefaultValue.MarginLarge; _margins[Direction.Right] = DefaultValue.MarginSmall; _margins[Direction.Bottom] = DefaultValue.MarginLarge; _margins[Direction.Left] = DefaultValue.MarginSmall; } _lcid = lcid; _fontTable = new List<string>(); _fontTable.Add(DefaultValue.Font); // default font _colorTable = new List<Color>(); _colorTable.Add(new Color()); // default color _header = null; _footer = null; }
private void tambah_antrian(object sender, RoutedEventArgs e) { if (!string.IsNullOrWhiteSpace(txtIdPasien.Text) && !string.IsNullOrEmpty(txtIdPasien.Text) && cbPoliklinik.SelectedIndex != 0) { var cbp = (ComboboxPairs)cbPoliklinik.SelectedItem; var policode = cbp.nama_poliklinik; var norm = txtIdPasien.Text; var no_urut = 0; var cmd = new DBCommand(conn); if (cmd.CountRmPasienExists(norm) == 1) { var last = cmd.GetLastNoUrut(policode); if (last == 0) { no_urut = 1; } else { no_urut = last + 1; } this.no_urut = no_urut; poli = cbp.kode_poliklinik; if (cmd.InsertAntrian(norm, no_urut, policode)) { MessageBox.Show("Pasien berhasil didaftarkan.\nNomor Antri: " + no_urut, "Informasi", MessageBoxButton.OK, MessageBoxImage.Information); txtIdPasien.Text = ""; cbPoliklinik.SelectedIndex = 0; try { sck.Send(Encoding.ASCII.GetBytes("Update")); } catch (Exception) { } var pd = new PrintDocument(); var ps = new PaperSize("", 300, 540); pd.PrintPage += Pd_PrintPage; pd.PrintController = new StandardPrintController(); pd.DefaultPageSettings.Margins.Left = 0; pd.DefaultPageSettings.Margins.Right = 0; pd.DefaultPageSettings.Margins.Top = 0; pd.DefaultPageSettings.Margins.Bottom = 0; pd.DefaultPageSettings.PaperSize = ps; pd.Print(); } else { MessageBox.Show("Pasien gagal didaftarkan.", "Informasi", MessageBoxButton.OK, MessageBoxImage.Information); } } else { MessageBox.Show("Rekam medis pasien belum teraftar, periksa kembali data pasien.", "Perhatian", MessageBoxButton.OK, MessageBoxImage.Warning); } } else { MessageBox.Show("Isikan data dengan benar, pastikan semua data telah benar.", "Perhatian", MessageBoxButton.OK, MessageBoxImage.Warning); } }
public async Task SavedSearchesProperties() { using (var service = await SdkHelper.CreateService()) { SavedSearchCollection savedSearches = service.SavedSearches; await savedSearches.GetAllAsync(); // Iterate saved searches and make sure we can read them foreach (SavedSearch savedSearch in savedSearches) { string dummyString; bool dummyBool; //DateTime dummyDateTime; int dummyInt; // Resource properties //dummyString = savedSearch.Name; dummyString = savedSearch.Name; //dummyString = savedSearch.Path; // SavedSearch properties get dummyString = savedSearch.Actions.Email.AuthPassword; dummyString = savedSearch.Actions.Email.AuthUsername; dummyBool = savedSearch.Actions.Email.SendResults; dummyString = savedSearch.Actions.Email.Bcc; dummyString = savedSearch.Actions.Email.CC; dummyString = savedSearch.Actions.Email.Command; EmailFormat emailFormat = savedSearch.Actions.Email.Format; dummyBool = savedSearch.Actions.Email.Inline; dummyString = savedSearch.Actions.Email.MailServer; dummyInt = savedSearch.Actions.Email.MaxResults; dummyString = savedSearch.Actions.Email.MaxTime; PaperOrientation paperOrientation = savedSearch.Actions.Email.ReportPaperOrientation; PaperSize paperSize = savedSearch.Actions.Email.ReportPaperSize; dummyBool = savedSearch.Actions.Email.ReportServerEnabled; //dummyString = savedSearch.Actions.Email.ReportServerUrl; dummyBool = savedSearch.Actions.Email.SendPdf; dummyBool = savedSearch.Actions.Email.SendResults; dummyString = savedSearch.Actions.Email.Subject; dummyString = savedSearch.Actions.Email.To; dummyBool = savedSearch.Actions.Email.TrackAlert; dummyString = savedSearch.Actions.Email.Ttl; dummyBool = savedSearch.Actions.Email.UseSsl; dummyBool = savedSearch.Actions.Email.UseTls; dummyBool = savedSearch.Actions.Email.WidthSortColumns; dummyString = savedSearch.Actions.PopulateLookup.Command; dummyString = savedSearch.Actions.PopulateLookup.Destination; dummyString = savedSearch.Actions.PopulateLookup.Hostname; dummyInt = savedSearch.Actions.PopulateLookup.MaxResults; dummyString = savedSearch.Actions.PopulateLookup.MaxTime; dummyBool = savedSearch.Actions.PopulateLookup.TrackAlert; dummyString = savedSearch.Actions.PopulateLookup.Ttl; dummyString = savedSearch.Actions.Rss.Command; //dummyString = savedSearch.Actions.Rss.Hostname; dummyInt = savedSearch.Actions.Rss.MaxResults; dummyString = savedSearch.Actions.Rss.MaxTime; dummyBool = savedSearch.Actions.Rss.TrackAlert; dummyString = savedSearch.Actions.Rss.Ttl; SavedSearch.ActionsAdapter.ScriptAdapter scriptT = savedSearch.Actions.Script; dummyString = scriptT.FileName; dummyString = scriptT.Hostname; dummyInt = scriptT.MaxResults; dummyString = scriptT.MaxTime; dummyBool = scriptT.TrackAlert; dummyString = scriptT.Ttl; dummyString = savedSearch.Actions.SummaryIndex.Name; dummyString = savedSearch.Actions.SummaryIndex.Command; //dummyString = savedSearch.Actions.SummaryIndex.Hostname; dummyBool = savedSearch.Actions.SummaryIndex.Inline; dummyInt = savedSearch.Actions.SummaryIndex.MaxResults; dummyString = savedSearch.Actions.SummaryIndex.MaxTime; dummyBool = savedSearch.Actions.SummaryIndex.TrackAlert; dummyString = savedSearch.Actions.SummaryIndex.Ttl; dummyBool = savedSearch.Alert.DigestMode; dummyString = savedSearch.Alert.Expires; AlertSeverity alertSeverity = savedSearch.Alert.Severity; SavedSearch.AlertAdapter.SuppressAdapter suppress = savedSearch.Alert.Suppress; dummyString = suppress.Fields; dummyString = suppress.Period; AlertTrack track = savedSearch.Alert.Track; AlertComparator comparator = savedSearch.Alert.Comparator; dummyString = savedSearch.Alert.Condition; dummyString = savedSearch.Alert.Threshold; AlertType alertType = savedSearch.Alert.AlertType; dummyString = savedSearch.CronSchedule; dummyString = savedSearch.Description; dummyInt = savedSearch.Dispatch.Buckets; dummyString = savedSearch.Dispatch.EarliestTime; //dummyString = savedSearch.Dispatch.LatestTime; dummyBool = savedSearch.Dispatch.Lookups; dummyInt = savedSearch.Dispatch.MaxCount; dummyInt = savedSearch.Dispatch.MaxTime; dummyInt = savedSearch.Dispatch.ReduceFreq; dummyBool = savedSearch.Dispatch.RealTimeBackfill; dummyBool = savedSearch.Dispatch.SpawnProcess; dummyString = savedSearch.Dispatch.TimeFormat; dummyString = savedSearch.Dispatch.Ttl; SavedSearch.DisplayAdapter display = savedSearch.Display; dummyInt = savedSearch.MaxConcurrent; //dummyDateTime = savedSearch.NextScheduledTime; dummyString = savedSearch.QualifiedSearch; dummyBool = savedSearch.RealTimeSchedule; dummyString = savedSearch.Request.UIDispatchApp; dummyString = savedSearch.Request.UIDispatchView; dummyBool = savedSearch.RestartOnSearchPeerAdd; dummyBool = savedSearch.RunOnStartup; dummyString = savedSearch.Search; //dummyString = savedSearch.Vsid; dummyBool = savedSearch.Actions.Email.IsEnabled; dummyBool = savedSearch.Actions.PopulateLookup.IsEnabled; dummyBool = savedSearch.Actions.Rss.IsEnabled; //dummyBool = savedSearch.IsActionScript; dummyBool = savedSearch.Actions.SummaryIndex.IsEnabled; dummyBool = savedSearch.IsDisabled; dummyBool = savedSearch.IsScheduled; dummyBool = savedSearch.IsVisible; } for (int i = 0; i < savedSearches.Count; i++) { SavedSearch savedSearch = savedSearches[i]; string dummyString; bool dummyBool; //DateTime dummyDateTime; int dummyInt; // Resource properties //dummyString = savedSearch.Name; dummyString = savedSearch.Name; //dummyString = savedSearch.Path; // SavedSearch properties get dummyString = savedSearch.Actions.Email.AuthPassword; dummyString = savedSearch.Actions.Email.AuthUsername; dummyBool = savedSearch.Actions.Email.SendResults; dummyString = savedSearch.Actions.Email.Bcc; dummyString = savedSearch.Actions.Email.CC; dummyString = savedSearch.Actions.Email.Command; EmailFormat emailFormat = savedSearch.Actions.Email.Format; dummyBool = savedSearch.Actions.Email.Inline; dummyString = savedSearch.Actions.Email.MailServer; dummyInt = savedSearch.Actions.Email.MaxResults; dummyString = savedSearch.Actions.Email.MaxTime; PaperOrientation paperOrientation = savedSearch.Actions.Email.ReportPaperOrientation; PaperSize paperSize = savedSearch.Actions.Email.ReportPaperSize; dummyBool = savedSearch.Actions.Email.ReportServerEnabled; //dummyString = savedSearch.Actions.Email.ReportServerUrl; dummyBool = savedSearch.Actions.Email.SendPdf; dummyBool = savedSearch.Actions.Email.SendResults; dummyString = savedSearch.Actions.Email.Subject; dummyString = savedSearch.Actions.Email.To; dummyBool = savedSearch.Actions.Email.TrackAlert; dummyString = savedSearch.Actions.Email.Ttl; dummyBool = savedSearch.Actions.Email.UseSsl; dummyBool = savedSearch.Actions.Email.UseTls; dummyBool = savedSearch.Actions.Email.WidthSortColumns; dummyString = savedSearch.Actions.PopulateLookup.Command; dummyString = savedSearch.Actions.PopulateLookup.Destination; dummyString = savedSearch.Actions.PopulateLookup.Hostname; dummyInt = savedSearch.Actions.PopulateLookup.MaxResults; dummyString = savedSearch.Actions.PopulateLookup.MaxTime; dummyBool = savedSearch.Actions.PopulateLookup.TrackAlert; dummyString = savedSearch.Actions.PopulateLookup.Ttl; dummyString = savedSearch.Actions.Rss.Command; //dummyString = savedSearch.Actions.Rss.Hostname; dummyInt = savedSearch.Actions.Rss.MaxResults; dummyString = savedSearch.Actions.Rss.MaxTime; dummyBool = savedSearch.Actions.Rss.TrackAlert; dummyString = savedSearch.Actions.Rss.Ttl; SavedSearch.ActionsAdapter.ScriptAdapter script = savedSearch.Actions.Script; dummyString = script.FileName; dummyString = script.Hostname; dummyInt = script.MaxResults; dummyString = script.MaxTime; dummyBool = script.TrackAlert; dummyString = script.Ttl; dummyString = savedSearch.Actions.SummaryIndex.Name; dummyString = savedSearch.Actions.SummaryIndex.Command; //dummyString = savedSearch.Actions.SummaryIndex.Hostname; dummyBool = savedSearch.Actions.SummaryIndex.Inline; dummyInt = savedSearch.Actions.SummaryIndex.MaxResults; dummyString = savedSearch.Actions.SummaryIndex.MaxTime; dummyBool = savedSearch.Actions.SummaryIndex.TrackAlert; dummyString = savedSearch.Actions.SummaryIndex.Ttl; dummyBool = savedSearch.Alert.DigestMode; dummyString = savedSearch.Alert.Expires; AlertSeverity alertSeverity = savedSearch.Alert.Severity; SavedSearch.AlertAdapter.SuppressAdapter suppress = savedSearch.Alert.Suppress; dummyString = suppress.Fields; dummyString = suppress.Period; AlertTrack track = savedSearch.Alert.Track; AlertComparator comparator = savedSearch.Alert.Comparator; dummyString = savedSearch.Alert.Condition; dummyString = savedSearch.Alert.Threshold; AlertType alertType = savedSearch.Alert.AlertType; dummyString = savedSearch.CronSchedule; dummyString = savedSearch.Description; dummyInt = savedSearch.Dispatch.Buckets; dummyString = savedSearch.Dispatch.EarliestTime; //dummyString = savedSearch.Dispatch.LatestTime; dummyBool = savedSearch.Dispatch.Lookups; dummyInt = savedSearch.Dispatch.MaxCount; dummyInt = savedSearch.Dispatch.MaxTime; dummyInt = savedSearch.Dispatch.ReduceFreq; dummyBool = savedSearch.Dispatch.RealTimeBackfill; dummyBool = savedSearch.Dispatch.SpawnProcess; dummyString = savedSearch.Dispatch.TimeFormat; dummyString = savedSearch.Dispatch.Ttl; SavedSearch.DisplayAdapter display = savedSearch.Display; dummyInt = savedSearch.MaxConcurrent; //dummyDateTime = savedSearch.NextScheduledTime; dummyString = savedSearch.QualifiedSearch; dummyBool = savedSearch.RealTimeSchedule; dummyString = savedSearch.Request.UIDispatchApp; dummyString = savedSearch.Request.UIDispatchView; dummyBool = savedSearch.RestartOnSearchPeerAdd; dummyBool = savedSearch.RunOnStartup; dummyString = savedSearch.Search; //dummyString = savedSearch.Vsid; dummyBool = savedSearch.Actions.Email.IsEnabled; dummyBool = savedSearch.Actions.PopulateLookup.IsEnabled; dummyBool = savedSearch.Actions.Rss.IsEnabled; //dummyBool = savedSearch.IsActionScript; dummyBool = savedSearch.Actions.SummaryIndex.IsEnabled; dummyBool = savedSearch.IsDisabled; dummyBool = savedSearch.IsScheduled; dummyBool = savedSearch.IsVisible; } } }
Stream(ArrayList data, PaperSize paperSize) { data.Add(new Snoop.Data.ClassSeparator(typeof(PaperSize))); data.Add(new Snoop.Data.String("Name", paperSize.Name)); }
public M_V4_printCartonSlip() { InitializeComponent(); this.c = new DbConnect(); //Load Data //Create drop-down lists var dataSource = new List <string>(); DataTable d = c.getQC('f'); for (int i = 0; i < d.Rows.Count; i++) { dataSource.Add(d.Rows[i][0].ToString()); } this.fiscalCombobox.DataSource = dataSource; this.fiscalCombobox.DisplayMember = "Financial Year"; this.fiscalCombobox.DropDownStyle = ComboBoxStyle.DropDownList;//Create a drop-down list this.fiscalCombobox.AutoCompleteSource = AutoCompleteSource.ListItems; this.fiscalCombobox.AutoCompleteMode = AutoCompleteMode.SuggestAppend; this.fiscalCombobox.SelectedIndex = this.fiscalCombobox.FindStringExact(c.getFinancialYear(DateTime.Now)); //Datagridviews DataTable dyeing_batches = c.getBatchTable_State(3); dataGridView1.DataSource = dyeing_batches; if (true) { dataGridView1.Columns.OfType <DataGridViewColumn>().ToList().ForEach(col => col.Visible = false); this.dataGridView1.Columns["Batch_No"].Visible = true; this.dataGridView1.Columns["Colour"].Visible = true; this.dataGridView1.Columns["Quality"].Visible = true; this.dataGridView1.Columns["Date_Of_Production"].Visible = true; this.dataGridView1.Columns["Net_Weight"].Visible = true; this.dataGridView1.Columns["Number_Of_Trays"].Visible = true; this.dataGridView1.Columns["Fiscal_Year"].Visible = true; this.dataGridView1.Columns["Fiscal_Year"].HeaderText = "Financial Year"; this.dataGridView1.Columns["Number_Of_Trays"].HeaderText = "Number of Trays"; this.dataGridView1.Columns["Batch_No"].HeaderText = "Batch Number"; this.dataGridView1.Columns["Date_Of_Production"].HeaderText = "Date of Production"; this.dataGridView1.Columns["Batch_No"].Width = 70; this.dataGridView1.Columns["Number_Of_Trays"].Width = 80; } dataGridView1.DefaultCellStyle.SelectionBackColor = Color.White; dataGridView1.DefaultCellStyle.SelectionForeColor = Color.Blue; dataGridView1.Columns["Fiscal_Year"].AutoSizeMode = DataGridViewAutoSizeColumnMode.Fill; dataGridView2.DataSource = dt2; dataGridView2.DefaultCellStyle.SelectionBackColor = Color.White; dataGridView2.DefaultCellStyle.SelectionForeColor = Color.Blue; c.set_dgv_column_sort_state(dataGridView2, DataGridViewColumnSortMode.NotSortable); dataGridView3.DataSource = this.dt3; dataGridView3.RowHeadersVisible = false; this.dt3.Columns.Clear(); this.dt3.Columns.Add("SlNo"); this.dt3.Columns.Add("Batch_No"); this.dt3.Columns.Add("Financal Year"); this.dt3.Columns.Add("Net Weight"); dataGridView3.Columns["SlNo"].Width = 60; dataGridView3.DefaultCellStyle.SelectionBackColor = Color.White; dataGridView3.DefaultCellStyle.SelectionForeColor = Color.Black; dataGridView3.Columns["Net Weight"].AutoSizeMode = DataGridViewAutoSizeColumnMode.Fill; c.set_dgv_column_sort_state(dataGridView3, DataGridViewColumnSortMode.NotSortable); dataGridView4.DataSource = this.dt4; dataGridView4.RowHeadersVisible = false; this.dt4.Columns.Clear(); this.dt4.Columns.Add("SlNo"); this.dt4.Columns.Add("Carton No."); this.dt4.Columns.Add("Net Weight"); this.dt4.Columns.Add("Financial Year"); dataGridView4.Columns["SlNo"].Width = 70; dataGridView4.Columns["Carton No."].Width = 70; dataGridView4.Columns["Net Weight"].AutoSizeMode = DataGridViewAutoSizeColumnMode.Fill; dataGridView4.DefaultCellStyle.SelectionBackColor = Color.White; dataGridView4.DefaultCellStyle.SelectionForeColor = Color.Blue; c.set_dgv_column_sort_state(dataGridView4, DataGridViewColumnSortMode.NotSortable); dataGridView5.RowHeadersVisible = false; this.dataGridView5.Columns.Clear(); this.dataGridView5.Columns.Add("SlNo", "SlNo"); this.dataGridView5.Columns.Add("Carton No.", "Carton No."); this.dataGridView5.Columns.Add("Net Weight", "Net Weight"); this.dataGridView5.Columns.Add("Financial Year", "Financial Year"); dataGridView5.Columns["SlNo"].Width = 70; dataGridView5.Columns["Carton No."].Width = 70; dataGridView5.Columns["Net Weight"].AutoSizeMode = DataGridViewAutoSizeColumnMode.Fill; dataGridView5.DefaultCellStyle.SelectionBackColor = Color.White; dataGridView5.DefaultCellStyle.SelectionForeColor = Color.Blue; c.set_dgv_column_sort_state(dataGridView5, DataGridViewColumnSortMode.NotSortable); PrinterSettings ps = new PrinterSettings(); printDocument1.PrinterSettings = ps; IEnumerable <PaperSize> paperSizes = ps.PaperSizes.Cast <PaperSize>(); PaperSize sizeA4 = paperSizes.First <PaperSize>(size => size.Kind == PaperKind.A4); // setting paper size to A4 size printDocument1.DefaultPageSettings.PaperSize = sizeA4; //Load and Set defaults var print_types = new List <string>(); dt_printTypes = c.runQuery("SELECT * FROM Print_Types"); for (int i = 0; i < dt_printTypes.Rows.Count; i++) { string val = ""; for (int j = 0; j < dt_printTypes.Columns.Count - 1; j++) { val += dt_printTypes.Rows[i][j].ToString() + ", "; } val += "ID:" + dt_printTypes.Rows[i]["Print_Type_ID"].ToString(); print_types.Add(val); } this.firmDetailsCB.DataSource = print_types; this.firmDetailsCB.DisplayMember = "Firm Details"; this.firmDetailsCB.DropDownStyle = ComboBoxStyle.DropDownList;//Create a drop-down list this.firmDetailsCB.AutoCompleteSource = AutoCompleteSource.ListItems; this.firmDetailsCB.AutoCompleteMode = AutoCompleteMode.SuggestAppend; this.firmDetailsCB.DropDownWidth = DropDownWidth(this.firmDetailsCB); this.firmDetailsCB.ItemHeight = 50; //set drawmode user to use //Load default DataTable dt = c.runQuery("SELECT * FROM Defaults WHERE Default_Type= 'Print:Carton_Slip' and default_name = 'Default Print Type'"); int default_print_type_id = int.Parse(dt.Rows[0]["Default_Value"].ToString()); this.firmDetailsCB.SelectedIndex = FindEndSubStringIndex(this.firmDetailsCB, "ID:" + default_print_type_id.ToString()); this.printFormatCB.DropDownStyle = ComboBoxStyle.DropDownList;//Create a drop-down list this.printFormatCB.AutoCompleteSource = AutoCompleteSource.ListItems; this.printFormatCB.AutoCompleteMode = AutoCompleteMode.SuggestAppend; this.printFormatCB.SelectedIndex = 0; //default print type }
public PaperSizeInfo(PaperSize key, float width, float height) { this.Key = key; this.Width = width; this.Height = height; }
public int Add(PaperSize paperSize) {}
public static void LayoutPageSize(Map pMap, LayoutControl pLayout, string pMapTitle, string pPageSizeName = "A3", double pWidth = 42, double pHeight = 29.7) { var mG = pLayout.CreateGraphics(); // Calculate position parameters int pPageWidth = Utilities.Cm(pWidth); int pPageHeight = Utilities.Cm(pHeight); //int pPageWidth = pLayout.PrinterSettings.DefaultPageSettings.PaperSize.Width; //int pPageHeight = pLayout.PrinterSettings.DefaultPageSettings.PaperSize.Height; int pOuterMargin = Utilities.Cm(1); int pInternalMargin = Utilities.Cm(0.25); int pTitleHeight = Utilities.Cm(1); int pSubTitleHeight = Utilities.Cm(0.5); int pTitleAreaHeight = pTitleHeight + pInternalMargin + pSubTitleHeight + pInternalMargin; int pLegendWidth = Utilities.Cm(5); int pMapRectWidth = ((pPageWidth - (2 * pOuterMargin)) - pLegendWidth) - pInternalMargin; int pMapRectHeight = (pPageHeight - (2 * pOuterMargin)) - pTitleAreaHeight; int pMapWidth = pMapRectWidth - (pInternalMargin * 2); int pMapHeight = pMapRectHeight - (pInternalMargin * 2); int pScaleBarHeight = Utilities.Cm(0.75); int pScaleBarWidth = Utilities.Cm(5); int pNArrowWidth = Utilities.Cm(1); int pNArrowHeight = Utilities.Cm(1); // Set fonts var mFont1 = new Font("Arial", 9, FontStyle.Bold, GraphicsUnit.Millimeter); var mFont2 = new Font("Arial", 4, FontStyle.Italic, GraphicsUnit.Millimeter); var mFont3 = new Font("Arial", 3, FontStyle.Regular, GraphicsUnit.Millimeter); // Set page size var mPaperSize = new PaperSize(); mPaperSize.PaperName = pPageSizeName; mPaperSize.Width = pPageWidth; mPaperSize.Height = pPageHeight; pLayout.PrinterSettings.DefaultPageSettings.PaperSize = mPaperSize; // Set printer margin to 1 cm pLayout.PrinterSettings.DefaultPageSettings.Margins = new Margins(pOuterMargin, pOuterMargin, pOuterMargin, pOuterMargin); // Add map to layout var mMap = new LayoutMap(pMap); //mMap.MapControl = pMap; mMap.Size = new Size(pPageWidth, pPageHeight); mMap.Location = new Point(0, 0); pLayout.AddToLayout(mMap); // Add map mask // Add top margin AddRectangle(pLayout, pPageWidth, pOuterMargin + pTitleAreaHeight, 0, 0); // Add right margin AddRectangle(pLayout, pOuterMargin + pInternalMargin + pLegendWidth, pPageHeight, ((pPageWidth - pOuterMargin) - pLegendWidth) - pInternalMargin, 0); // Add bottom margin AddRectangle(pLayout, pPageWidth, pOuterMargin, 0, pPageHeight - pOuterMargin); // Add left margin AddRectangle(pLayout, pOuterMargin, pPageHeight, 0, 0); // Add title element to layout var mMapTitleElement = new LayoutText(); mMapTitleElement.Name = "Title"; mMapTitleElement.Size = new Size(pMapRectWidth, pTitleHeight); mMapTitleElement.Location = new Point(pOuterMargin, pOuterMargin); mMapTitleElement.Text = pMapTitle; mMapTitleElement.Font = mFont1; pLayout.AddToLayout(mMapTitleElement); // Add subtitle element to layout var mSubTitleElement = new LayoutText(); mSubTitleElement.Name = "Subtitle"; mSubTitleElement.Size = new Size(pMapRectWidth, pSubTitleHeight); mSubTitleElement.Location = new Point(pOuterMargin, pOuterMargin + pTitleHeight + pInternalMargin); mSubTitleElement.Text = "New Addressing System for Abu Dhabi Municipality"; mSubTitleElement.Font = mFont2; pLayout.AddToLayout(mSubTitleElement); // Add map border rectangle to map var mRect = new LayoutRectangle(); mRect.Size = new Size(pMapRectWidth, pMapRectHeight); mRect.Location = new Point(pOuterMargin, pOuterMargin + pTitleAreaHeight); pLayout.AddToLayout(mRect); // Add legend element to layout var mLegend = new LayoutLegend(); mLegend.Name = "Legend"; mLegend.LayoutControl = pLayout; mLegend.Map = mMap; mLegend.Size = new Size(pLegendWidth, pMapRectHeight); mLegend.Location = new Point(pPageWidth - pOuterMargin - pLegendWidth, pOuterMargin + pTitleAreaHeight); mLegend.Font = mFont3; pLayout.AddToLayout(mLegend); // Add scalebar element to layout var mScaleBar = new LayoutScaleBar(); mScaleBar.Name = "Scale Bar"; mScaleBar.Map = mMap; mScaleBar.Unit = ScaleBarUnit.Meters; mScaleBar.UnitText = "m"; mScaleBar.Size = new Size(pScaleBarWidth, pScaleBarWidth); mScaleBar.Location = new Point(pOuterMargin + pInternalMargin + pInternalMargin, ((((pPageHeight - pOuterMargin) - pInternalMargin) - pInternalMargin) - pInternalMargin) - pScaleBarHeight); mScaleBar.Font = mFont3; mScaleBar.BreakBeforeZero = false; mScaleBar.NumberOfBreaks = 2; pLayout.AddToLayout(mScaleBar); // Add north arrow to layout var mNorthArrow = new LayoutNorthArrow(); mNorthArrow.Name = "North Arrow"; mNorthArrow.NorthArrowStyle = NorthArrowStyle.ArrowN; mNorthArrow.Size = new Size(Utilities.Cm(0.5), Utilities.Cm(1)); mNorthArrow.Location = new Point(Utilities.Cm(1.5), Utilities.Cm(3.5)); pLayout.AddToLayout(mNorthArrow); mG.DrawLine(new Pen(Color.Black), new Point(0, 0), new Point(500, 500)); }
private void radioButtonMixedDoubleLetter_CheckedChanged(object sender, EventArgs e) { textBoxWidth.Enabled = false; textBoxHeight.Enabled = false; _papersize = PaperSize.MixedDoubleLetter; }
private void radioButtonMixedB4CarrierSheet_CheckedChanged(object sender, EventArgs e) { textBoxWidth.Enabled = false; textBoxHeight.Enabled = false; _papersize = PaperSize.MixedB4CarrierSheet; }
private void radioButtonLegal_CheckedChanged(object sender, System.EventArgs e) { _papersize=PaperSize.Legal; }
private void changePaperSize(PaperSize value) { switch(value) { case PaperSize.AutoSize: radioButtonAutoSize.Checked=true; break; case PaperSize.A4: radioButtonA4.Checked=true; break; case PaperSize.A5: radioButtonA5.Checked=true; break; case PaperSize.A6: radioButtonA6.Checked=true; break; case PaperSize.B5: radioButtonB5.Checked=true; break; case PaperSize.B6: radioButtonB6.Checked=true; break; case PaperSize.Letter: radioButtonLetter.Checked=true; break; case PaperSize.Legal: radioButtonLegal.Checked=true; break; //case PaperSize.Photo: // radioButtonPhoto.Checked=true; // break; case PaperSize.PostCard: radioButtonPostCard.Checked=true; break; case PaperSize.BusinessCard: radioButtonBusinessCard.Checked=true; break; case PaperSize.Executive: radioButtonExecutive.Checked = true; break; case PaperSize.Custom: radioButtonCustom.Checked = true; break; case PaperSize.A3CarrierSheet: radioButtonA3.Checked = true; break; case PaperSize.B4CarrierSheet: radioButtonB4Carrier.Checked = true; break; case PaperSize.DoubleLetter: radioButtonDoubleLetter.Checked = true; break; case PaperSize.MixedA3CarrierSheet: radioButtonMixedA3CarrierSheet.Checked = true; break; case PaperSize.MixedB4CarrierSheet: radioButtonMixedB4CarrierSheet.Checked = true; break; case PaperSize.MixedDoubleLetter: radioButtonMixedDoubleLetter.Checked = true; break; } }
public static void ConvertHtmlToPdf(string documentFilename, string htmlCode, PaperSize paperSize) { string pdfpath = HttpContext.Current.Server.MapPath("var/trackprotect"); string imagepath = HttpContext.Current.Server.MapPath(HttpContext.Current.Request.ApplicationPath) + "/Images"; Document doc = new Document(); try { PdfWriter.GetInstance(doc, new FileStream(pdfpath + "/Images.pdf", FileMode.Create)); doc.Open(); doc.Add(new Paragraph("PNG")); Image gif = Image.GetInstance(imagepath + "/invoicelogoTP.png"); doc.Add(gif); } catch (DocumentException dex) { HttpContext.Current.Response.Write(dex.Message); } catch (IOException ioex) { HttpContext.Current.Response.Write(ioex.Message); } catch (Exception ex) { HttpContext.Current.Response.Write(ex.Message); } finally { doc.Close(); } }
public static void ConvertHtmlToPdf(string documentFilename, string HTMLCode, PaperSize paperSize) { Rectangle pageSize = PageSize.A4; switch (paperSize) { case PaperSize.A4: pageSize = PageSize.A4; break; case PaperSize.A4_LANDSCAPE: pageSize = PageSize.A4_LANDSCAPE; break; case PaperSize.LETTER: pageSize = PageSize.LETTER; break; case PaperSize.LETTER_LANDSCAPE: pageSize = PageSize.LETTER_LANDSCAPE; break; } HttpContext context = HttpContext.Current; //Render PlaceHolder to temporary stream StringWriter stringWrite = new StringWriter(); HtmlTextWriter htmlWrite = new HtmlTextWriter(stringWrite); string postContent = getImage(HTMLCode); StringReader reader = new StringReader(postContent); //Create PDF document Document doc = new Document(pageSize); HTMLWorker parser = new HTMLWorker(doc); PdfWriter.GetInstance(doc, new FileStream(documentFilename, FileMode.Create)); doc.Open(); try { parser.Parse(reader); parser.EndDocument(); } catch (Exception ex) { Logger.Instance.Write(LogLevel.Error, ex, "[Util.ConvertHtmlToPdf]"); // Display parser errors in PDF. Paragraph paragraph = new Paragraph("Error!" + ex.Message); Chunk text = paragraph.Chunks[0] as Chunk; if (text != null) text.Font.Color = BaseColor.RED; doc.Add(paragraph); } finally { parser.Close(); doc.Close(); } }
public GlobalConfig SetPaperSize(PaperSize ps) { return(ps.Kind == PaperKind.Custom ? SetPaperSize(ps.Width, ps.Height) : SetPaperSize(ps.Kind)); }
public void PaperSizeKindTest() { // set_RawKind seems to accept any value (no ArgEx seen), but get_Kind // returns "Custom" when it's set to a value bigger than the biggest enum. // PaperSize ps = new PaperSize("foo", 100, 100); // // Zero == Custom Assert.AreEqual(PaperKind.Custom, ps.Kind, "Kind #1"); Assert.AreEqual(0, ps.RawKind, "RawKind #1"); try { ps.Height = 1; Assert.AreEqual(1, ps.Height, "get_Height #1"); } catch (ArgumentException) { Assert.Fail("should not have thrown #1"); } // // Well-known ps.RawKind = (int)PaperKind.A4; Assert.AreEqual(PaperKind.A4, ps.Kind, "Kind #2"); Assert.AreEqual((int)PaperKind.A4, ps.RawKind, "RawKind #2"); try { ps.Height = 2; Assert.Fail("should have thrown #2"); } catch (ArgumentException) { } // ps.RawKind = (int)PaperKind.JapaneseEnvelopeKakuNumber3; Assert.AreEqual(PaperKind.JapaneseEnvelopeKakuNumber3, ps.Kind, "Kind #3"); Assert.AreEqual((int)PaperKind.JapaneseEnvelopeKakuNumber3, ps.RawKind, "RawKind #3"); // // Too Big ps.RawKind = 999999; Assert.AreEqual(PaperKind.Custom, ps.Kind, "Kind #4"); Assert.AreEqual(999999, ps.RawKind, "RawKind #4"); // The properties can be changed only when the *real* Kind is Custom // and not when is 'effectively' Custom. try { ps.Height = 4; Assert.Fail("should have thrown #4"); } catch (ArgumentException) { } // ps.RawKind = int.MaxValue; Assert.AreEqual(PaperKind.Custom, ps.Kind, "Kind #5"); Assert.AreEqual(int.MaxValue, ps.RawKind, "RawKind #5"); // // Negative -- Looks as if MSFT forgot to check for negative! ps.RawKind = -1; Assert.AreEqual((PaperKind)(-1), ps.Kind, "Kind #6"); Assert.AreEqual(-1, ps.RawKind, "RawKind #6"); // ps.RawKind = int.MinValue; Assert.AreEqual((PaperKind)(int.MinValue), ps.Kind, "Kind #7"); Assert.AreEqual(int.MinValue, ps.RawKind, "RawKind #7"); // // Where's the top limit? ps.RawKind = (int)PaperKind.PrcEnvelopeNumber10Rotated; Assert.AreEqual(PaperKind.PrcEnvelopeNumber10Rotated, ps.Kind, "Kind #8"); Assert.AreEqual((int)PaperKind.PrcEnvelopeNumber10Rotated, ps.RawKind, "RawKind #8"); // +1 ps.RawKind = 1 + (int)PaperKind.PrcEnvelopeNumber10Rotated; Assert.AreEqual(PaperKind.Custom, ps.Kind, "Kind #9"); Assert.AreEqual(1 + (int)PaperKind.PrcEnvelopeNumber10Rotated, ps.RawKind, "RawKind #9"); try { ps.Height = 9; Assert.Fail("should have thrown #9"); } catch (ArgumentException) { } // Set Custom ps.RawKind = (int)PaperKind.Custom; Assert.AreEqual(PaperKind.Custom, ps.Kind, "Kind #1b"); Assert.AreEqual(0, ps.RawKind, "RawKind #1b"); try { ps.Height = 1; Assert.AreEqual(1, ps.Height, "get_Height #1b"); } catch (ArgumentException) { Assert.Fail("should not have thrown #1b"); } }
private void radioButtonPostCard_CheckedChanged(object sender, System.EventArgs e) { textBoxWidth.Enabled = false; textBoxHeight.Enabled = false; _papersize=PaperSize.PostCard; }
public static float PaperWidthInPt(PaperSize paperSize, PaperOrientation orientation) { return(PaperWidthInTwip(paperSize, orientation) / 20.0F); }
public PaperText(decimal spacing, string originalText, StringFormat textFormat, Font textFont, PaperSize size, PrintStruct.Pdpi dpi) { Spacing = spacing; OriginalText = originalText; TextFormat = textFormat; TextFont = textFont; PagerSize = size; var printBitmap = new Bitmap(size.Width * dpi.X / 100, size.Height * dpi.Y / 100); printBitmap.SetResolution(dpi.X, dpi.Y); Segmentation = ImageHepler.GetStringRows(Graphics.FromImage(printBitmap), textFont, originalText); }
private void radioCustom_CheckedChanged(object sender, System.EventArgs e) { textBoxWidth.Enabled = true; textBoxHeight.Enabled = true; _papersize=PaperSize.Custom; }
/** * Constructor */ private PaperSize(int v,bool growArray) { val = v; if (v >= paperSizes.Length && growArray) { // Grow the array and add this to it PaperSize[] newarray = new PaperSize[v + 1]; System.Array.Copy(paperSizes,0,newarray,0,paperSizes.Length); paperSizes = newarray; } if (v < paperSizes.Length) { paperSizes[v] = this; } }
public void CopyTo(PaperSize[] paperSizes, int index) {}
private void cbxPrinter_SelectedIndexChanged(object sender, EventArgs e) { FPrinterSettings.PrinterName = (string)cbxPrinter.SelectedItem; // paper int indexOfDefaultPaper = -1; PaperSize defaultPaper = FPrinterSettings.DefaultPageSettings.PaperSize; cbxPrintOnSheet.Items.Clear(); foreach (PaperSize ps in FPrinterSettings.PaperSizes) { cbxPrintOnSheet.Items.Add(ps.PaperName); if (ps == defaultPaper) { indexOfDefaultPaper = cbxPrintOnSheet.Items.Count - 1; } } // probe PaperWidth, PaperHeight, RawPaperSize if (Report.PrintSettings.PrintOnSheetRawPaperSize != 0) { foreach (PaperSize ps in FPrinterSettings.PaperSizes) { if (cbxPrintOnSheet.SelectedIndex == -1 && PaperSizeEqual(ps, Report.PrintSettings.PrintOnSheetWidth, Report.PrintSettings.PrintOnSheetHeight, Report.PrintSettings.PrintOnSheetRawPaperSize)) { cbxPrintOnSheet.SelectedIndex = cbxPrintOnSheet.Items.IndexOf(ps.PaperName); } } } // probe PaperWidth, PaperHeight only if (cbxPrintOnSheet.SelectedIndex == -1) { foreach (PaperSize ps in FPrinterSettings.PaperSizes) { if (cbxPrintOnSheet.SelectedIndex == -1 && PaperSizeEqual(ps, Report.PrintSettings.PrintOnSheetWidth, Report.PrintSettings.PrintOnSheetHeight, 0)) { cbxPrintOnSheet.SelectedIndex = cbxPrintOnSheet.Items.IndexOf(ps.PaperName); } } } if (cbxPrintOnSheet.SelectedIndex == -1 && indexOfDefaultPaper < cbxPrintOnSheet.Items.Count) { cbxPrintOnSheet.SelectedIndex = indexOfDefaultPaper; } // paper source cbxSource.Items.Clear(); int indexOfAutofeed = -1; foreach (PaperSource ps in FPrinterSettings.PaperSources) { cbxSource.Items.Add(ps.SourceName); if (ps.Kind == PaperSourceKind.AutomaticFeed) { indexOfAutofeed = cbxSource.Items.Count - 1; } if (Report.PrintSettings.PaperSource == ps.RawKind) { cbxSource.SelectedIndex = cbxSource.Items.Count - 1; } } if (cbxSource.SelectedIndex == -1 && indexOfAutofeed < cbxSource.Items.Count) { cbxSource.SelectedIndex = indexOfAutofeed; } }
/** * Sets the paper size * * @param ps the paper size */ public void setPaperSize(PaperSize ps) { paperSize = ps.getValue(); }
private void saveToPDF(List <Part> partList) { String printerName = printDialog1.PrinterSettings.PrinterName; String extenzija; try { string fileName = ""; Printers prt = new Printers(); printDocumentIUS.PrinterSettings.PrinterName = "Microsoft Print to PDF"; if (prt.PrinterExist(printDocumentIUS.PrinterSettings.PrinterName)) { extenzija = ".pdf"; } else { printDocumentIUS.PrinterSettings.PrinterName = "Microsoft XPS Document Writer"; if (prt.PrinterExist(printDocumentIUS.PrinterSettings.PrinterName)) { extenzija = ".xps"; } else { MessageBox.Show("PDF or XPS printer can't be found!"); return; } } fileName = "\\IUS " + IUSNumber.ToString().Replace("/", "") + extenzija; if (!Directory.Exists(Properties.Settings.Default.DefaultFolder + "\\IUS")) { return; } string directory = Properties.Settings.Default.DefaultFolder + "\\IUS"; printDocumentIUS.PrinterSettings.PrintFileName = directory + fileName; printDocumentIUS.PrinterSettings.PrintToFile = true; IEnumerable <PaperSize> paperSizes = printDocumentIUS.PrinterSettings.PaperSizes.Cast <PaperSize>(); PaperSize sizeA4 = paperSizes.First <PaperSize>(size => size.Kind == PaperKind.A4); // setting paper size to A4 size printDocumentIUS.DefaultPageSettings.PaperSize = sizeA4; printDocumentIUS.DefaultPageSettings.Margins.Top = 0; printDocumentIUS.DefaultPageSettings.Margins.Bottom = 0; printDocumentIUS.Print(); printDocumentIUS.PrinterSettings.PrintToFile = false; printDocumentIUS.PrinterSettings.PrinterName = printerName; } catch (Exception e1) { new LogWriter(e1); MessageBox.Show(e1.Message + Environment.NewLine + "PDF file not saved.", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); } finally { Program.LoadStop(); } }
public static void Set(PaperSize ps) { SelectedPaper = ps; }
public override object ReadJson(Newtonsoft.Json.JsonReader reader, Type objectType, object existingValue, JsonSerializer serializer) { return(PaperSize.GetPaperSize(reader.Value as string)); }
CollectEvent(object sender, CollectorEventArgs e) { // cast the sender object to the SnoopCollector we are expecting Collector snoopCollector = sender as Collector; if (snoopCollector == null) { Debug.Assert(false); // why did someone else send us the message? return; } // see if it is a type we are responsible for Document doc = e.ObjToSnoop as Document; if (doc != null) { Stream(snoopCollector.Data(), doc); return; } Selection sel = e.ObjToSnoop as Selection; if (sel != null) { Stream(snoopCollector.Data(), sel); return; } Settings settings = e.ObjToSnoop as Settings; if (settings != null) { Stream(snoopCollector.Data(), settings); return; } Category cat = e.ObjToSnoop as Category; if (cat != null) { Stream(snoopCollector.Data(), cat); return; } PaperSize paperSize = e.ObjToSnoop as PaperSize; if (paperSize != null) { Stream(snoopCollector.Data(), paperSize); return; } PaperSource paperSource = e.ObjToSnoop as PaperSource; if (paperSource != null) { Stream(snoopCollector.Data(), paperSource); return; } PrintSetup prnSetup = e.ObjToSnoop as PrintSetup; if (prnSetup != null) { Stream(snoopCollector.Data(), prnSetup); return; } PrintParameters prnParams = e.ObjToSnoop as PrintParameters; if (prnParams != null) { Stream(snoopCollector.Data(), prnParams); return; } PlanTopology planTopo = e.ObjToSnoop as PlanTopology; if (planTopo != null) { Stream(snoopCollector.Data(), planTopo); return; } PlanCircuit planCircuit = e.ObjToSnoop as PlanCircuit; if (planCircuit != null) { Stream(snoopCollector.Data(), planCircuit); return; } PrintManager printManager = e.ObjToSnoop as PrintManager; if (printManager != null) { Stream(snoopCollector.Data(), printManager); return; } }
private void loadRpt() { PageSettings pg; pg = new System.Drawing.Printing.PageSettings(); pg.Landscape = true; pg.Margins.Top = 2; pg.Margins.Bottom = 2; pg.Margins.Left = 40; pg.Margins.Right = 2; PaperSize size = new PaperSize(); size.RawKind = (int)PaperKind.A4; pg.PaperSize = size; //reportViewer1.SetPageSettings(pg); //DataTable dt = ReceiptsManager.GetAvowelsReportDT(< Parameters >); DateTime startDate = new DateTime(2018, 01, 28); DateTime endDate = new DateTime(2018, 02, 03); string zStartDate = startDate.ToString("yyyy-MM-dd"); string zEndDate = endDate.ToString("yyyy-MM-dd"); #if !use_sqlite string qry = string.Format("select * from external_payment" + " where constr_org like N'%{0}%' and date between '{1} 00:00:00' and '{2} 00:00:00'" + " order by date", constrorg, zStartDate, zEndDate); #else string qry = string.Format("select * from receipts" + " where date between '{0} 00:00:00' and '{1} 00:00:00'" + " order by date", zStartDate, zEndDate); #endif var m_sqls = new Dictionary <string, string> { { "DataSet1", qry }, }; //if (dt != null && dt.Rows.Count > 0) { reportViewer1.ProcessingMode = ProcessingMode.Local; LocalReport localReport = reportViewer1.LocalReport; reportViewer1.LocalReport.ReportPath = @"..\..\Report1.rdlc"; reportViewer1.LocalReport.DataSources.Clear(); DataSet ds = new DataSet(); foreach (var pair in m_sqls) { DataTable dt; dt = loadData(pair.Value); //dt = new DataTable(); dt.TableName = pair.Key; ds.Tables.Add(dt); reportViewer1.LocalReport.DataSources.Add(new ReportDataSource(pair.Key, dt)); } reportViewer1.LocalReport.DataSources.Add(new ReportDataSource()); List <ReportParameter> rpParams = new List <ReportParameter>() { new ReportParameter("startDate", zStartDate), new ReportParameter("endDate", zEndDate) }; reportViewer1.LocalReport.SetParameters(rpParams); reportViewer1.LocalReport.Refresh(); reportViewer1.SetDisplayMode(DisplayMode.PrintLayout); reportViewer1.ResetPageSettings(); pg = reportViewer1.GetPageSettings(); //pg.Landscape = true; reportViewer1.SetPageSettings(pg); this.reportViewer1.RefreshReport(); } }
public Class5(System.Drawing.Printing.PaperSize paperSize_1) { this.paperSize_0 = paperSize_1; }
void loadBill() { PageSettings pg; pg = new System.Drawing.Printing.PageSettings(); pg.Landscape = true; pg.Margins.Top = 2; pg.Margins.Bottom = 2; pg.Margins.Left = 40; pg.Margins.Right = 2; PaperSize size = new PaperSize(); size.RawKind = (int)PaperKind.A4; pg.PaperSize = size; //reportViewer1.SetPageSettings(pg); //DataTable dt = ReceiptsManager.GetAvowelsReportDT(< Parameters >); DateTime startDate = new DateTime(2018, 01, 28); DateTime endDate = new DateTime(2018, 01, 28); string zStartDate = startDate.ToString("yyyy-MM-dd"); string zEndDate = endDate.ToString("yyyy-MM-dd"); string constrorg = "don vi a"; #if !use_sqlite string qry = string.Format("select * from external_payment" + " where constr_org like N'%{0}%' and date between '{1} 00:00:00' and '{2} 00:00:00'" + " order by date", constrorg, zStartDate, zEndDate); qry = "select top 2 * from internal_payment"; #else string qry = string.Format("select * from internal_payment" + " where constr_org like '%{0}%' and date between '{1} 00:00:00' and '{2} 00:00:00'" + " order by date", constrorg, zStartDate, zEndDate); qry = "select * from internal_payment limit 2"; #endif var m_sqls = new Dictionary <string, string> { { "DataSet1", qry }, }; //if (dt != null && dt.Rows.Count > 0) { reportViewer1.ProcessingMode = ProcessingMode.Local; LocalReport localReport = reportViewer1.LocalReport; reportViewer1.LocalReport.ReportPath = @"..\..\bill_receipts.rdlc"; reportViewer1.LocalReport.DataSources.Clear(); DataSet ds = new DataSet(); foreach (var pair in m_sqls) { DataTable dt; dt = loadData(pair.Value); //dt = new DataTable(); dt.TableName = pair.Key; ds.Tables.Add(dt); DataTable rptDt = new DataTable(); rptDt.Columns.Add(new DataColumn("name")); rptDt.Columns.Add(new DataColumn("addr")); rptDt.Columns.Add(new DataColumn("date", typeof(DateTime))); rptDt.Columns.Add(new DataColumn("num")); rptDt.Columns.Add(new DataColumn("content")); rptDt.Columns.Add(new DataColumn("note")); rptDt.Columns.Add(new DataColumn("amount", typeof(Int64))); rptDt.Columns.Add(new DataColumn("amountTxt")); foreach (DataRow dr in dt.Rows) { var r = rptDt.NewRow(); r["name"] = dr["name"]; r["addr"] = dr["addr"]; r["date"] = dr["date"]; r["num"] = dr["payment_number"]; r["content"] = dr["content"]; r["note"] = dr["note"]; r["amount"] = dr["advance_payment"]; r["amountTxt"] = ""; rptDt.Rows.Add(r); } reportViewer1.LocalReport.DataSources.Add(new ReportDataSource(pair.Key, rptDt)); } reportViewer1.LocalReport.DataSources.Add(new ReportDataSource()); List <ReportParameter> rpParams = new List <ReportParameter>() { //receipt = 1 //payment = 2 new ReportParameter("type", "1") }; reportViewer1.LocalReport.SetParameters(rpParams); reportViewer1.LocalReport.Refresh(); reportViewer1.SetDisplayMode(DisplayMode.PrintLayout); reportViewer1.ResetPageSettings(); pg = reportViewer1.GetPageSettings(); //pg.Landscape = true; reportViewer1.SetPageSettings(pg); this.reportViewer1.RefreshReport(); } }
/** * Set the paper size as enum value. * * @param size value for the paper size. */ public void SetPaperSize(PaperSize size) { PaperSize = ((short)(size + 1)); }
void load_bill() { PageSettings pg; pg = new System.Drawing.Printing.PageSettings(); pg.Landscape = true; pg.Margins.Top = 2; pg.Margins.Bottom = 2; pg.Margins.Left = 40; pg.Margins.Right = 2; PaperSize size = new PaperSize(); size.RawKind = (int)PaperKind.A4; pg.PaperSize = size; //reportViewer1.SetPageSettings(pg); //DataTable dt = ReceiptsManager.GetAvowelsReportDT(< Parameters >); DateTime startDate = new DateTime(2015, 01, 03); DateTime endDate = new DateTime(2015, 01, 06); string zStartDate = startDate.ToString("yyyy-MM-dd"); string zEndDate = endDate.ToString("yyyy-MM-dd"); var m_sqls = new Dictionary <string, string> { { "DataSet1", "select * from receipts limit 3" }, }; //if (dt != null && dt.Rows.Count > 0) { reportViewer1.ProcessingMode = ProcessingMode.Local; LocalReport localReport = reportViewer1.LocalReport; reportViewer1.LocalReport.ReportPath = @"..\..\bill_receipts.rdlc"; //ReportDataSource RDS = new ReportDataSource(); //RDS.Name = < RDLC Report Dataset Name >; //RDS.Value = dt; reportViewer1.LocalReport.DataSources.Clear(); //reportViewer1.LocalReport.DataSources.Add(RDS); DataSet ds = new DataSet(); foreach (var pair in m_sqls) { DataTable dt; dt = loadData(pair.Value); //dt = new DataTable(); dt.TableName = pair.Key; ds.Tables.Add(dt); reportViewer1.LocalReport.DataSources.Add(new ReportDataSource(pair.Key, dt)); } reportViewer1.LocalReport.DataSources.Add(new ReportDataSource()); List <ReportParameter> rpParams = new List <ReportParameter>() { new ReportParameter("ReportParameter1", new string [] { "one", "two", "three" }) // new ReportParameter("nameTxt", "nguyen van a") // //new ReportParameter("startDate", zStartDate), // //new ReportParameter("endDate", zEndDate), // //new ReportParameter( "type", "Ngày") }; reportViewer1.LocalReport.SetParameters(rpParams); reportViewer1.LocalReport.Refresh(); reportViewer1.SetDisplayMode(DisplayMode.PrintLayout); reportViewer1.ResetPageSettings(); pg = reportViewer1.GetPageSettings(); //pg.Landscape = true; reportViewer1.SetPageSettings(pg); this.reportViewer1.RefreshReport(); } }
/// <summary> /// Converts PaperSize (hundredths of an inch) to PageMediaSize (px). /// </summary> static PageMediaSize ConvertPaperSizeToMediaSize(PaperSize paperSize) { return(new PageMediaSize(ConvertToPx(paperSize.Width), ConvertToPx(paperSize.Height))); }
private void btnBookSeats_Click(object sender, System.Windows.RoutedEventArgs e) { try { Dispatcher.Invoke(DispatcherPriority.Background, new Action(() => ManageLoadingDataVisibility(true))); if (Seats.Where(x => x.IsEnabled && x.IsChecked).ToList().Count() == 0) { ModernDialog.ShowMessage("Please Select seats", "Alert", MessageBoxButton.OK); } else if (Seats.Where(x => x.IsEnabled && x.IsChecked).ToList().Count() > Convert.ToInt32(ConfigurationSettings.AppSettings["MaxBookingSeats"])) { ModernDialog.ShowMessage(string.Format("You can select Maximum {0} seats only", Convert.ToInt32(ConfigurationSettings.AppSettings["MaxBookingSeats"])), "Alert", MessageBoxButton.OK); } else if (Seats.Where(x => x.IsEnabled && x.IsChecked).ToList().GroupBy(l => l.ScreenClassId).Count() > 1) { ModernDialog.ShowMessage("Please Book tickets from Only one Class, You Can't book tickets from multiple classes", "Alert", MessageBoxButton.OK); } else if (Seats.Where(x => x.IsEnabled && x.IsChecked).ToList().Count() != Convert.ToInt32((lstSeats.SelectedValue as ListBoxItem).Content)) { ModernDialog.ShowMessage("Required seats and selected seats count is not matched.", "Alert", MessageBoxButton.OK); } else { //if (ModernDialog.ShowMessage("Are you sure you want to continue booking?", string.Format("Confirmation"), MessageBoxButton.YesNo) == MessageBoxResult.Yes) //{ var selectedSeats = Seats.Where(x => x.IsEnabled && x.IsChecked).ToList(); var seats = string.Join(",", selectedSeats.Select(x => x.Id)); var result = new MovieTimingsRepository().InsertMovieBooking(Convert.ToInt32(lstMovie.SelectedValue), selectedSeats.Count(), Convert.ToDouble(Seats.Where(x => x.IsEnabled && x.IsChecked).ToList().Sum(x => x.TicketCost)), selectedSeats.FirstOrDefault().ScreenClassId, Convert.ToInt32(lstScreen.SelectedValue), Convert.ToInt32((lstTimes.SelectedItem as Movie).Id), seats); if (result == 0) { if (ModernDialog.ShowMessage("Tickets already reserved, Please reload and try another seats..", "Alert", MessageBoxButton.YesNo) == MessageBoxResult.Yes) { LoadBookedTickets(); } } else { order_Id = result; PrintDocument pd = new PrintDocument(); PaperSize ps = new PaperSize("", 475, 550); pd.PrintPage += new PrintPageEventHandler(ticket_PrintPage); pd.PrintController = new StandardPrintController(); pd.DefaultPageSettings.Margins.Left = 0; pd.DefaultPageSettings.Margins.Right = 0; pd.DefaultPageSettings.Margins.Top = 0; pd.DefaultPageSettings.Margins.Bottom = 0; pd.DefaultPageSettings.PaperSize = ps; pd.Print(); //ModernDialog.ShowMessage("Tickets booking confired successfully", "Alert", MessageBoxButton.OK); LoadBookedTickets(); stkBooking.Visibility = Visibility.Collapsed; } //} } Dispatcher.Invoke(DispatcherPriority.Background, new Action(() => ManageLoadingDataVisibility(false))); } catch (Exception ex) { ManageLoadingDataVisibility(false); LogExceptions.LogException(ex); } }
public printDO(DataRow row, M_V4_printDO f) { InitializeComponent(); this.c = new DbConnect(); this.parent = f; if (row.Table.Columns.Count < 3) { return; } if (row["Type_Of_Sale"].ToString() == "0") { label3.Visible = false; label5.Visible = false; label6.Visible = false; this.label7.Location = new System.Drawing.Point(268, 48); } // Load default firm details DataTable dt10 = c.runQuery("SELECT * FROM Defaults WHERE Default_Type= 'Print' and default_name = 'Default Print Type'"); string default_print_type_id = dt10.Rows[0]["Default_Value"].ToString(); DataTable dt_printTypes = c.runQuery("select * from Print_Types where Print_Type_ID=" + default_print_type_id); if (dt_printTypes == null) { c.WarningBox("Print->Default Print Type is set as " + default_print_type_id + ", not found in Default Print_Type_IDs Table, " + "defaulting to first entry in Print_Types table"); dt_printTypes = c.runQuery("select * from Print_Types"); } for (int j = 0; j < dt_printTypes.Columns.Count - 1; j++) { firmDetails[dt_printTypes.Columns[j].ColumnName] = dt_printTypes.Rows[0][j].ToString(); } this.type = int.Parse(row["Type_Of_Sale"].ToString()); this.donoTextbox.Text = row["Sale_DO_No"].ToString(); this.saleDateTextbox.Text = row["Date_Of_Sale"].ToString().Substring(0, 10); this.customerNameTextbox.Text = row["Customer"].ToString(); this.qualityTextbox.Text = row["Quality"].ToString(); this.label3.Text = firmDetails["Firm_Name"]; this.label5.Text = firmDetails["Address"]; float sale_rate = float.Parse(row["Sale_Rate"].ToString()); float net_weight = float.Parse(row["Net_Weight"].ToString()); //this.amountTextbox.Text = (sale_rate * net_weight).ToString("F2"); //this.netwtTextbox.Text = net_weight.ToString("F3"); this.rateTB.Text = sale_rate.ToString("F2"); //string[] carton_nos = c.csvToArray(row["Carton_No_Arr"].ToString()); //string cartonfisc = row["Carton_Fiscal_Year"].ToString(); string table = row["Tablename"].ToString(); DataTable dt = new DataTable(); dt.Columns.Add("Sl No"); dt.Columns.Add("Carton No."); dt.Columns.Add("Shade"); dt.Columns.Add("Net Wt."); dt.Columns.Add("Rate"); float net_wt = 0F, net_rate = 0F; DataTable cartons = new DataTable(); if (table == "Carton") { cartons = c.getTableData("Carton", "*", "TS_Voucher_ID=" + row["Voucher_ID"].ToString() + " AND Date_Of_Sale IS Not Null"); } else { cartons = c.getTableData("Carton_Produced", "*", "Sales_Voucher_ID=" + row["Voucher_ID"].ToString()); } for (int i = 0; i < cartons.Rows.Count; i++) { DataRow dtemp = cartons.Rows[i]; string colour = "Gray"; if (table != "Carton") { colour = dtemp["Colour"].ToString(); } net_wt += float.Parse(dtemp["Net_Weight"].ToString()); float rate = (float.Parse(dtemp["Net_Weight"].ToString()) * float.Parse(row["Sale_Rate"].ToString())); net_rate += rate; dt.Rows.Add(i + 1, dtemp["Carton_No"].ToString(), colour, dtemp["Net_Weight"].ToString(), rate.ToString("F2")); } dt.Rows.Add("", "", "Net Weight", net_wt.ToString("F3"), net_rate.ToString("F2")); dataGridView1.DataSource = dt; dataGridView1.Columns["Sl No"].Width = 60; c.auto_adjust_dgv(dataGridView1); dataGridView1.DefaultCellStyle.SelectionBackColor = Color.White; dataGridView1.DefaultCellStyle.SelectionForeColor = Color.Black; dataGridView1.Columns.Cast <DataGridViewColumn>().ToList().ForEach(t => t.SortMode = DataGridViewColumnSortMode.NotSortable); dataGridView1.Columns["Sl NO"].AutoSizeMode = DataGridViewAutoSizeColumnMode.None; c.set_dgv_column_sort_state(dataGridView1, DataGridViewColumnSortMode.NotSortable); this.where = "Voucher_ID=" + int.Parse(row["Voucher_ID"].ToString()) + ""; this.label3.Text = firmDetails["Firm_Name"]; this.label5.Text = firmDetails["Address"]; this.label6.Text = "(GSTIN No. " + firmDetails["GSTIN"] + ")"; PrinterSettings ps = new PrinterSettings(); printDocument1.PrinterSettings = ps; IEnumerable <PaperSize> paperSizes = ps.PaperSizes.Cast <PaperSize>(); PaperSize sizeA4 = paperSizes.First <PaperSize>(size => size.Kind == PaperKind.A4); // setting paper size to A4 size printDocument1.DefaultPageSettings.PaperSize = sizeA4; }
public Form1() { // // Required for Windows Form Designer support // InitializeComponent(); // Setup the event handlers printDoc.QueryPageSettings += new QueryPageSettingsEventHandler(this.MyPrintQueryPageSettingsEvent); printDoc.PrintPage += new PrintPageEventHandler(this.MyPrintPageEvent); /* // Other way to specify custom paper size is to set the paper kind and related properties. * PaperSize pkCustomSize2 = new PaperSize(); * pkCustomSize2.Kind = PaperSourceKind.Custom; * pkCustomSize2.PaperName = "Other custom size"; * pkCustomSize2.Width = 100; * pkCustomSize2.Height = 200; * * comboPaperSize.Items.Add(pkCustomSize2); * */ // <Snippet1> // Add list of supported paper sizes found on the printer. // The DisplayMember property is used to identify the property that will provide the display string. comboPaperSize.DisplayMember = "PaperName"; PaperSize pkSize; for (int i = 0; i < printDoc.PrinterSettings.PaperSizes.Count; i++) { pkSize = printDoc.PrinterSettings.PaperSizes[i]; comboPaperSize.Items.Add(pkSize); } // Create a PaperSize and specify the custom paper size through the constructor and add to combobox. PaperSize pkCustomSize1 = new PaperSize("First custom size", 100, 200); comboPaperSize.Items.Add(pkCustomSize1); // </Snippet1> // <Snippet2> // Add list of paper sources found on the printer to the combo box. // The DisplayMember property is used to identify the property that will provide the display string. comboPaperSource.DisplayMember = "SourceName"; PaperSource pkSource; for (int i = 0; i < printDoc.PrinterSettings.PaperSources.Count; i++) { pkSource = printDoc.PrinterSettings.PaperSources[i]; comboPaperSource.Items.Add(pkSource); } // </Snippet2> // <Snippet3> // Add list of printer resolutions found on the printer to the combobox. // The PrinterResolution's ToString() method will be used to provide the display string. PrinterResolution pkResolution; for (int i = 0; i < printDoc.PrinterSettings.PrinterResolutions.Count; i++) { pkResolution = printDoc.PrinterSettings.PrinterResolutions[i]; comboPrintResolution.Items.Add(pkResolution); } // </Snippet3> PopulateInstalledPrintersCombo(); }
public static string GetPaperSizeName(PaperSize paperSize) { string result; switch (paperSize) { case PaperSize.LedgerPortrait: result = "11x17"; break; case PaperSize.Ledger: result = "ledger"; break; case PaperSize.Legal: result = "legal"; break; case PaperSize.Letter: result = "letter"; break; case PaperSize.LetterSmall: result = "lettersmall"; break; case PaperSize.ArchE: result = "archE"; break; case PaperSize.ArchD: result = "archD"; break; case PaperSize.ArchC: result = "archC"; break; case PaperSize.ArchB: result = "archB"; break; case PaperSize.ArchA: result = "archA"; break; case PaperSize.A0: result = "a0"; break; case PaperSize.A1: result = "a1"; break; case PaperSize.A2: result = "a2"; break; case PaperSize.A3: result = "a3"; break; case PaperSize.A4: result = "a4"; break; case PaperSize.A5: result = "a5"; break; case PaperSize.A6: result = "a6"; break; case PaperSize.A7: result = "a7"; break; case PaperSize.A8: result = "a8"; break; case PaperSize.A9: result = "a9"; break; case PaperSize.A10: result = "a10"; break; case PaperSize.B0: result = "isob0"; break; case PaperSize.B1: result = "isob1"; break; case PaperSize.B2: result = "isob2"; break; case PaperSize.B3: result = "isob3"; break; case PaperSize.B4: result = "isob4"; break; case PaperSize.B5: result = "isob5"; break; case PaperSize.B6: result = "isob6"; break; case PaperSize.C0: result = "c0"; break; case PaperSize.C1: result = "c1"; break; case PaperSize.C2: result = "c2"; break; case PaperSize.C3: result = "c3"; break; case PaperSize.C4: result = "c4"; break; case PaperSize.C5: result = "c5"; break; case PaperSize.C6: result = "c6"; break; case PaperSize.Foolscap: result = "fse"; break; case PaperSize.HalfLetter: result = "halfletter"; break; case PaperSize.Hagaki: result = "hagaki"; break; default: throw new ArgumentException("Invalid paper size", "paperSize"); } return(result); }
private void corte() { folio = GenerateRandom(); Utilerias.LOG.acciones("genero corte de caja " + folio); string sql = "UPDATE VENDIDOS SET CORTE=@CORTE WHERE CORTE=0 AND VENDEDOR=@VALIDADOR AND NOT STATUS='PREVENTA' AND NOT STATUS='BLOQUEADO' "; db.PreparedSQL(sql); db.command.Parameters.AddWithValue("@CORTE", 1); db.command.Parameters.AddWithValue("@VALIDADOR", usuarioconsulta); db.execute(); string sql3 = "UPDATE VENDIDOS SET CORTECANCELADO=@CORTECANCELADO WHERE CORTECANCELADO=0 AND CANCELADO=@VALIDADOR"; db.PreparedSQL(sql3); db.command.Parameters.AddWithValue("@CORTECANCELADO", 1); db.command.Parameters.AddWithValue("@VALIDADOR", usuarioconsulta); db.execute(); string sql2 = "UPDATE GUIA SET CORTE=@CORTE WHERE CORTE=0 AND VALIDADOR=@VALIDADOR"; db.PreparedSQL(sql2); db.command.Parameters.AddWithValue("@CORTE", 1); db.command.Parameters.AddWithValue("@VALIDADOR", usuarioconsulta); db.execute(); tamaño = 1000; PrintDocument pd = new PrintDocument(); pd.PrintPage += new PrintPageEventHandler(llenarticket); PaperSize ps = new PaperSize("", 420, tamaño); pd.PrintController = new StandardPrintController(); pd.DefaultPageSettings.Margins.Left = 0; pd.DefaultPageSettings.Margins.Right = 0; pd.DefaultPageSettings.Margins.Top = 0; pd.DefaultPageSettings.Margins.Bottom = 0; pd.DefaultPageSettings.PaperSize = ps; pd.PrinterSettings.PrinterName = Settings1.Default.impresora; subir(); pd.Print(); CrearTicket ticket0 = new CrearTicket(); ticket0.TextoIzquierda(""); ticket0.TextoIzquierda(""); ticket0.TextoIzquierda(""); ticket0.TextoIzquierda(""); ticket0.CortaTicket(); ticket0.ImprimirTicket(Settings1.Default.impresora); this.Close(); }
/// <summary> /// Print RDLC File /// </summary> /// <returns></returns> public bool Print() { this.pageIndex = 0; this.pageStreams.Clear(); ReportPageSettings rps = this.localReport.GetDefaultPageSettings(); float pageWidth = 0f; float pageHeight = 0f; float marginTop = rps.Margins.Top / 100f; float marginLeft = rps.Margins.Left / 100f; float marginRight = rps.Margins.Right / 100f; float marginBottom = rps.Margins.Bottom / 100f; bool landscape = false; if (rps.PaperSize.Width > rps.PaperSize.Height) { pageWidth = rps.PaperSize.Width / 100f; pageHeight = rps.PaperSize.Height / 100f; landscape = false; } else { pageWidth = rps.PaperSize.Height / 100f; pageHeight = rps.PaperSize.Width / 100f; landscape = true; } string ImageDeviceInfo = string.Format(@"<DeviceInfo> <OutputFormat>EMF</OutputFormat> <PageWidth>{0}in</PageWidth> <PageHeight>{1}in</PageHeight> <MarginTop>{2}in</MarginTop> <MarginLeft>{3}in</MarginLeft> <MarginRight>{4}in</MarginRight> <MarginBottom>{5}in</MarginBottom> </DeviceInfo>", pageWidth, pageHeight, marginTop, marginLeft, marginRight, marginBottom); Warning[] warnings = null; try { this.localReport.Render("Image", ImageDeviceInfo, CreatePrintPageStream, out warnings); } catch (Exception ex) { MessageBox.Show(ex.Message); } if (warnings != null && warnings.Length > 0) { string warnMsg = string.Empty; foreach (Warning warning in warnings) { warnMsg += string.Format("WarningCode: {0} WarningMessage: {1}\r\n", warning.Code, warning.Message); } throw new Exception(warnMsg); } if (this.pageStreams == null || this.pageStreams.Count == 0) { return(false); } try { PageSetupDialog psd = new PageSetupDialog(); PrinterSettings printset = new PrinterSettings(); XmlDocument doc = new XmlDocument(); string xmlFile = AppDomain.CurrentDomain.BaseDirectory + "BugsBox.Pharmacy.AppClient.printSet.xml"; doc.Load(xmlFile); string s = System.Environment.CurrentDirectory; XmlNodeList nodelist = doc.SelectNodes("/printsets/pageset"); int wt = Convert.ToInt16(nodelist[0].Attributes["width"].Value); int ht = Convert.ToInt16(nodelist[1].Attributes["height"].Value); PaperSize pse = new PaperSize("Custom", wt, ht); PageSettings pageset = new PageSettings(); int Bottom = Convert.ToInt16(nodelist[2].Attributes["top"].Value); int Top = Convert.ToInt16(nodelist[3].Attributes["left"].Value); int Left = Convert.ToInt16(nodelist[4].Attributes["right"].Value); int Right = Convert.ToInt16(nodelist[5].Attributes["bottom"].Value); Margins margin = new Margins(Left, Right, Top, Bottom); pageset.Margins = margin; pageset.PaperSize = pse; printset.DefaultPageSettings.PaperSize = pse; psd.PrinterSettings = printset; psd.PageSettings = pageset; psd.PageSettings.PaperSize = pse; this.printDocument.PrinterSettings = psd.PrinterSettings; this.printPreview.Document = this.printDocument; this.printPreview.ShowDialog(); //使用image输出到文件后,可能会改变应用程序默认路径,所以。。。。。。。。 if (System.Environment.CurrentDirectory != s) { System.Environment.CurrentDirectory = s; } } catch (Exception ex) { MessageBox.Show("打印配置文件丢失,请检查!\n" + ex.Message); } return(true); }
private DriverKitchenPrint(string printerName, string paperName, string paperType) { string printConfigPath = AppDomain.CurrentDomain.BaseDirectory + "PrintConfig\\KitchenPrintSetting.config"; if (!File.Exists(printConfigPath)) { throw new ArgumentNullException("Print config file does not exist."); } DriverPrintSetting printSetting = XmlUtil.Deserialize <DriverPrintSetting>(printConfigPath); if (printSetting != null && printSetting.PrintConfigs != null && printSetting.PrintConfigs.Count > 0) { foreach (PrintConfig printConfig in printSetting.PrintConfigs) { if (printConfig.PaperType == paperType) { _curPrintConfig = printConfig; break; } } } if (_curPrintConfig != null) { if (_curPrintConfig.PrintLayouts != null && _curPrintConfig.PrintLayouts.LayoutList != null && _curPrintConfig.PrintLayouts.LayoutList.Count > 0) { foreach (var printLayout in _curPrintConfig.PrintLayouts.LayoutList) { if (printLayout.Key.Equals("KitchenPrint", StringComparison.CurrentCultureIgnoreCase)) { _kitchenPrintLayoutPath = string.Format("{0}PrintConfig\\{1}", AppDomain.CurrentDomain.BaseDirectory, printLayout.Value); } else if (printLayout.Key.Equals("DeskChangePrint", StringComparison.CurrentCultureIgnoreCase)) { _deskChangePrintLayoutPath = string.Format("{0}PrintConfig\\{1}", AppDomain.CurrentDomain.BaseDirectory, printLayout.Value); } } } } else { throw new ArgumentNullException(string.Format("Can not find the {0} paper type.", paperType)); } int width = 283, height = 1869; if (paperType.Equals("58mm", StringComparison.CurrentCultureIgnoreCase)) { width = 203; } else if (paperType.Equals("76mm", StringComparison.CurrentCultureIgnoreCase)) { width = 268; } else if (paperType.Equals("80mm", StringComparison.CurrentCultureIgnoreCase)) { width = 283; } _printDocument = new PrintDocument(); _printDocument.PrinterSettings.PrinterName = printerName; PaperSize paperSize = new PaperSize(paperName, width, height);//页面大小; foreach (PaperSize ps in _printDocument.PrinterSettings.PaperSizes) { if (ps.PaperName.Equals(paperName)) { paperSize = ps; } } _printDocument.DefaultPageSettings.PaperSize = paperSize; _printDocument.DefaultPageSettings.Landscape = false;//横向打印 _printDocument.PrintPage += new PrintPageEventHandler(pDoc_PrintPage); }
public PaperSize[] GetPaperSizeCollection() { PaperSize[] paperSizeList = new PaperSize[_printDocument.PrinterSettings.PaperSizes.Count]; _printDocument.PrinterSettings.PaperSizes.CopyTo(paperSizeList, 0); return(paperSizeList); }
private void SetPrintPagperSize() { PaperSize paperSize = new PaperSize("自定义页面", _printPanel.Width, _printPanel.Height); _printDocument.DefaultPageSettings.PaperSize = paperSize; }
public static float paperHeightInPt(PaperSize paperSize, PaperOrientation orientation) { return (float)paperHeightInTwip(paperSize, orientation) / 20.0F; }
public void getDXFFormat(DxfModel model, string filename, string outfile) { try { string extension = System.IO.Path.GetExtension(filename); if (string.Compare(extension, ".dwg", true) == 0) { model = DwgReader.Read(filename); } else { model = DxfReader.Read(filename); } } catch (Exception e) { //Console.Error.WriteLine("Error occurred: " + e.Message); //Environment.Exit(1); } GDIGraphics3D graphics = new GDIGraphics3D(GraphicsConfig.BlackBackgroundCorrectForBackColor); Size maxSize = new Size(500, 500); Bitmap bitmap = ImageExporter.CreateAutoSizedBitmap( model, graphics, Matrix4D.Identity, System.Drawing.Color.Black, maxSize ); //string outfile = Path.GetFileNameWithoutExtension(Path.GetFullPath(filename)); Stream stream = null; //string outfile = AppDomain.CurrentDomain.BaseDirectory + "Drill\\rockHistogram\\"+filename; BoundsCalculator boundsCalculator = new BoundsCalculator(); boundsCalculator.GetBounds(model); Bounds3D bounds = boundsCalculator.Bounds; PaperSize paperSize = PaperSizes.GetPaperSize(PaperKind.A4);//设置为A4纸的大小 // Lengths in inches. float pageWidth = (float)paperSize.Width / 100f; float pageHeight = (float)paperSize.Height / 100f; float margin = 0.2f; //值越小 model相对于pdf图幅越大 // Scale and transform such that its fits max width/height // and the top left middle of the cad drawing will match the // top middle of the pdf page. // The transform transforms to pdf pixels. Matrix4D to2DTransform = DxfUtil.GetScaleTransform( bounds.Corner1, bounds.Corner2, new Point3D(bounds.Center.X, bounds.Corner2.Y, 0d), new Point3D(new Vector3D(margin, margin, 0d) * PdfExporter.InchToPixel), new Point3D(new Vector3D(pageWidth - margin, pageHeight - margin, 0d) * PdfExporter.InchToPixel), new Point3D(new Vector3D(pageWidth / 2d, pageHeight - margin, 0d) * PdfExporter.InchToPixel) ); using (stream = File.Create(outfile + ".pdf")) { PdfExporter pdfGraphics = new PdfExporter(stream); pdfGraphics.DrawPage( model, GraphicsConfig.WhiteBackgroundCorrectForBackColor, to2DTransform, paperSize ); pdfGraphics.EndDocument(); } /* * 可选的图片格式 * stream = File.Create(outfile + ".png"); * ImageExporter.EncodeImageToPng(bitmap, stream); * * stream = File.Create(outfile + ".tiff"); * ImageExporter.EncodeImageToTiff(bitmap, stream); * * stream = File.Create(outfile + ".jpg"); * ImageExporter.EncodeImageToJpeg(bitmap, stream); * * stream = File.Create(outfile + ".gif"); * ImageExporter.EncodeImageToGif(bitmap, stream); * * stream = File.Create(outfile + ".bmp"); * ImageExporter.EncodeImageToBmp(bitmap, stream); */ }
public static string GetPaperSizeName(PaperSize paperSize) { string result; switch (paperSize) { case PaperSize.LedgerPortrait: result = "11x17"; break; case PaperSize.Ledger: result = "ledger"; break; case PaperSize.Legal: result = "legal"; break; case PaperSize.Letter: result = "letter"; break; case PaperSize.LetterSmall: result = "lettersmall"; break; case PaperSize.ArchE: result = "archE"; break; case PaperSize.ArchD: result = "archD"; break; case PaperSize.ArchC: result = "archC"; break; case PaperSize.ArchB: result = "archB"; break; case PaperSize.ArchA: result = "archA"; break; case PaperSize.A0: result = "a0"; break; case PaperSize.A1: result = "a1"; break; case PaperSize.A2: result = "a2"; break; case PaperSize.A3: result = "a3"; break; case PaperSize.A4: result = "a4"; break; case PaperSize.A5: result = "a5"; break; case PaperSize.A6: result = "a6"; break; case PaperSize.A7: result = "a7"; break; case PaperSize.A8: result = "a8"; break; case PaperSize.A9: result = "a9"; break; case PaperSize.A10: result = "a10"; break; case PaperSize.B0: result = "isob0"; break; case PaperSize.B1: result = "isob1"; break; case PaperSize.B2: result = "isob2"; break; case PaperSize.B3: result = "isob3"; break; case PaperSize.B4: result = "isob4"; break; case PaperSize.B5: result = "isob5"; break; case PaperSize.B6: result = "isob6"; break; case PaperSize.C0: result = "c0"; break; case PaperSize.C1: result = "c1"; break; case PaperSize.C2: result = "c2"; break; case PaperSize.C3: result = "c3"; break; case PaperSize.C4: result = "c4"; break; case PaperSize.C5: result = "c5"; break; case PaperSize.C6: result = "c6"; break; case PaperSize.Foolscap: result = "fse"; break; case PaperSize.HalfLetter: result = "halfletter"; break; case PaperSize.Hagaki: result = "hagaki"; break; default: throw new ArgumentException("Invalid paper size", "paperSize"); } return result; }
// Constructors public PaperSizeCollection(PaperSize[] array) {}