Gma.QrCodeNet.Encoder/Windows/Render/EncapsulatedPostScriptRenderer.cs
/// <summary>
/// Outputs the EPS header with mandatory declarations, variable declarations and function definitions.
/// </summary>
/// <param name="matrix">The matrix to be rendered</param>
/// <param name="moduleSize">Size in points (1 inch contains 72 point in PostScript) of a module</param>
/// <param name="stream">Output text stream</param>
Outputs the EPS header with mandatory declarations, variable declarations and function definitions.
Outputs the EPS header with mandatory declarations variable declarations and function definitions .
private void OutputHeader(DrawingSize drawingSize, StreamWriter stream)
		{
			string strHeader = @"%!PS-Adobe-3.0 EPSF-3.0
%%Creator: Gma.QrCodeNet
%%Title: QR Code
%%CreationDate: {0:yyyyMMdd}
%%Pages: 1
%%BoundingBox: 0 0 {1} {2}
%%Document-Fonts: Times-Roman
%%LanguageLevel: 1
%%EndComments
%%BeginProlog
/w {{ {3} }} def
/h {{ {4} }} def
/q {{ {5} }} def
/s {{ {6} }} def
/W {{ w q q add add }} def
/H {{ h q q add add }} def";
			string strBoxFunctions = @"% Define the box functions taking X and Y coordinates of the top left corner and filling a 1 point large square
/b { newpath moveto 1 0 rlineto 0 1 rlineto -1 0 rlineto closepath fill } def
/br { newpath moveto 1.01 0 rlineto 0 1 rlineto -1.01 0 rlineto closepath fill } def
/bb { newpath moveto 1 0 rlineto 0 1.01 rlineto -1 0 rlineto closepath fill } def
/brb { newpath moveto 1.01 0 rlineto 0 1 rlineto -0.01 0 rlineto 0 0.01 rlineto -1 0 rlineto closepath fill } def";
			string strHeaderEnd = @"%%EndProlog
%%Page: 1 1
% Save the current state
save
% Invert the Y axis
0 W s mul translate
s s neg scale";
			stream.WriteLine(string.Format(strHeader,
				DateTime.UtcNow,
				(drawingSize.CodeWidth).ToString(CultureInfo.InvariantCulture.NumberFormat), 
				(drawingSize.CodeWidth).ToString(CultureInfo.InvariantCulture.NumberFormat),
				drawingSize.CodeWidth / drawingSize.ModuleSize - ((int)drawingSize.QuietZoneModules * 2), 
				drawingSize.CodeWidth / drawingSize.ModuleSize - ((int)drawingSize.QuietZoneModules * 2),
				(int)drawingSize.QuietZoneModules, 
				drawingSize.ModuleSize.ToString(CultureInfo.InvariantCulture.NumberFormat))); 
			if (m_DrawingTechnique == EpsModuleDrawingTechnique.Squares)
				stream.WriteLine(strBoxFunctions);
			stream.WriteLine(strHeaderEnd);
		}
private void OutputHeader ( DrawingSize drawingSize , StreamWriter stream ) { string strHeader = @"%!PS-Adobe-3.0 EPSF-3.0
%%Creator: Gma.QrCodeNet
%%Title: QR Code
%%CreationDate: {0:yyyyMMdd}
%%Pages: 1
%%BoundingBox: 0 0 {1} {2}
%%Document-Fonts: Times-Roman
%%LanguageLevel: 1
%%EndComments
%%BeginProlog
/w {{ {3} }} def
/h {{ {4} }} def
/q {{ {5} }} def
/s {{ {6} }} def
/W {{ w q q add add }} def
/H {{ h q q add add }} def" ; string strBoxFunctions = @"% Define the box functions taking X and Y coordinates of the top left corner and filling a 1 point large square
/b { newpath moveto 1 0 rlineto 0 1 rlineto -1 0 rlineto closepath fill } def
/br { newpath moveto 1.01 0 rlineto 0 1 rlineto -1.01 0 rlineto closepath fill } def
/bb { newpath moveto 1 0 rlineto 0 1.01 rlineto -1 0 rlineto closepath fill } def
/brb { newpath moveto 1.01 0 rlineto 0 1 rlineto -0.01 0 rlineto 0 0.01 rlineto -1 0 rlineto closepath fill } def" ; string strHeaderEnd = @"%%EndProlog
%%Page: 1 1

% Save the current state
save

% Invert the Y axis
0 W s mul translate
s s neg scale" ; stream . WriteLine ( string . Format ( strHeader , DateTime . UtcNow , ( drawingSize . CodeWidth ) . ToString ( CultureInfo . InvariantCulture . NumberFormat ) , ( drawingSize . CodeWidth ) . ToString ( CultureInfo . InvariantCulture . NumberFormat ) , drawingSize . CodeWidth / drawingSize . ModuleSize - ( ( int ) drawingSize . QuietZoneModules * 2 ) , drawingSize . CodeWidth / drawingSize . ModuleSize - ( ( int ) drawingSize . QuietZoneModules * 2 ) , ( int ) drawingSize . QuietZoneModules , drawingSize . ModuleSize . ToString ( CultureInfo . InvariantCulture . NumberFormat ) ) ) ; if ( m_DrawingTechnique == EpsModuleDrawingTechnique . Squares ) stream . WriteLine ( strBoxFunctions ) ; stream . WriteLine ( strHeaderEnd ) ; }
Outputs the EPS header with mandatory declarations, variable declarations and function definitions.
Outputs the EPS header with mandatory declarations variable declarations and function definitions .
// Use invariant culture to ensure that the dot is used as the decimal separator // Size in points of the matrix with the quiet zone // Number of modules of the matrix without the quiet zone // Number of quiet zone modules // Size in points of a single module
drawingSize
DrawingSize
stream
StreamWriter
Output text stream
Output text stream
matrix
The matrix to be rendered
The matrix to be rendered
moduleSize
Size in points (1 inch contains 72 point in PostScript) of a module
Size in points ( 1 inch contains 72 point in PostScript ) of a module