private void SelectCustomPageSize(string name, PageDimensions dimens) { for (var i = 0; i < cmbPage.Items.Count; i++) { var item = (PageSizeListItem)cmbPage.Items[i]; if (item.Type != ScanPageSize.Custom || item.CustomName != name || item.CustomDimens != dimens) { continue; } cmbPage.SelectedIndex = i; return; } // Not found, so insert a new item cmbPage.Items.Insert(cmbPage.Items.Count - 1, new PageSizeListItem { Type = ScanPageSize.Custom, Label = string.IsNullOrEmpty(name) ? string.Format(MiscResources.CustomPageSizeFormat, dimens.Width, dimens.Height, dimens.Unit.Description()) : string.Format(MiscResources.NamedPageSizeFormat, name, dimens.Width, dimens.Height, dimens.Unit.Description()), CustomName = name, CustomDimens = dimens }); cmbPage.SelectedIndex = cmbPage.Items.Count - 2; }
protected override void OnLoad(object sender, EventArgs eventArgs) { new LayoutManager(this) .Bind(comboName) .WidthToForm() .Bind(textboxWidth, textboxHeight) .WidthTo(() => Width / 3) .Bind(comboUnit) .WidthTo(() => Width - 2 * (Width / 3)) .Bind(labelX) .LeftTo(() => textboxWidth.Right) .Bind(textboxHeight) .LeftTo(() => labelX.Right) .Bind(comboUnit) .LeftTo(() => textboxHeight.Right) .Bind(btnCancel, btnOK, btnDelete) .RightToForm() .Activate(); initialDimens = PageSizeDimens ?? ScanPageSize.Letter.PageDimensions(); UpdateDropdown(); comboName.Text = PageSizeName ?? ""; UpdateDimens(initialDimens); }
public static Bitmap PostProcessStep1(Image output, ScanProfile profile) { double scaleFactor = 1; if (!profile.UseNativeUI) { scaleFactor = profile.AfterScanScale.ToIntScaleFactor(); } var result = ImageScaleHelper.ScaleImage(output, scaleFactor); if (!profile.UseNativeUI && profile.ForcePageSize) { float width = output.Width / output.HorizontalResolution; float height = output.Height / output.VerticalResolution; if (float.IsNaN(width) || float.IsNaN(height)) { width = output.Width; height = output.Height; } PageDimensions pageDimensions = profile.PageSize.PageDimensions() ?? profile.CustomPageSize; if (pageDimensions.Width > pageDimensions.Height && width < height) { // Flip dimensions result.SetResolution((float)(output.Width / pageDimensions.HeightInInches()), (float)(output.Height / pageDimensions.WidthInInches())); } else { result.SetResolution((float)(output.Width / pageDimensions.WidthInInches()), (float)(output.Height / pageDimensions.HeightInInches())); } } return(result); }
void GetPageDimensions(Body Body, out PageDimensions Dim) { SectionProperties SectPr = Body.GetFirstChild <SectionProperties>(); PageSize PgSz = SectPr.GetFirstChild <PageSize>(); PageMargin Margin = SectPr.GetFirstChild <PageMargin>(); Dim = new PageDimensions(PgSz.Width, PgSz.Height, Margin.Left, Margin.Right, Margin.Top, Margin.Bottom); }
public DocReader(string filePath, string password, PageDimensions dimensions) { _dimensions = dimensions; lock (DocLib.Lock) { _docWrapper = new DocumentWrapper(filePath, password); } }
public DocReader(byte[] bytes, string password, PageDimensions dimensions) { _dimensions = dimensions; lock (DocLib.Lock) { _docWrapper = new DocumentWrapper(bytes, password); } }
public Bitmap PostProcessStep1(Image output, ScanProfile profile) { double scaleFactor = 1; if (!profile.UseNativeUI) { scaleFactor = profile.AfterScanScale.ToIntScaleFactor(); } var result = ImageScaleHelper.ScaleImage(output, scaleFactor); if (!profile.UseNativeUI && (profile.ForcePageSize || profile.ForcePageSizeCrop)) { float width = output.Width / output.HorizontalResolution; float height = output.Height / output.VerticalResolution; if (float.IsNaN(width) || float.IsNaN(height)) { width = output.Width; height = output.Height; } PageDimensions pageDimensions = profile.PageSize.PageDimensions() ?? profile.CustomPageSize; if (pageDimensions.Width > pageDimensions.Height && width < height) { if (profile.ForcePageSizeCrop) { result = new CropTransform { Right = (int)((width - (float)pageDimensions.HeightInInches()) * output.HorizontalResolution), Bottom = (int)((height - (float)pageDimensions.WidthInInches()) * output.VerticalResolution) }.Perform(result); } else { result.SetResolution((float)(output.Width / pageDimensions.HeightInInches()), (float)(output.Height / pageDimensions.WidthInInches())); } } else { if (profile.ForcePageSizeCrop) { result = new CropTransform { Right = (int)((width - (float)pageDimensions.WidthInInches()) * output.HorizontalResolution), Bottom = (int)((height - (float)pageDimensions.HeightInInches()) * output.VerticalResolution) }.Perform(result); } else { result.SetResolution((float)(output.Width / pageDimensions.WidthInInches()), (float)(output.Height / pageDimensions.HeightInInches())); } } } return(result); }
private void SaveSettings() { ScanPageSize pageSize; PageDimensions customPageSize = null; if (cmbPage.SelectedIndex > (int)ScanPageSize.Custom) { pageSize = ScanPageSize.Custom; customPageSize = (PageDimensions)cmbPage.SelectedItem; } else if (cmbPage.SelectedIndex == (int)ScanPageSize.Custom) { throw new InvalidOperationException("Custom page size should never be selected when saving"); } else { pageSize = (ScanPageSize)cmbPage.SelectedIndex; } ScanSettings = new ExtendedScanSettings { Version = ExtendedScanSettings.CURRENT_VERSION, Device = CurrentDevice, IsDefault = isDefault, DriverName = DeviceDriverName, DisplayName = txtName.Text, IconID = iconID, MaxQuality = cbHighQuality.Checked, UseNativeUI = rdbNative.Checked, AfterScanScale = (ScanScale)cmbScale.SelectedIndex, BitDepth = (ScanBitDepth)cmbDepth.SelectedIndex, Brightness = trBrightness.Value, Contrast = trContrast.Value, PageAlign = (ScanHorizontalAlign)cmbAlign.SelectedIndex, PageSize = pageSize, CustomPageSize = customPageSize, Resolution = (ScanDpi)cmbResolution.SelectedIndex, PaperSource = (ScanSource)cmbSource.SelectedIndex }; }
static void Main(string[] args) { IPdfDocument doc = new PdfDocument { Author = "Kaltek", Creator = "Kaltek", Keywords = "Kaltek, PDF, SkiaSharp", Subject = "Creating PDF Document", Title = "The PDF Document" }; PageDimensions dimensions = new PageDimensions(PaperType.Letter, PageOrientation.Portrait); var page = new PdfPage(dimensions) { BorderColor = Color.DarkGray, BorderWidth = 2 }; AddHeaderAndFooter(page); AddTestTable(page); doc.Pages.Add(page); PageDimensions dim2 = new PageDimensions(PaperType.Letter, PageOrientation.Landscape); page = new PdfPage(dim2) { BorderColor = Color.Red, BorderWidth = 3 }; AddHeaderAndFooter(page); AddImage(page); doc.Pages.Add(page); doc.Save($@"C:\Development\Tests\HelloWorld_{DateTime.Now:yyyyMMdd_hhmm_tt}.pdf"); }
public PageReader(DocumentWrapper docWrapper, int pageIndex, PageDimensions pageDimensions) { PageIndex = pageIndex; lock (DocLib.Lock) { _page = fpdf_view.FPDF_LoadPage(docWrapper.Instance, pageIndex); if (_page == null) { throw new DocnetException($"failed to open page for page index {pageIndex}"); } _text = fpdf_text.FPDFTextLoadPage(_page); if (_text == null) { throw new DocnetException($"failed to open page text for page index {pageIndex}"); } _scaling = pageDimensions.GetScalingFactor(_page); } }
private void btnOK_Click(object sender, EventArgs e) { const NumberStyles numberStyle = NumberStyles.AllowDecimalPoint | NumberStyles.AllowThousands | NumberStyles.AllowLeadingWhite | NumberStyles.AllowTrailingSign; decimal width, height; if (!decimal.TryParse(textboxWidth.Text, numberStyle, CultureInfo.CurrentCulture, out width)) { textboxWidth.Focus(); return; } if (!decimal.TryParse(textboxHeight.Text, numberStyle, CultureInfo.CurrentCulture, out height)) { textboxHeight.Focus(); return; } PageSizeName = null; PageSizeDimens = new PageDimensions { Width = width, Height = height, Unit = (PageSizeUnit)comboUnit.SelectedIndex }; if (!string.IsNullOrWhiteSpace(comboName.Text)) { PageSizeName = comboName.Text; var presets = UserConfigManager.Config.CustomPageSizePresets; presets.RemoveAll(x => x.Name == PageSizeName); presets.Add(new NamedPageSize { Name = PageSizeName, Dimens = PageSizeDimens }); UserConfigManager.Save(); } DialogResult = DialogResult.OK; Close(); }
private void btnOK_Click(object sender, EventArgs e) { const NumberStyles numberStyle = NumberStyles.AllowDecimalPoint | NumberStyles.AllowThousands | NumberStyles.AllowLeadingWhite | NumberStyles.AllowTrailingSign; decimal width, height; if (!decimal.TryParse(textboxWidth.Text, numberStyle, CultureInfo.CurrentCulture, out width)) { textboxWidth.Focus(); return; } if (!decimal.TryParse(textboxHeight.Text, numberStyle, CultureInfo.CurrentCulture, out height)) { textboxHeight.Focus(); return; } Result = new PageDimensions { Width = width, Height = height, Unit = (PageSizeUnit)comboUnit.SelectedIndex }; DialogResult = DialogResult.OK; Close(); }
private void ConfigureProps(WiaDevice device, WiaItem item) { if (ScanProfile.UseNativeUI) { return; } if (ScanProfile.PaperSource != ScanSource.Glass) { if (device.Version == WiaVersion.Wia10) { device.SetProperty(WiaPropertyId.DPS_PAGES, 1); } else { item.SetProperty(WiaPropertyId.IPS_PAGES, 0); } } if (device.Version == WiaVersion.Wia10) { switch (ScanProfile.PaperSource) { case ScanSource.Glass: device.SetProperty(WiaPropertyId.DPS_DOCUMENT_HANDLING_SELECT, WiaPropertyValue.FLATBED); break; case ScanSource.Feeder: device.SetProperty(WiaPropertyId.DPS_DOCUMENT_HANDLING_SELECT, WiaPropertyValue.FEEDER); break; case ScanSource.Duplex: device.SetProperty(WiaPropertyId.DPS_DOCUMENT_HANDLING_SELECT, WiaPropertyValue.FEEDER | WiaPropertyValue.DUPLEX); break; } } else { switch (ScanProfile.PaperSource) { case ScanSource.Feeder: item.SetProperty(WiaPropertyId.IPS_DOCUMENT_HANDLING_SELECT, WiaPropertyValue.FRONT_ONLY); break; case ScanSource.Duplex: item.SetProperty(WiaPropertyId.IPS_DOCUMENT_HANDLING_SELECT, WiaPropertyValue.DUPLEX | WiaPropertyValue.FRONT_FIRST); break; } } switch (ScanProfile.BitDepth) { case ScanBitDepth.Grayscale: item.SetProperty(WiaPropertyId.IPA_DATATYPE, 2); break; case ScanBitDepth.C24Bit: item.SetProperty(WiaPropertyId.IPA_DATATYPE, 3); break; case ScanBitDepth.BlackWhite: item.SetProperty(WiaPropertyId.IPA_DATATYPE, 0); break; } int xRes = ScanProfile.Resolution.ToIntDpi(); int yRes = xRes; item.SetPropertyClosest(WiaPropertyId.IPS_XRES, ref xRes); item.SetPropertyClosest(WiaPropertyId.IPS_YRES, ref yRes); PageDimensions pageDimensions = ScanProfile.PageSize.PageDimensions() ?? ScanProfile.CustomPageSize; if (pageDimensions == null) { throw new InvalidOperationException("No page size specified"); } int pageWidth = pageDimensions.WidthInThousandthsOfAnInch() * xRes / 1000; int pageHeight = pageDimensions.HeightInThousandthsOfAnInch() * yRes / 1000; int horizontalSize, verticalSize; if (device.Version == WiaVersion.Wia10) { horizontalSize = (int)device.Properties[ScanProfile.PaperSource == ScanSource.Glass ? WiaPropertyId.DPS_HORIZONTAL_BED_SIZE : WiaPropertyId.DPS_HORIZONTAL_SHEET_FEED_SIZE].Value; verticalSize = (int)device.Properties[ScanProfile.PaperSource == ScanSource.Glass ? WiaPropertyId.DPS_VERTICAL_BED_SIZE : WiaPropertyId.DPS_VERTICAL_SHEET_FEED_SIZE].Value; } else { horizontalSize = (int)item.Properties[WiaPropertyId.IPS_MAX_HORIZONTAL_SIZE].Value; verticalSize = (int)item.Properties[WiaPropertyId.IPS_MAX_VERTICAL_SIZE].Value; } int pagemaxwidth = horizontalSize * xRes / 1000; int pagemaxheight = verticalSize * yRes / 1000; int horizontalPos = 0; if (ScanProfile.PageAlign == ScanHorizontalAlign.Center) { horizontalPos = (pagemaxwidth - pageWidth) / 2; } else if (ScanProfile.PageAlign == ScanHorizontalAlign.Left) { horizontalPos = (pagemaxwidth - pageWidth); } pageWidth = pageWidth < pagemaxwidth ? pageWidth : pagemaxwidth; pageHeight = pageHeight < pagemaxheight ? pageHeight : pagemaxheight; if (ScanProfile.WiaOffsetWidth) { item.SetProperty(WiaPropertyId.IPS_XEXTENT, pageWidth + horizontalPos); item.SetProperty(WiaPropertyId.IPS_XPOS, horizontalPos); } else { item.SetProperty(WiaPropertyId.IPS_XEXTENT, pageWidth); item.SetProperty(WiaPropertyId.IPS_XPOS, horizontalPos); } item.SetProperty(WiaPropertyId.IPS_YEXTENT, pageHeight); if (!ScanProfile.BrightnessContrastAfterScan) { item.SetPropertyRange(WiaPropertyId.IPS_CONTRAST, ScanProfile.Contrast, -1000, 1000); item.SetPropertyRange(WiaPropertyId.IPS_BRIGHTNESS, ScanProfile.Brightness, -1000, 1000); } }
private void ConfigureDS(DataSource ds, ScanProfile scanProfile, ScanParams scanParams) { if (scanProfile.UseNativeUI) { return; } // Transfer Mode if (scanProfile.TwainImpl == TwainImpl.MemXfer) { ds.Capabilities.ICapXferMech.SetValue(XferMech.Memory); } // Paper Source switch (scanProfile.PaperSource) { case ScanSource.Glass: ds.Capabilities.CapFeederEnabled.SetValue(BoolType.False); ds.Capabilities.CapDuplexEnabled.SetValue(BoolType.False); break; case ScanSource.Feeder: ds.Capabilities.CapFeederEnabled.SetValue(BoolType.True); ds.Capabilities.CapDuplexEnabled.SetValue(BoolType.False); break; case ScanSource.Duplex: ds.Capabilities.CapFeederEnabled.SetValue(BoolType.True); ds.Capabilities.CapDuplexEnabled.SetValue(BoolType.True); break; } // Bit Depth switch (scanProfile.BitDepth) { case ScanBitDepth.C24Bit: ds.Capabilities.ICapPixelType.SetValue(PixelType.RGB); break; case ScanBitDepth.Grayscale: ds.Capabilities.ICapPixelType.SetValue(PixelType.Gray); break; case ScanBitDepth.BlackWhite: ds.Capabilities.ICapPixelType.SetValue(PixelType.BlackWhite); break; } // Page Size, Horizontal Align PageDimensions pageDimensions = scanProfile.PageSize.PageDimensions() ?? scanProfile.CustomPageSize; if (pageDimensions == null) { throw new InvalidOperationException("No page size specified"); } float pageWidth = pageDimensions.WidthInThousandthsOfAnInch() / 1000.0f; float pageHeight = pageDimensions.HeightInThousandthsOfAnInch() / 1000.0f; var pageMaxWidthFixed = ds.Capabilities.ICapPhysicalWidth.GetCurrent(); float pageMaxWidth = pageMaxWidthFixed.Whole + (pageMaxWidthFixed.Fraction / (float)UInt16.MaxValue); float horizontalOffset = 0.0f; if (scanProfile.PageAlign == ScanHorizontalAlign.Center) { horizontalOffset = (pageMaxWidth - pageWidth) / 2; } else if (scanProfile.PageAlign == ScanHorizontalAlign.Left) { horizontalOffset = (pageMaxWidth - pageWidth); } ds.Capabilities.ICapUnits.SetValue(Unit.Inches); TWImageLayout imageLayout; ds.DGImage.ImageLayout.Get(out imageLayout); imageLayout.Frame = new TWFrame { Left = horizontalOffset, Right = horizontalOffset + pageWidth, Top = 0, Bottom = pageHeight }; ds.DGImage.ImageLayout.Set(imageLayout); // Brightness, Contrast // Conveniently, the range of values used in settings (-1000 to +1000) is the same range TWAIN supports if (!scanProfile.BrightnessContrastAfterScan) { ds.Capabilities.ICapBrightness.SetValue(scanProfile.Brightness); ds.Capabilities.ICapContrast.SetValue(scanProfile.Contrast); } // Resolution int dpi = scanProfile.Resolution.ToIntDpi(); ds.Capabilities.ICapXResolution.SetValue(dpi); ds.Capabilities.ICapYResolution.SetValue(dpi); // Patch codes if (scanParams.DetectPatchCodes) { ds.Capabilities.ICapPatchCodeDetectionEnabled.SetValue(BoolType.True); } }
private static void ConfigureItemProperties(Device device, Item item, ExtendedScanSettings settings) { switch (settings.BitDepth) { case ScanBitDepth.Grayscale: SetItemIntProperty(item, 2, ItemProperties.DATA_TYPE); break; case ScanBitDepth.C24Bit: SetItemIntProperty(item, 3, ItemProperties.DATA_TYPE); break; case ScanBitDepth.BlackWhite: SetItemIntProperty(item, 0, ItemProperties.DATA_TYPE); break; } int resolution = settings.Resolution.ToIntDpi(); SetItemIntProperty(item, resolution, ItemProperties.VERTICAL_RESOLUTION); SetItemIntProperty(item, resolution, ItemProperties.HORIZONTAL_RESOLUTION); PageDimensions pageDimensions = settings.PageSize.PageDimensions() ?? settings.CustomPageSize; if (pageDimensions == null) { throw new InvalidOperationException("No page size specified"); } int pageWidth = pageDimensions.WidthInThousandthsOfAnInch() * resolution / 1000; int pageHeight = pageDimensions.HeightInThousandthsOfAnInch() * resolution / 1000; int horizontalSize = GetDeviceIntProperty(device, settings.PaperSource == ScanSource.Glass ? DeviceProperties.HORIZONTAL_BED_SIZE : DeviceProperties.HORIZONTAL_FEED_SIZE); int verticalSize = GetDeviceIntProperty(device, settings.PaperSource == ScanSource.Glass ? DeviceProperties.VERTICAL_BED_SIZE : DeviceProperties.VERTICAL_FEED_SIZE); int pagemaxwidth = horizontalSize * resolution / 1000; int pagemaxheight = verticalSize * resolution / 1000; int horizontalPos = 0; if (settings.PageAlign == ScanHorizontalAlign.Center) { horizontalPos = (pagemaxwidth - pageWidth) / 2; } else if (settings.PageAlign == ScanHorizontalAlign.Left) { horizontalPos = (pagemaxwidth - pageWidth); } pageWidth = pageWidth < pagemaxwidth ? pageWidth : pagemaxwidth; pageHeight = pageHeight < pagemaxheight ? pageHeight : pagemaxheight; SetItemIntProperty(item, pageWidth, ItemProperties.HORIZONTAL_EXTENT); SetItemIntProperty(item, pageHeight, ItemProperties.VERTICAL_EXTENT); SetItemIntProperty(item, horizontalPos, ItemProperties.HORIZONTAL_START); SetItemIntProperty(item, settings.Contrast, -1000, 1000, ItemProperties.CONTRAST); SetItemIntProperty(item, settings.Brightness, -1000, 1000, ItemProperties.BRIGHTNESS); }
/// <inheritdoc /> public IDocReader GetDocReader(byte[] bytes, string password, PageDimensions dimensionOptions) { Validator.CheckBytesNullOrZero(bytes, nameof(bytes)); return(new DocReader(bytes, password, dimensionOptions)); }
/// <inheritdoc /> public IDocReader GetDocReader(byte[] bytes, PageDimensions dimensionOptions) { return(GetDocReader(bytes, null, dimensionOptions)); }
/// <inheritdoc /> public IDocReader GetDocReader(string filePath, string password, PageDimensions dimensionOptions) { Validator.CheckFilePathNotNull(filePath, nameof(filePath)); return(new DocReader(filePath, password, dimensionOptions)); }
/// <inheritdoc /> public IDocReader GetDocReader(string filePath, PageDimensions dimensionOptions) { return(GetDocReader(filePath, null, dimensionOptions)); }
protected void Page_Load(object sender, EventArgs e) { //Live SLX //ceTe.DynamicPDF.Document.AddLicense("MER60NPSJJDBEFbTKXo9DTKh84Ls4R90/YApxJTfZnNXdoXd5/+oVV0yrnWOCDd5iUS9kpu3YCN/0YH81AoPprVEeuNctj7N3tdg"); //Development ceTe.DynamicPDF.Document.AddLicense("MER40NPSGMHANPtrOOqTu5LFwXFK80OvGQYSH+Wd2Zc6PNmiwQSdLIIxVDgSRI32WB88Dxhpt7mqjdh9jiwh41ZVSO91EeKDq87w"); //Create a PDF Document Document document = new Document(); document.Creator = "Invoice.aspx"; document.Author = "Career Cruising"; document.Title = "Invoice"; DataTable dt1; DataTable dt2; StringBuilder sbSQL1 = new StringBuilder(""); StringBuilder sbSQL2 = new StringBuilder(""); string pagePath = @"C:\newmedia\EmptyInvoice.pdf"; string strInvoiceNo, strDate, strPONumber; string strInvoiceContactPerson, strInvoiceCustomerName, strInvoiceAddress1, strInvoiceCity, strInvoiceState, strInvoiceZip; string strRequestByContactPerson, strRequestByAddress1, strRequestByAddress2, strInvoiceCity2, strInvoiceState2, strInvoiceZip2; string strStartDate, strEndDate; string strNotes; string strQuantity, strProductDescripton, strUnitPrice, strPrice; string strSubtotal, strMiscAmount, strFreightAmount, strTaxAmount, strTotal; string strCurrentInvoiceNo; string strFileName; Array[] pdfCoords = new Array[11]; string strConnectionString = "Data Source=192.168.11.5,1433;Network Library=DBMSSOCN;Initial Catalog=GPCC;User ID=ccwebadmin;Password=crm5au1g;"; strCurrentInvoiceNo = Request.QueryString["InvoiceNo"] != null ? Request.QueryString["InvoiceNo"].Trim() : ""; //strCurrentInvoiceNo = "C1004018"; strFileName = Request.QueryString["FileName"] != null ? Request.QueryString["FileName"].Trim() : ""; if (strCurrentInvoiceNo != "") { pdfCoords[0] = new int[4, 4] { { 30, 295, 40, 20 }, { 75, 295, 295, 20 }, { 375, 295, 55, 20 }, { 436, 295, 70, 20 } }; pdfCoords[1] = new int[4, 4] { { 30, 320, 40, 20 }, { 75, 320, 295, 20 }, { 375, 320, 55, 20 }, { 436, 320, 70, 20 } }; pdfCoords[2] = new int[4, 4] { { 30, 345, 40, 20 }, { 75, 345, 295, 20 }, { 375, 345, 55, 20 }, { 436, 345, 70, 20 } }; pdfCoords[3] = new int[4, 4] { { 30, 370, 40, 20 }, { 75, 370, 295, 20 }, { 375, 370, 55, 20 }, { 436, 370, 70, 20 } }; pdfCoords[4] = new int[4, 4] { { 30, 395, 40, 20 }, { 75, 395, 295, 20 }, { 375, 395, 55, 20 }, { 436, 395, 70, 20 } }; pdfCoords[5] = new int[4, 4] { { 30, 420, 40, 20 }, { 75, 420, 295, 20 }, { 375, 420, 55, 20 }, { 436, 420, 70, 20 } }; pdfCoords[6] = new int[4, 4] { { 30, 445, 40, 20 }, { 75, 445, 295, 20 }, { 375, 445, 55, 20 }, { 436, 445, 70, 20 } }; pdfCoords[7] = new int[4, 4] { { 30, 470, 40, 20 }, { 75, 470, 295, 20 }, { 375, 470, 55, 20 }, { 436, 470, 70, 20 } }; pdfCoords[8] = new int[4, 4] { { 30, 495, 40, 20 }, { 75, 495, 295, 20 }, { 375, 495, 55, 20 }, { 436, 495, 70, 20 } }; pdfCoords[9] = new int[4, 4] { { 30, 520, 40, 20 }, { 75, 520, 295, 20 }, { 375, 520, 55, 20 }, { 436, 520, 70, 20 } }; pdfCoords[10] = new int[4, 4] { { 30, 545, 40, 20 }, { 75, 545, 295, 20 }, { 375, 545, 55, 20 }, { 436, 545, 70, 20 } }; sbSQL1.Append("SELECT "); sbSQL1.Append("A.SOPNUMBE AS [Invoice No],"); sbSQL1.Append("CONVERT(VARCHAR(10), A.DOCDATE, 101) AS [Date],"); sbSQL1.Append("A.CSTPONBR AS [PO Number],"); sbSQL1.Append("B.CNTCPRSN AS [Invoice Contact Person],"); sbSQL1.Append("A.CUSTNAME AS [Invoice Customer Name],"); sbSQL1.Append("B.ADDRESS1 AS [Invoice Address1],"); sbSQL1.Append("B.ADDRESS2 AS [Invoice Address2],"); sbSQL1.Append("B.ADDRESS3 AS [Invoice Address3],"); sbSQL1.Append("B.CITY AS [Invoice City],"); sbSQL1.Append("B.STATE AS [Invoice State],"); sbSQL1.Append("B.ZIP AS [Invoice Zip],"); sbSQL1.Append("A.CNTCPRSN AS [Request By Contact Person],"); sbSQL1.Append("A.ADDRESS1 AS [Request By Address1],"); sbSQL1.Append("A.ADDRESS2 AS [Request By Address2],"); sbSQL1.Append("A.ADDRESS3 AS [Request By Address3],"); sbSQL1.Append("A.CITY AS [Invoice City 2],"); sbSQL1.Append("A.STATE AS [Invoice State 2],"); sbSQL1.Append("A.ZIPCODE AS [Invoice Zip 2],"); sbSQL1.Append("CONVERT(varchar, CONVERT(money, A.ORSUBTOT), 1) AS [Subtotal],"); sbSQL1.Append("CONVERT(varchar, CONVERT(money, A.ORMISCAMT), 1) AS [Misc Amount],"); sbSQL1.Append("CONVERT(varchar, CONVERT(money, A.ORFRTAMT), 1) AS [Freight Amount],"); sbSQL1.Append("CONVERT(varchar, CONVERT(money, A.ORTAXAMT), 1) AS [Tax Amount],"); sbSQL1.Append("CONVERT(varchar, CONVERT(money, A.ORDOCAMT), 1) AS [Total],"); sbSQL1.Append("C.TXTFIELD AS [Notes],"); sbSQL1.Append("CONVERT(VARCHAR(10), D.USRDAT01, 101) AS [Start Date],"); sbSQL1.Append("CONVERT(VARCHAR(10), D.USRDAT02, 101) AS [End Date] "); sbSQL1.Append("FROM SOP30200 A "); sbSQL1.Append("LEFT OUTER JOIN RM00102 B "); sbSQL1.Append("ON A.CUSTNMBR = B.CUSTNMBR AND "); sbSQL1.Append("A.PRBTADCD = B.ADRSCODE "); sbSQL1.Append("LEFT OUTER JOIN SY03900 C "); sbSQL1.Append("ON A.NOTEINDX = C.NOTEINDX "); sbSQL1.Append("LEFT OUTER JOIN SOP10106 D "); sbSQL1.Append("ON A.SOPTYPE = D.SOPTYPE AND "); sbSQL1.Append("A.SOPNUMBE = D.SOPNUMBE "); sbSQL1.Append("WHERE A.SOPNUMBE = '"); sbSQL1.Append(strCurrentInvoiceNo); sbSQL1.Append("'"); // Create a page dimensions object and set the margins PageDimensions dimensions = new PageDimensions(PageSize.Letter, PageOrientation.Portrait); dimensions.BottomMargin = 20; dimensions.TopMargin = 20; dimensions.LeftMargin = 20; dimensions.RightMargin = 20; // Create a page using a page dimensions object and add it to the document //ceTe.DynamicPDF.Page page = new ceTe.DynamicPDF.Page(dimensions); ceTe.DynamicPDF.Page page = new ceTe.DynamicPDF.Merger.ImportedPage(pagePath, 1); page.Dimensions = dimensions; document.Pages.Add(page); //dt1 = DataAccess.GetDataTable(sbSQL1.ToString()); dt1 = CareerCruisingWeb.CCLib.SqlHelper.GetDataTable(strConnectionString, sbSQL1.ToString()); if (dt1.Rows.Count > 0) { strInvoiceNo = dt1.Rows[0]["Invoice No"] != null ? dt1.Rows[0]["Invoice No"].ToString() : ""; strDate = dt1.Rows[0]["Date"] != null ? dt1.Rows[0]["Date"].ToString() : ""; strPONumber = dt1.Rows[0]["PO Number"] != null ? dt1.Rows[0]["PO Number"].ToString() : ""; strInvoiceContactPerson = dt1.Rows[0]["Invoice Contact Person"] != null ? dt1.Rows[0]["Invoice Contact Person"].ToString() : ""; strInvoiceCustomerName = dt1.Rows[0]["Invoice Customer Name"] != null ? dt1.Rows[0]["Invoice Customer Name"].ToString() : ""; strInvoiceAddress1 = dt1.Rows[0]["Invoice Address1"] != null ? dt1.Rows[0]["Invoice Address1"].ToString() : ""; strInvoiceCity = dt1.Rows[0]["Invoice City"] != null ? dt1.Rows[0]["Invoice City"].ToString() : ""; strInvoiceState = dt1.Rows[0]["Invoice State"] != null ? dt1.Rows[0]["Invoice State"].ToString() : ""; strInvoiceZip = dt1.Rows[0]["Invoice Zip"] != null ? dt1.Rows[0]["Invoice Zip"].ToString() : ""; strRequestByContactPerson = dt1.Rows[0]["Request By Contact Person"] != null ? dt1.Rows[0]["Request By Contact Person"].ToString() : ""; strRequestByAddress1 = dt1.Rows[0]["Request By Address1"] != null ? dt1.Rows[0]["Request By Address1"].ToString() : ""; strRequestByAddress2 = dt1.Rows[0]["Request By Address2"] != null ? dt1.Rows[0]["Request By Address2"].ToString() : ""; strInvoiceCity2 = dt1.Rows[0]["Invoice City 2"] != null ? dt1.Rows[0]["Invoice City 2"].ToString() : ""; strInvoiceState2 = dt1.Rows[0]["Invoice State 2"] != null ? dt1.Rows[0]["Invoice State 2"].ToString() : ""; strInvoiceZip2 = dt1.Rows[0]["Invoice Zip 2"] != null ? dt1.Rows[0]["Invoice Zip 2"].ToString() : ""; strStartDate = dt1.Rows[0]["Start Date"] != null ? dt1.Rows[0]["Start Date"].ToString() : ""; strEndDate = dt1.Rows[0]["End Date"] != null ? dt1.Rows[0]["End Date"].ToString() : ""; strNotes = dt1.Rows[0]["Notes"] != null ? dt1.Rows[0]["Notes"].ToString() : ""; strSubtotal = dt1.Rows[0]["Subtotal"] != null ? dt1.Rows[0]["Subtotal"].ToString() : ""; strMiscAmount = dt1.Rows[0]["Misc Amount"] != null ? dt1.Rows[0]["Misc Amount"].ToString() : ""; strFreightAmount = dt1.Rows[0]["Freight Amount"] != null ? dt1.Rows[0]["Freight Amount"].ToString() : ""; strTaxAmount = dt1.Rows[0]["Tax Amount"] != null ? dt1.Rows[0]["Tax Amount"].ToString() : ""; strTotal = dt1.Rows[0]["Total"] != null ? dt1.Rows[0]["Total"].ToString() : ""; //Add labels to the page //Invoice No. page.Elements.Add(new ceTe.DynamicPDF.PageElements.Label(strInvoiceNo.Trim(), 110, 62, 100, 10, Font.Helvetica, 8)); //Date page.Elements.Add(new ceTe.DynamicPDF.PageElements.Label(strDate.Trim(), 110, 74, 100, 10, Font.Helvetica, 8)); //PO Number page.Elements.Add(new ceTe.DynamicPDF.PageElements.Label(strPONumber.Trim(), 110, 86, 100, 10, Font.Helvetica, 8)); //Invoice To //Invoice Contact Person page.Elements.Add(new ceTe.DynamicPDF.PageElements.Label(strInvoiceContactPerson.Trim(), 30, 120, 230, 10, Font.Helvetica, 8)); //Invoice Customer Name page.Elements.Add(new ceTe.DynamicPDF.PageElements.Label(strInvoiceCustomerName.Trim(), 30, 130, 230, 10, Font.Helvetica, 8)); //Invoice Address1 page.Elements.Add(new ceTe.DynamicPDF.PageElements.Label(strInvoiceAddress1.Trim(), 30, 140, 230, 10, Font.Helvetica, 8)); //Invoice City + Invoice State + Invoice Zip page.Elements.Add(new ceTe.DynamicPDF.PageElements.Label(strInvoiceCity.Trim() + " " + strInvoiceState.Trim() + " " + strInvoiceZip.Trim(), 30, 150, 230, 10, Font.Helvetica, 8)); //Requested By //Request By Contact Person page.Elements.Add(new ceTe.DynamicPDF.PageElements.Label(strRequestByContactPerson.Trim(), 30, 208, 230, 10, Font.Helvetica, 8)); //Request By Address1 page.Elements.Add(new ceTe.DynamicPDF.PageElements.Label(strRequestByAddress1.Trim(), 30, 218, 230, 10, Font.Helvetica, 8)); //Request By Address2 page.Elements.Add(new ceTe.DynamicPDF.PageElements.Label(strRequestByAddress2.Trim(), 30, 228, 230, 10, Font.Helvetica, 8)); //Invoice City 2 + Invoice State 2 + Invoice Zip 2 page.Elements.Add(new ceTe.DynamicPDF.PageElements.Label(strInvoiceCity2.Trim() + " " + strInvoiceState2.Trim() + " " + strInvoiceZip2.Trim(), 30, 238, 230, 10, Font.Helvetica, 8)); //Start Date page.Elements.Add(new ceTe.DynamicPDF.PageElements.Label(strStartDate.Trim(), 430, 74, 80, 10, Font.Helvetica, 8)); //End Date page.Elements.Add(new ceTe.DynamicPDF.PageElements.Label(strEndDate.Trim(), 430, 86, 80, 10, Font.Helvetica, 8)); //Note page.Elements.Add(new ceTe.DynamicPDF.PageElements.Label(strNotes.Trim(), 288, 118, 215, 140, Font.Helvetica, 8)); //Summary //Subtotal page.Elements.Add(new ceTe.DynamicPDF.PageElements.Label("$" + strSubtotal, 436, 571, 70, 10, Font.Helvetica, 8)); //Misc Amount page.Elements.Add(new ceTe.DynamicPDF.PageElements.Label("$" + strMiscAmount, 436, 583, 70, 10, Font.Helvetica, 8)); //Freight Amount page.Elements.Add(new ceTe.DynamicPDF.PageElements.Label("$" + strFreightAmount, 436, 594, 70, 10, Font.Helvetica, 8)); //Tax Amount page.Elements.Add(new ceTe.DynamicPDF.PageElements.Label("$" + strTaxAmount, 436, 605, 70, 10, Font.Helvetica, 8)); //Total page.Elements.Add(new ceTe.DynamicPDF.PageElements.Label("$" + strTotal, 436, 616, 70, 10, Font.Helvetica, 8)); //Grid Area sbSQL2.Append("SELECT "); sbSQL2.Append("CONVERT(int, QTYTOINV) AS [Quantity],"); sbSQL2.Append("ITEMDESC AS [Product Descripton],"); sbSQL2.Append("CONVERT(varchar, CONVERT(money, ORUNTPRC), 1) AS [Unit Price],"); sbSQL2.Append("CONVERT(varchar, CONVERT(money, OREPRICE), 1) AS [Price] "); sbSQL2.Append("FROM SOP30300 "); sbSQL2.Append("WHERE SOPNUMBE = '"); sbSQL2.Append(strCurrentInvoiceNo); sbSQL2.Append("'"); dt2 = CareerCruisingWeb.CCLib.SqlHelper.GetDataTable(strConnectionString, sbSQL2.ToString()); if (dt2.Rows.Count > 0) { for (int i = 0; i < dt2.Rows.Count; i++) { strQuantity = dt2.Rows[i]["Quantity"] != null ? dt2.Rows[i]["Quantity"].ToString() : ""; strProductDescripton = dt2.Rows[i]["Product Descripton"] != null ? dt2.Rows[i]["Product Descripton"].ToString() : ""; strUnitPrice = dt2.Rows[i]["Unit Price"] != null ? dt2.Rows[i]["Unit Price"].ToString() : ""; strPrice = dt2.Rows[i]["Price"] != null ? dt2.Rows[i]["Price"].ToString() : ""; page.Elements.Add(new ceTe.DynamicPDF.PageElements.Label(strQuantity, (int)pdfCoords[i].GetValue(0, 0), (int)pdfCoords[i].GetValue(0, 1), (int)pdfCoords[i].GetValue(0, 2), (int)pdfCoords[i].GetValue(0, 3), Font.Helvetica, 8)); page.Elements.Add(new ceTe.DynamicPDF.PageElements.Label(strProductDescripton, (int)pdfCoords[i].GetValue(1, 0), (int)pdfCoords[i].GetValue(1, 1), (int)pdfCoords[i].GetValue(1, 2), (int)pdfCoords[i].GetValue(1, 3), Font.Helvetica, 8)); page.Elements.Add(new ceTe.DynamicPDF.PageElements.Label("$" + strUnitPrice, (int)pdfCoords[i].GetValue(2, 0), (int)pdfCoords[i].GetValue(2, 1), (int)pdfCoords[i].GetValue(2, 2), (int)pdfCoords[i].GetValue(2, 3), Font.Helvetica, 8)); page.Elements.Add(new ceTe.DynamicPDF.PageElements.Label("$" + strPrice, (int)pdfCoords[i].GetValue(3, 0), (int)pdfCoords[i].GetValue(3, 1), (int)pdfCoords[i].GetValue(3, 2), (int)pdfCoords[i].GetValue(3, 3), Font.Helvetica, 8)); } } //page.Elements.Add(new ceTe.DynamicPDF.PageElements.Label(strQuantity, 30, 320, 40, 20, Font.Helvetica, 8)); ////Product Descripton //page.Elements.Add(new ceTe.DynamicPDF.PageElements.Label(strProductDescripton, 75, 320, 295, 20, Font.Helvetica, 8)); ////Unit Price //page.Elements.Add(new ceTe.DynamicPDF.PageElements.Label(strUnitPrice, 375, 320, 55, 20, Font.Helvetica, 8)); ////Price //page.Elements.Add(new ceTe.DynamicPDF.PageElements.Label(strPrice, 436, 320, 70, 20, Font.Helvetica, 8)); //Quantity //page.Elements.Add(new ceTe.DynamicPDF.PageElements.Label(strQuantity, 30, 345, 40, 20, Font.Helvetica, 8)); ////Product Descripton //page.Elements.Add(new ceTe.DynamicPDF.PageElements.Label(strProductDescripton, 75, 345, 295, 20, Font.Helvetica, 8)); ////Unit Price //page.Elements.Add(new ceTe.DynamicPDF.PageElements.Label(strUnitPrice, 375, 345, 55, 20, Font.Helvetica, 8)); ////Price //page.Elements.Add(new ceTe.DynamicPDF.PageElements.Label(strPrice, 436, 345, 70, 20, Font.Helvetica, 8)); //Quantity //page.Elements.Add(new ceTe.DynamicPDF.PageElements.Label(strQuantity, 30, 370, 40, 20, Font.Helvetica, 8)); ////Product Descripton //page.Elements.Add(new ceTe.DynamicPDF.PageElements.Label(strProductDescripton, 75, 370, 295, 20, Font.Helvetica, 8)); ////Unit Price //page.Elements.Add(new ceTe.DynamicPDF.PageElements.Label(strUnitPrice, 375, 370, 55, 20, Font.Helvetica, 8)); ////Price //page.Elements.Add(new ceTe.DynamicPDF.PageElements.Label(strPrice, 436, 370, 70, 20, Font.Helvetica, 8)); //Quantity //page.Elements.Add(new ceTe.DynamicPDF.PageElements.Label(strQuantity, 30, 395, 40, 20, Font.Helvetica, 8)); ////Product Descripton //page.Elements.Add(new ceTe.DynamicPDF.PageElements.Label(strProductDescripton, 75, 395, 295, 20, Font.Helvetica, 8)); ////Unit Price //page.Elements.Add(new ceTe.DynamicPDF.PageElements.Label(strUnitPrice, 375, 395, 55, 20, Font.Helvetica, 8)); ////Price //page.Elements.Add(new ceTe.DynamicPDF.PageElements.Label(strPrice, 436, 395, 70, 20, Font.Helvetica, 8)); //Quantity //page.Elements.Add(new ceTe.DynamicPDF.PageElements.Label(strQuantity, 30, 420, 40, 20, Font.Helvetica, 8)); ////Product Descripton //page.Elements.Add(new ceTe.DynamicPDF.PageElements.Label(strProductDescripton, 75, 420, 295, 20, Font.Helvetica, 8)); ////Unit Price //page.Elements.Add(new ceTe.DynamicPDF.PageElements.Label(strUnitPrice, 375, 420, 55, 20, Font.Helvetica, 8)); ////Price //page.Elements.Add(new ceTe.DynamicPDF.PageElements.Label(strPrice, 436, 420, 70, 20, Font.Helvetica, 8)); //Quantity //page.Elements.Add(new ceTe.DynamicPDF.PageElements.Label(strQuantity, 30, 445, 40, 20, Font.Helvetica, 8)); ////Product Descripton //page.Elements.Add(new ceTe.DynamicPDF.PageElements.Label(strProductDescripton, 75, 445, 295, 20, Font.Helvetica, 8)); ////Unit Price //page.Elements.Add(new ceTe.DynamicPDF.PageElements.Label(strUnitPrice, 375, 445, 55, 20, Font.Helvetica, 8)); ////Price //page.Elements.Add(new ceTe.DynamicPDF.PageElements.Label(strPrice, 436, 445, 70, 20, Font.Helvetica, 8)); //Quantity //page.Elements.Add(new ceTe.DynamicPDF.PageElements.Label(strQuantity, 30, 470, 40, 20, Font.Helvetica, 8)); ////Product Descripton //page.Elements.Add(new ceTe.DynamicPDF.PageElements.Label(strProductDescripton, 75, 470, 295, 20, Font.Helvetica, 8)); ////Unit Price //page.Elements.Add(new ceTe.DynamicPDF.PageElements.Label(strUnitPrice, 375, 470, 55, 20, Font.Helvetica, 8)); ////Price //page.Elements.Add(new ceTe.DynamicPDF.PageElements.Label(strPrice, 436, 470, 70, 20, Font.Helvetica, 8)); //Quantity //page.Elements.Add(new ceTe.DynamicPDF.PageElements.Label(strQuantity, 30, 495, 40, 20, Font.Helvetica, 8)); ////Product Descripton //page.Elements.Add(new ceTe.DynamicPDF.PageElements.Label(strProductDescripton, 75, 495, 295, 20, Font.Helvetica, 8)); ////Unit Price //page.Elements.Add(new ceTe.DynamicPDF.PageElements.Label(strUnitPrice, 375, 495, 55, 20, Font.Helvetica, 8)); ////Price //page.Elements.Add(new ceTe.DynamicPDF.PageElements.Label(strPrice, 436, 495, 70, 20, Font.Helvetica, 8)); //Quantity //page.Elements.Add(new ceTe.DynamicPDF.PageElements.Label(strQuantity, 30, 520, 40, 20, Font.Helvetica, 8)); ////Product Descripton //page.Elements.Add(new ceTe.DynamicPDF.PageElements.Label(strProductDescripton, 75, 520, 295, 20, Font.Helvetica, 8)); ////Unit Price //page.Elements.Add(new ceTe.DynamicPDF.PageElements.Label(strUnitPrice, 375, 520, 55, 20, Font.Helvetica, 8)); ////Price //page.Elements.Add(new ceTe.DynamicPDF.PageElements.Label(strPrice, 436, 520, 70, 20, Font.Helvetica, 8)); //Quantity //page.Elements.Add(new ceTe.DynamicPDF.PageElements.Label(strQuantity, 30, 545, 40, 20, Font.Helvetica, 8)); ////Product Descripton //page.Elements.Add(new ceTe.DynamicPDF.PageElements.Label(strProductDescripton, 75, 545, 295, 20, Font.Helvetica, 8)); ////Unit Price //page.Elements.Add(new ceTe.DynamicPDF.PageElements.Label(strUnitPrice, 375, 545, 55, 20, Font.Helvetica, 8)); ////Price //page.Elements.Add(new ceTe.DynamicPDF.PageElements.Label(strPrice, 436, 545, 70, 20, Font.Helvetica, 8)); if (strFileName != "") { //Save the PDF file in the folder document.Draw(@"C:\newmedia\" + strFileName); //Display the web_based PDF file on the browser document.DrawToWeb(strFileName); } else { string strMonth = DateTime.Now.Month.ToString(); string strDay = DateTime.Now.Day.ToString(); string strYear = DateTime.Now.Year.ToString(); string strCurrentDate = strMonth + "-" + strDay + "-" + strYear; //Save the PDF file in the folder document.Draw(@"C:\newmedia\" + strCurrentInvoiceNo + "_" + strCurrentDate + @"_Invoice.pdf"); //Display the web_based PDF file on the browser document.DrawToWeb(strCurrentInvoiceNo + "_" + strCurrentDate + @"_Invoice.pdf"); } Response.End(); } else { Response.Write("This invoice doesn't exist in the GP system"); } } else { Response.Write("Please provide the Invoice Number"); } }
private void UpdateDimens(PageDimensions dimens) { textboxWidth.Text = dimens.Width.ToString(CultureInfo.CurrentCulture); textboxHeight.Text = dimens.Height.ToString(CultureInfo.CurrentCulture); comboUnit.SelectedIndex = (int)dimens.Unit; }
//Additional Parameter go here public PageLayout() { Dimensions = new PageDimensions(PageSize.Letter, PageOrientation.Portrait, 54.0f); BodyTop = 200; }