itextsharp的颜色空间-成都创新互联网站建设

关于创新互联

多方位宣传企业产品与服务 突出企业形象

公司简介 公司的服务 荣誉资质 新闻动态 联系我们

itextsharp的颜色空间

string filename = DateTime.Now.ToString("yyyyMMddHHmmss").ToString() + ".pdf";
   float w = PageSize.A4.Width;
   float h = PageSize.A4.Height;
   Rectangle rect = new Rectangle(0, 0, w, h);
   Document document = new Document(rect);
   PdfWriter writer = PdfWriter.GetInstance(document, new FileStream(Server.MapPath(filename), FileMode.Create));
   //Sets the transparency blending colorspace to RGB. The default blending colorspace is CMYK and will result in faded colors in the screen and in printing. Calling this method will return the RGB colors to what is expected. The RGB blending will be applied to all subsequent pages until other value is set. Note that this is a generic solution that may not work in all cases. 

十年的渭城网站建设经验,针对设计、前端、开发、售后、文案、推广等六对一服务,响应快,48小时及时工作处理。成都全网营销推广的优势是能够根据用户设备显示端的尺寸不同,自动调整渭城建站的显示方式,使网站能够适用不同显示终端,在浏览器中调整网站的宽度,无论在任何一种浏览器上浏览网站,都能展现优雅布局与设计,从而大程度地提升浏览体验。创新互联从事“渭城网站设计”,“渭城网站推广”以来,每个客户项目都认真落实执行。

   //Parameters:
   //rgbTransparencyBlending - true to set the transparency blending colorspace to RGB, false to use the default blending colorspace

//设置颜色空间,默认是CMKY颜色空间,如果设置为true则为RGB颜色空间
   writer.RgbTransparencyBlending = true;
   document.Open();
   PdfContentByte content = writer.DirectContent;
   PdfTemplate template = content.CreateTemplate(rect.Width, rect.Height);
   PdfGState state = null;
   template.SaveState();

   template.SetColorFill(Color.RED);
   template.SetColorStroke(Color.GREEN);
   template.SetLineWidth(3);
   state = new PdfGState();
   state.FillOpacity = 0.5f;
   state.AlphaIsShape = false;
   template.SetGState(state);
   template.Rectangle(100, 100, 100, 100);
   template.FillStroke();
   template.RestoreState();

   content.AddTemplate(template, 1, 0, 0, -1, 0, rect.Height);
   document.Close();

 


当前名称:itextsharp的颜色空间
文章来源:http://kswsj.cn/article/jcjdhi.html

其他资讯