예제 #1
0
파일: PdfPage.cs 프로젝트: baluubas/Magic
		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);
		}
예제 #2
0
        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);
        }
예제 #3
0
        public RelativeSelection(
			Dimensions pageDimensions,
			double relativeOffsetX,
			double relativeOffsetY,
			double relativeWidth,
			double relativeHeight)
            : this(pageDimensions,
				relativeOffsetX,
				relativeOffsetY,
				relativeWidth,
				relativeHeight,
				0)
        {
        }
예제 #4
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);
        }
예제 #5
0
파일: PdfPage.cs 프로젝트: baluubas/Magic
		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;
		}
예제 #6
0
파일: PdfPage.cs 프로젝트: baluubas/Magic
		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;
		}
예제 #7
0
 public double ScaleRatioForDimension(Dimensions maxDimension)
 {
     var ratioX = maxDimension.Width / (_pageDimensions.Width * RelativeWidth);
     var ratioY = maxDimension.Height / (_pageDimensions.Height * RelativeHeight);
     return Math.Min(ratioX, ratioY);
 }