Color Space of itextsharp

Source: Internet
Author: User

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 );
Using writer = Using writer. 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.

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

// Set the color space. The default value is the CMKY color space. If it is set to true, It is the RGB color space.
Writer. RgbTransparencyBlending = true;
Document. Open ();
Required contentbyte content = writer. DirectContent;
Repeated 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 ();

 

This article is from the explorer blog, please be sure to keep this source http://1906754.blog.51cto.com/1896754/1272930

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.