/** * <summary>Begins a content block.</summary> * <param name="frame">Block boundaries.</param> * <param name="xAlignment">Horizontal alignment.</param> * <param name="yAlignment">Vertical alignment.</param> */ public void Begin( RectangleF frame, XAlignmentEnum xAlignment, YAlignmentEnum yAlignment ) { this.frame = frame; this.xAlignment = xAlignment; this.yAlignment = yAlignment; lastFontSize = 0; // Open the block local state! /* * NOTE: This device allows a fine-grained control over the block representation. * It MUST be coupled with a closing statement on block end. */ container = baseComposer.BeginLocalState(); boundBox = new RectangleF( frame.X, frame.Y, frame.Width, 0 ); BeginRow(); }
/** * <summary>Ends current paragraph, specifying the offset and alignment of the next one.</summary> * <remarks>This functionality allows higher-level features such as paragraph indentation and margin.</remarks> * <param name="offset">Relative location of the next paragraph.</param> * <param name="xAlignment">Horizontal alignment.</param> */ public bool ShowBreak( SizeF?offset, XAlignmentEnum?xAlignment ) { // End previous row! if (!EnsureRow(false)) { return(false); } if (xAlignment.HasValue) { this.xAlignment = xAlignment.Value; } BeginRow(); if (offset.HasValue) { currentRow.Y += offset.Value.Height; currentRow.Width = offset.Value.Width; } return(true); }
/** * <summary>Ends current paragraph, specifying the alignment of the next one.</summary> * <remarks>This functionality allows higher-level features such as paragraph indentation and margin.</remarks> * <param name="xAlignment">Horizontal alignment.</param> */ public void ShowBreak( XAlignmentEnum xAlignment ) { ShowBreak(); this.xAlignment = xAlignment; }
protected virtual DanfeCampo CriarCampo(String cabecalho, String corpo, XAlignmentEnum corpoAlinhamentoX = XAlignmentEnum.Left) { DanfeCampo campo = new DanfeCampo(cabecalho, corpo); Campos.Add(campo); campo.CorpoAlinhamentoX = corpoAlinhamentoX; return(campo); }
/** * <summary>Ends current paragraph, specifying the offset and alignment of the next one.</summary> * <remarks>This functionality allows higher-level features such as paragraph indentation and margin.</remarks> * <param name="offset">Relative location of the next paragraph.</param> * <param name="xAlignment">Horizontal alignment.</param> */ public void ShowBreak( SizeF offset, XAlignmentEnum xAlignment ) { ShowBreak(offset); this.xAlignment = xAlignment; }
public DanfeCampo(String cabecalho, String corpo, RectangleF retangulo , XAlignmentEnum corpoAlinhamentoX = XAlignmentEnum.Left, double corpoTamanhoFonte = 10, Boolean isCorpoNegrito = false, YAlignmentEnum corpoAlinhamentoY = YAlignmentEnum.Bottom) { Cabecalho = cabecalho; Corpo = corpo; Retangulo = retangulo; CorpoAlinhamentoX = corpoAlinhamentoX; CorpoTamanhoFonte = corpoTamanhoFonte; CorpoAlinhamentoY = corpoAlinhamentoY; IsCorpoNegrito = isCorpoNegrito; MultiLinha = false; }
public DanfeCampo(String cabecalho, String corpo, RectangleF retangulo, XAlignmentEnum corpoAlinhamentoX = XAlignmentEnum.Left, double corpoTamanhoFonte = 10, Boolean isCorpoNegrito = false, YAlignmentEnum corpoAlinhamentoY = YAlignmentEnum.Bottom) { Cabecalho = cabecalho; Corpo = corpo; Retangulo = retangulo; CorpoAlinhamentoX = corpoAlinhamentoX; CorpoTamanhoFonte = corpoTamanhoFonte; CorpoAlinhamentoY = corpoAlinhamentoY; IsCorpoNegrito = isCorpoNegrito; MultiLinha = false; }
private void DrawText( PrimitiveComposer composer, string value, PointF location, XAlignmentEnum xAlignment, YAlignmentEnum yAlignment, float rotation ) { // Show the anchor point! DrawCross(composer, location); composer.BeginLocalState(); composer.SetFillColor(SampleColor); // Show the text onto the page! Quad textFrame = composer.ShowText( value, location, xAlignment, yAlignment, rotation ); composer.End(); // Draw the frame binding the shown text! DrawFrame( composer, textFrame.Points ); composer.BeginLocalState(); composer.SetFont(composer.State.Font, 8); // Draw the rotation degrees! composer.ShowText( "(" + ((int)rotation) + " degrees)", new PointF( location.X + 70, location.Y ), XAlignmentEnum.Left, YAlignmentEnum.Middle, 0 ); composer.End(); }
protected virtual DanfeCampo CriarCampo(String cabecalho, String corpo, XAlignmentEnum corpoAlinhamentoX = XAlignmentEnum.Left) { DanfeCampo campo = new DanfeCampo(cabecalho, corpo); Campos.Add(campo); campo.CorpoAlinhamentoX = corpoAlinhamentoX; return campo; }
/** * <summary>Ends the content row.</summary> * <param name="broken">Indicates whether this is the end of a paragraph.</param> */ private void EndRow( bool broken ) { if (rowEnded) { return; } rowEnded = true; double[] objectXOffsets = new double[currentRow.Objects.Count]; // Horizontal object displacements. double wordSpace = 0; // Exceeding space among words. double rowXOffset = 0; // Horizontal row offset. List <RowObject> objects = currentRow.Objects; // Horizontal alignment. XAlignmentEnum xAlignment = this.xAlignment; switch (xAlignment) { case XAlignmentEnum.Left: break; case XAlignmentEnum.Right: rowXOffset = frame.Width - currentRow.Width; break; case XAlignmentEnum.Center: rowXOffset = (frame.Width - currentRow.Width) / 2; break; case XAlignmentEnum.Justify: // Are there NO spaces? if (currentRow.SpaceCount == 0 || broken) // NO spaces. { /* NOTE: This situation equals a simple left alignment. */ xAlignment = XAlignmentEnum.Left; } else // Spaces exist. { // Calculate the exceeding spacing among the words! wordSpace = (frame.Width - currentRow.Width) / currentRow.SpaceCount; // Define the horizontal offsets for justified alignment. for ( int index = 1, count = objects.Count; index < count; index++ ) { /* * NOTE: The offset represents the horizontal justification gap inserted * at the left side of each object. */ objectXOffsets[index] = objectXOffsets[index - 1] + objects[index - 1].SpaceCount * wordSpace; } } break; } SetWordSpace wordSpaceOperation = new SetWordSpace(wordSpace); // Vertical alignment and translation. for ( int index = objects.Count - 1; index >= 0; index-- ) { RowObject obj = objects[index]; // Vertical alignment. double objectYOffset = 0; { LineAlignmentEnum lineAlignment; double lineRise; { object objectLineAlignment = obj.LineAlignment; if (objectLineAlignment is Double) { lineAlignment = LineAlignmentEnum.BaseLine; lineRise = (double)objectLineAlignment; } else { lineAlignment = (LineAlignmentEnum)objectLineAlignment; lineRise = 0; } } switch (lineAlignment) { case LineAlignmentEnum.Top: /* NOOP */ break; case LineAlignmentEnum.Middle: objectYOffset = -(currentRow.Height - obj.Height) / 2; break; case LineAlignmentEnum.BaseLine: objectYOffset = -(currentRow.BaseLine - obj.BaseLine - lineRise); break; case LineAlignmentEnum.Bottom: objectYOffset = -(currentRow.Height - obj.Height); break; default: throw new NotImplementedException("Line alignment " + lineAlignment + " unknown."); } } IList <ContentObject> containedGraphics = obj.Container.Objects; // Word spacing. containedGraphics.Insert(0, wordSpaceOperation); // Translation. containedGraphics.Insert( 0, new ModifyCTM( 1, 0, 0, 1, objectXOffsets[index] + rowXOffset, // Horizontal alignment. objectYOffset // Vertical alignment. ) ); } // Update the actual block height! boundBox.Height = (float)(currentRow.Y + currentRow.Height); // Update the actual block vertical location! double yOffset; switch (yAlignment) { case YAlignmentEnum.Bottom: yOffset = frame.Height - boundBox.Height; break; case YAlignmentEnum.Middle: yOffset = (frame.Height - boundBox.Height) / 2; break; case YAlignmentEnum.Top: default: yOffset = 0; break; } boundBox.Y = (float)(frame.Y + yOffset); // Discard the current row! currentRow = null; }
/** <summary>Begins a content block.</summary> <param name="frame">Block boundaries.</param> <param name="xAlignment">Horizontal alignment.</param> <param name="yAlignment">Vertical alignment.</param> */ public void Begin( RectangleF frame, XAlignmentEnum xAlignment, YAlignmentEnum yAlignment ) { this.frame = frame; this.xAlignment = xAlignment; this.yAlignment = yAlignment; lastFontSize = 0; // Open the block local state! /* NOTE: This device allows a fine-grained control over the block representation. It MUST be coupled with a closing statement on block end. */ container = baseComposer.BeginLocalState(); boundBox = new RectangleF( frame.X, frame.Y, frame.Width, 0 ); BeginRow(); }
/** <summary>Ends current paragraph, specifying the offset and alignment of the next one.</summary> <remarks>This functionality allows higher-level features such as paragraph indentation and margin.</remarks> <param name="offset">Relative location of the next paragraph.</param> <param name="xAlignment">Horizontal alignment.</param> */ public void ShowBreak( SizeF offset, XAlignmentEnum xAlignment ) { ShowBreak(offset); this.xAlignment = xAlignment; }
/** <summary>Ends current paragraph, specifying the alignment of the next one.</summary> <remarks>This functionality allows higher-level features such as paragraph indentation and margin.</remarks> <param name="xAlignment">Horizontal alignment.</param> */ public void ShowBreak( XAlignmentEnum xAlignment ) { ShowBreak(); this.xAlignment = xAlignment; }
public Coluna(String cabecalho, float largura, XAlignmentEnum alinhamentoHorizontal = XAlignmentEnum.Right) { Cabecalho = cabecalho; Largura = largura; AlinhamentoHorizontal = alinhamentoHorizontal; }
/** <summary>Ends the content row.</summary> <param name="broken">Indicates whether this is the end of a paragraph.</param> */ private void EndRow( bool broken ) { if(rowEnded) return; rowEnded = true; double[] objectXOffsets = new double[currentRow.Objects.Count]; // Horizontal object displacements. double wordSpace = 0; // Exceeding space among words. double rowXOffset = 0; // Horizontal row offset. List<RowObject> objects = currentRow.Objects; // Horizontal alignment. XAlignmentEnum xAlignment = this.xAlignment; switch(xAlignment) { case XAlignmentEnum.Left: break; case XAlignmentEnum.Right: rowXOffset = frame.Width - currentRow.Width; break; case XAlignmentEnum.Center: rowXOffset = (frame.Width - currentRow.Width) / 2; break; case XAlignmentEnum.Justify: // Are there NO spaces? if(currentRow.SpaceCount == 0 || broken) // NO spaces. { /* NOTE: This situation equals a simple left alignment. */ xAlignment = XAlignmentEnum.Left; } else // Spaces exist. { // Calculate the exceeding spacing among the words! wordSpace = (frame.Width - currentRow.Width) / currentRow.SpaceCount; // Define the horizontal offsets for justified alignment. for( int index = 1, count = objects.Count; index < count; index++ ) { /* NOTE: The offset represents the horizontal justification gap inserted at the left side of each object. */ objectXOffsets[index] = objectXOffsets[index - 1] + objects[index - 1].SpaceCount * wordSpace; } } break; } SetWordSpace wordSpaceOperation = new SetWordSpace(wordSpace); // Vertical alignment and translation. for( int index = objects.Count - 1; index >= 0; index-- ) { RowObject obj = objects[index]; // Vertical alignment. double objectYOffset = 0; { LineAlignmentEnum lineAlignment; double lineRise; { object objectLineAlignment = obj.LineAlignment; if(objectLineAlignment is Double) { lineAlignment = LineAlignmentEnum.BaseLine; lineRise = (double)objectLineAlignment; } else { lineAlignment = (LineAlignmentEnum)objectLineAlignment; lineRise = 0; } } switch (lineAlignment) { case LineAlignmentEnum.Top: /* NOOP */ break; case LineAlignmentEnum.Middle: objectYOffset = -(currentRow.Height - obj.Height) / 2; break; case LineAlignmentEnum.BaseLine: objectYOffset = -(currentRow.BaseLine - obj.BaseLine - lineRise); break; case LineAlignmentEnum.Bottom: objectYOffset = -(currentRow.Height - obj.Height); break; default: throw new NotImplementedException("Line alignment " + lineAlignment + " unknown."); } } IList<ContentObject> containedGraphics = obj.Container.Objects; // Word spacing. containedGraphics.Insert(0,wordSpaceOperation); // Translation. containedGraphics.Insert( 0, new ModifyCTM( 1, 0, 0, 1, objectXOffsets[index] + rowXOffset, // Horizontal alignment. objectYOffset // Vertical alignment. ) ); } // Update the actual block height! boundBox.Height = (float)(currentRow.Y + currentRow.Height); // Update the actual block vertical location! double yOffset; switch(yAlignment) { case YAlignmentEnum.Bottom: yOffset = frame.Height - boundBox.Height; break; case YAlignmentEnum.Middle: yOffset = (frame.Height - boundBox.Height) / 2; break; case YAlignmentEnum.Top: default: yOffset = 0; break; } boundBox.Y = (float)(frame.Y + yOffset); // Discard the current row! currentRow = null; }
private void DrawText( PrimitiveComposer composer, string value, PointF location, XAlignmentEnum xAlignment, YAlignmentEnum yAlignment, float rotation ) { // Show the anchor point! DrawCross(composer,location); composer.BeginLocalState(); composer.SetFillColor(SampleColor); // Show the text onto the page! Quad textFrame = composer.ShowText( value, location, xAlignment, yAlignment, rotation ); composer.End(); // Draw the frame binding the shown text! DrawFrame( composer, textFrame.Points ); composer.BeginLocalState(); composer.SetFont(composer.State.Font,8); // Draw the rotation degrees! composer.ShowText( "(" + ((int)rotation) + " degrees)", new PointF( location.X+70, location.Y ), XAlignmentEnum.Left, YAlignmentEnum.Middle, 0 ); composer.End(); }
private void PrintTextCell(PrimitiveComposer composer, String text, RectangleF rect, XAlignmentEnum align = XAlignmentEnum.Center) { if (!String.IsNullOrWhiteSpace(text)) { text = text.Replace(Char.ConvertFromUtf32(160), Char.ConvertFromUtf32(32)); } BlockComposer bComp = new BlockComposer(composer); bComp.SafeBegin(rect, align, YAlignmentEnum.Top); bComp.ShowText(text); bComp.End(); CurrentY = Math.Max(CurrentY, bComp.BoundBox.Bottom); }
protected virtual DanfeCampo CriarCampo(String cabecalho, String corpo, RectangleF retangulo, XAlignmentEnum corpoAlinhamentoX = XAlignmentEnum.Left, double corpoTamanhoFonte = 10, Boolean isCorpoNegrito = false, YAlignmentEnum corpoAlinhamentoY = YAlignmentEnum.Bottom) { DanfeCampo campo = new DanfeCampo(cabecalho, corpo, retangulo, corpoAlinhamentoX, corpoTamanhoFonte, isCorpoNegrito, corpoAlinhamentoY); Campos.Add(campo); return campo; }
/** * <summary>Ends current paragraph, specifying the alignment of the next one.</summary> * <remarks>This functionality allows higher-level features such as paragraph indentation and margin.</remarks> * <param name="xAlignment">Horizontal alignment.</param> */ public bool ShowBreak( XAlignmentEnum xAlignment ) { return(ShowBreak(null, xAlignment)); }
protected override DanfeCampo CriarCampo(string cabecalho, string corpo, XAlignmentEnum corpoAlinhamentoX = XAlignmentEnum.Right) { return(base.CriarCampo(cabecalho, corpo, corpoAlinhamentoX)); }
protected virtual DanfeCampo CriarCampo(String cabecalho, String corpo, RectangleF retangulo, XAlignmentEnum corpoAlinhamentoX = XAlignmentEnum.Left, double corpoTamanhoFonte = 10, Boolean isCorpoNegrito = false, YAlignmentEnum corpoAlinhamentoY = YAlignmentEnum.Bottom) { DanfeCampo campo = new DanfeCampo(cabecalho, corpo, retangulo, corpoAlinhamentoX, corpoTamanhoFonte, isCorpoNegrito, corpoAlinhamentoY); Campos.Add(campo); return(campo); }
/** * <summary>Ends the content row.</summary> * <param name="broken">Indicates whether this is the end of a paragraph.</param> */ private void EndRow( bool broken ) { if (rowEnded) { return; } rowEnded = true; List <RowObject> objects = currentRow.Objects; double[] objectXOffsets = new double[objects.Count]; // Horizontal object displacements. double wordSpace = 0; // Exceeding space among words. double rowXOffset = 0; // Horizontal row offset. // Horizontal alignment. XAlignmentEnum xAlignment = this.xAlignment; switch (xAlignment) { case XAlignmentEnum.Left: break; case XAlignmentEnum.Right: rowXOffset = frame.Width - currentRow.Width; break; case XAlignmentEnum.Center: rowXOffset = (frame.Width - currentRow.Width) / 2; break; case XAlignmentEnum.Justify: if (currentRow.SpaceCount == 0 || broken) // NO spaces. { /* NOTE: This situation equals a simple left alignment. */ xAlignment = XAlignmentEnum.Left; } else // Spaces exist. { // Calculate the exceeding spacing among the words! wordSpace = (frame.Width - currentRow.Width) / currentRow.SpaceCount; // Define the horizontal offsets for justified alignment. for ( int index = 1, count = objects.Count; index < count; index++ ) { /* * NOTE: The offset represents the horizontal justification gap inserted at the left * side of each object. */ objectXOffsets[index] = objectXOffsets[index - 1] + objects[index - 1].SpaceCount * wordSpace; } } currentRow.WordSpaceAdjustment.Value = wordSpace; break; } // Vertical alignment and translation. for ( int index = objects.Count - 1; index >= 0; index-- ) { RowObject obj = objects[index]; // Vertical alignment. double objectYOffset = 0; { LineAlignmentEnum lineAlignment; double lineRise; { object objectLineAlignment = obj.LineAlignment; if (objectLineAlignment is Double) { lineAlignment = LineAlignmentEnum.BaseLine; lineRise = (double)objectLineAlignment; } else { lineAlignment = (LineAlignmentEnum)objectLineAlignment; lineRise = 0; } } switch (lineAlignment) { case LineAlignmentEnum.Top: /* NOOP */ break; case LineAlignmentEnum.Middle: objectYOffset = -(currentRow.Height - obj.Height) / 2; break; case LineAlignmentEnum.BaseLine: objectYOffset = -(currentRow.BaseLine - obj.BaseLine - lineRise); break; case LineAlignmentEnum.Bottom: objectYOffset = -(currentRow.Height - obj.Height); break; default: throw new NotImplementedException("Line alignment " + lineAlignment + " unknown."); } } IList <ContentObject> containedGraphics = obj.Container.Objects; // Translation. containedGraphics.Insert( 0, new ModifyCTM( 1, 0, 0, 1, objectXOffsets[index] + rowXOffset, // Horizontal alignment. objectYOffset // Vertical alignment. ) ); // Word spacing. if (obj.Type == RowObject.TypeEnum.Text) { /* * TODO: This temporary hack adjusts the word spacing in case of composite font. * When DocumentComposer replaces BlockComposer, all the graphical properties of contents * will be declared as styles and their composition will occur as a single pass without such * ugly tweakings. */ ShowText showTextOperation = (ShowText)((Text)((LocalGraphicsState)containedGraphics[1]).Objects[1]).Objects[1]; if (showTextOperation is ShowAdjustedText) { PdfInteger wordSpaceObject = PdfInteger.Get((int)Math.Round(-wordSpace * 1000 * obj.Scale / obj.FontSize)); PdfArray textParams = (PdfArray)showTextOperation.Operands[0]; for (int textParamIndex = 1, textParamsLength = textParams.Count; textParamIndex < textParamsLength; textParamIndex += 2) { textParams[textParamIndex] = wordSpaceObject; } } } } // Update the actual block height! boundBox.Height = (float)(currentRow.Y + currentRow.Height); // Update the actual block vertical location! double yOffset; switch (yAlignment) { case YAlignmentEnum.Bottom: yOffset = frame.Height - boundBox.Height; break; case YAlignmentEnum.Middle: yOffset = (frame.Height - boundBox.Height) / 2; break; case YAlignmentEnum.Top: default: yOffset = 0; break; } boundBox.Y = (float)(frame.Y + yOffset); // Discard the current row! currentRow = null; }