Welcome
Guest
•
Login
PDFsharp and MigraDoc Wiki
Navigation
¶
Main Page
Random Page
Create a new Page
All Pages
Categories
Navigation Paths
File Management
Create Account
Quick Search
»
Back
PDFsharp Sample: Colors CMYK
Modified on 2015/09/14 10:23
by
Thomas Hövel
Categorized as
PDFsharp Samples
,
Samples
{s:navigationPrevUpNext|Bookmarks-sample|PDFsharpSamples|CombineDocuments-sample} This sample shows how to use CMYK colors. ==PDF Output File== See the PDF file created by this sample: {s:PdfLink|ColorCMYK-sample%2fColorsCMYK_output.pdf|output.pdf} (78 kB) ==Screen Shots== Here is a sample screen shot: {s:ImageThumbLink|PDF file with CMYK squares|ColorCMYK-sample%2fColorsCMYKth.png|ColorCMYK-sample%2fColorsCMYK.png} ==Source Code== This is the source code the shows how to set the color mode to CMYK: {s:beginCsharp} PdfDocument document = PdfReader.Open(filename); document.Options.ColorMode = PdfColorMode.Cmyk; // Set version to PDF 1.4 (Acrobat 5) because we use transparency. if (document.Version < 14) document.Version = 14; PdfPage page = document.Pages[0]; // Get an XGraphics object for drawing beneath the existing content XGraphics gfx = XGraphics.FromPdfPage(page, XGraphicsPdfPageOptions.Append); gfx.DrawRectangle(new XSolidBrush(XColor.FromCmyk(1, 0.68, 0, 0.12)), new XRect(30, 60, 50, 50)); gfx.DrawRectangle(new XSolidBrush(XColor.FromCmyk(0, 0.70, 1, 0)), new XRect(550, 60, 50, 50)); gfx.DrawRectangle(new XSolidBrush(XColor.FromCmyk(0, 0, 0, 0)), new XRect(90, 100, 50, 50)); gfx.DrawRectangle(new XSolidBrush(XColor.FromCmyk(0, 0, 0, 0)), new XRect(150, 100, 50, 50)); gfx.DrawRectangle(new XSolidBrush(XColor.FromCmyk(0.7, 0, 0.70, 1, 0)), new XRect(90, 100, 50, 50)); gfx.DrawRectangle(new XSolidBrush(XColor.FromCmyk(0.5, 0, 0.70, 1, 0)), new XRect(150, 100, 50, 50)); gfx.DrawRectangle(new XSolidBrush(XColor.FromCmyk(0.35, 0.15, 0, 0.08)), new XRect(50, 360, 50, 50)); gfx.DrawRectangle(new XSolidBrush(XColor.FromCmyk(0.25, 0.10, 0, 0.05)), new XRect(150, 360, 50, 50)); gfx.DrawRectangle(new XSolidBrush(XColor.FromCmyk(0.15, 0.05, 0, 0)), new XRect(250, 360, 50, 50)); {s:endCsharp} {s:sampleSourceCode}
Meta Keywords:
Meta Description:
Change Comment:
Miscellaneous
Home
PDFsharp
FAQ
Samples
Articles
MigraDoc
FAQ
Samples
Articles
ScrewTurn Wiki version 3.0.5.600. Some of the icons created by
FamFamFam
.
Impressum - Privacy Policy, Data Protection Declaration, Legal Notice