itextsharp的颜色空间
stringfilename=DateTime.Now.ToString("yyyyMMddHHmmss").ToString()+".pdf";
floatw=PageSize.A4.Width;
floath=PageSize.A4.Height;
Rectanglerect=newRectangle(0,0,w,h);
Documentdocument=newDocument(rect);
PdfWriterwriter=PdfWriter.GetInstance(document,newFileStream(Server.MapPath(filename),FileMode.Create));
//SetsthetransparencyblendingcolorspacetoRGB.ThedefaultblendingcolorspaceisCMYKandwillresultinfadedcolorsinthescreenandinprinting.CallingthismethodwillreturntheRGBcolorstowhatisexpected.TheRGBblendingwillbeappliedtoallsubsequentpagesuntilothervalueisset.Notethatthisisagenericsolutionthatmaynotworkinallcases.
//Parameters:
//rgbTransparencyBlending-truetosetthetransparencyblendingcolorspacetoRGB,falsetousethedefaultblendingcolorspace
//设置颜色空间,默认是CMKY颜色空间,如果设置为true则为RGB颜色空间
writer.RgbTransparencyBlending=true;
document.Open();
PdfContentBytecontent=writer.DirectContent;
PdfTemplatetemplate=content.CreateTemplate(rect.Width,rect.Height);
PdfGStatestate=null;
template.SaveState();
template.SetColorFill(Color.RED);
template.SetColorStroke(Color.GREEN);
template.SetLineWidth(3);
state=newPdfGState();
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();
声明:本站所有文章资源内容,如无特殊说明或标注,均为采集网络资源。如若本站内容侵犯了原著者的合法权益,可联系本站删除。