public PdfPage(IContainer container, IPdfRasterizer pdfRendering, PdfFile source, int pageIndex, float widthPt, float heightPt) { _container = container; _pdfRendering = pdfRendering; _source = source; _pageIndex = pageIndex; PageDimensions = new Dimensions(widthPt, heightPt); }
public Dimensions ScaleKeepRatio(Dimensions maxDimensionses) { var ratioX = maxDimensionses.Width / Width; var ratioY = maxDimensionses.Height / Height; var ratio = Math.Min(ratioX, ratioY); var newWidth = Width * ratio; var newHeight = Height * ratio; return new Dimensions(newWidth, newHeight); }
public RelativeSelection( Dimensions pageDimensions, double relativeOffsetX, double relativeOffsetY, double relativeWidth, double relativeHeight) : this(pageDimensions, relativeOffsetX, relativeOffsetY, relativeWidth, relativeHeight, 0) { }
public RelativeSelection( Dimensions pageDimensions, double relativeOffsetX, double relativeOffsetY, double relativeWidth, double relativeHeight, int rotation) { _pageDimensions = pageDimensions; RelativeOffsetX = relativeOffsetX; RelativeOffsetY = relativeOffsetY; RelativeWidth = relativeWidth; RelativeHeight = relativeHeight; Rotation = new Rotatation(rotation); }
private GhostscriptSettings CreateSetting(Dimensions dimensions, int dpi) { var result = new GhostscriptSettings(); result.Device = GhostscriptDevices.png16m; result.Resolution = new System.Drawing.Size(dpi, dpi); result.Page = new GhostscriptPages { AllPages = false, Start = _pageIndex, End = _pageIndex }; result.Size = new GhostscriptPageSize { Native = GhostscriptPageSizes.UNDEFINED, Manual = dimensions.ToSize() }; return result; }
private async Task<TemporaryBitmapFile> CreateRasterFile(Dimensions scaledSize, int dpi) { var tempFile = new TemporaryBitmapFile("png"); await _pdfRendering.GenerateOutput(_source.File, tempFile.FileName, CreateSetting(scaledSize, dpi)); return tempFile; }
public double ScaleRatioForDimension(Dimensions maxDimension) { var ratioX = maxDimension.Width / (_pageDimensions.Width * RelativeWidth); var ratioY = maxDimension.Height / (_pageDimensions.Height * RelativeHeight); return Math.Min(ratioX, ratioY); }