public void LoadDocument(Document document, string filename, bool attemptSingleImageMode, ResolutionDpi viewingResolution) { try { IntPtr docPtr = LibPdfium.LoadDocument(filename); for(int i = 0; i < LibPdfium.GetPageCount(docPtr); i++) { IntPtr pagePtr = LibPdfium.LoadPage(docPtr, i); double height = LibPdfium.GetPageHeight(pagePtr); double width = LibPdfium.GetPageWidth(pagePtr); SizeInches pageSize = new SizeInches(width, height); Page myPage = new PageFromPdf(filename, i, pageSize, attemptSingleImageMode, viewingResolution); document.AddPage(myPage); LibPdfium.ClosePage(pagePtr); } LibPdfium.CloseDocument(docPtr); } catch(Exception ex) { string msg = ex.Message; } }
public void LoadImagesFromFiles(Document document, string[] filenames, SizeInches size) { foreach(string filename in filenames) { LoadFromFile(document, filename, size); } }
public PageFromPdf(string filename, int pageIndex, SizeInches size, bool attemptSingleImageMode, ResolutionDpi viewingResolution) { fFilename = filename; fPageIndex = pageIndex; fSingleImageMode = attemptSingleImageMode; fViewingResolution = viewingResolution; Initialize(size, 0, 0); }
public Page() { fImageHandler = new ImageHandler(this); fLayoutThumbnail = null; fImageBoundsInches = null; fSizeInch = null; fResolutionDpi = null; }
public bool LoadFromFile(Document document, string filename, SizeInches size) { bool validFile; try { System.Drawing.Image image = Imaging.LoadImageFromFile(filename); validFile = true; } catch(Exception ex) { string msg = ex.Message; validFile = false; } if(validFile) { Page myPage = new PageFromFile(filename, size); document.AddPage(myPage); } return validFile; }
private void Scan(PageTypeEnum pageType) { ScanSettings settings = new ScanSettings(); SizeInches size; switch(pageType) { case PageTypeEnum.Letter: { size = SizeInches.Letter; } break; case PageTypeEnum.Legal: { size = SizeInches.Legal; } break; default: case PageTypeEnum.Custom: { size = new SizeInches(fAppSettings.ScannerCustomPageSize.Width, fAppSettings.ScannerCustomPageSize.Height); } break; } settings.ScanArea = new BoundsInches(0, 0, size); settings.EnableFeeder = fAppSettings.ScannerEnableFeeder; settings.ColorMode = fAppSettings.ScannerColorMode; settings.Resolution = fAppSettings.ScannerResolution; settings.Threshold = fAppSettings.ScannerThreshold; settings.Brightness = fAppSettings.ScannerBrightness; settings.Contrast = fAppSettings.ScannerContrast; settings.ShowSettingsUI = fAppSettings.ScannerUseNativeUI; settings.ShowTransferUI = true; fScanner.Acquire(fDocument, settings, fScanner_AcquireCallback); if(fLastScanned != pageType) { fLastScanned = pageType; RefreshButtonScanLabel(); } }
private void UIToSettings() { SizeInches customPageSize = new SizeInches((double)UpDownDoubleCustomPageWidth.Value, (double)UpDownDoubleCustomPageHeight.Value); fAppSettings.ScannerCustomPageSize = customPageSize; SizeInches defaultPageSize = new SizeInches((double)UpDownDoubleDefaultPageWidth.Value, (double)UpDownDoubleDefaultPageHeight.Value); fAppSettings.DefaultPageSize = defaultPageSize; switch(ComboBoxScannerColorMode.SelectedIndex) { default: case 0: fAppSettings.ScannerColorMode = Defines.ColorModeEnum.BW; break; case 1: fAppSettings.ScannerColorMode = Defines.ColorModeEnum.Gray; break; case 2: fAppSettings.ScannerColorMode = Defines.ColorModeEnum.RGB; break; } fAppSettings.ScannerResolution = (int)UpDownIntegerScannerResolution.Value; fAppSettings.ScannerThreshold = (double)UpDownDoubleScannerThreshold.Value; fAppSettings.ScannerBrightness = (double)UpDownDoubleScannerBrightness.Value; fAppSettings.ScannerContrast = (double)UpDownDoubleScannerContrast.Value; //switch(ComboBoxPageScaling.SelectedIndex) //{ // default: // case 0: fAppSettings.PageScaling = Defines.PageScalingEnum.UseDpi; break; // case 1: fAppSettings.PageScaling = Defines.PageScalingEnum.ShrinkOnly; break; // case 2: fAppSettings.PageScaling = Defines.PageScalingEnum.StretchShrink; break; //} fAppSettings.PdfViewingResolution = (int)UpDownIntegerDpiPdfRendering.Value; fAppSettings.PdfExportResolution = (int)UpDownIntegerDpiPdfExport.Value; fAppSettings.PdfExportCompressedImages = (bool)CheckBoxExportCompressImages.IsChecked; fAppSettings.PdfExportCompressionFactor = (int)UpDownIntegerExportCompressionFactor.Value; fAppSettings.PdfImportNativePages = (ComboBoxPdfImportAction.SelectedIndex == 0); fAppSettings.PdfImportSingleImages = (bool)CheckBoxPdfImageImport.IsChecked; fAppSettings.PdfExportRemovePagesAfter = (bool)CheckBoxRemovePagesPdfExport.IsChecked; fAppSettings.ShowPrintButton = (bool)CheckBoxShowPrintButton.IsChecked; }
public static IntPtr CreatePage(IntPtr document, SizeInches size) { int pageIndex = GetPageCount(document); double widthInPoints = size.Width * 72; double heightInPoints = size.Height * 72; return Pdfium.CreatePage(document, pageIndex, widthInPoints, heightInPoints); }
public BoundsInches(double x, double y, SizeInches size) : this(x, y, size.Width, size.Height) { }
public PageFromFile(string fileName, SizeInches size) { fFileName = fileName; Initialize(size, 0, 0); }
protected void Initialize(SizeInches pageSizeInches, int imageHorizontalDpi, int imageVerticalDpi) { fSizeInch = pageSizeInches; fImageHandler.Initialize(imageHorizontalDpi, imageVerticalDpi); RefreshLayout(); }
public void RotateSideways() { fSizeInch = fSizeInch.Transform(true); RefreshLayout(); }