コード例 #1
0
        public BidiLine(BidiLine org)
        {
            RunDirection    = org.RunDirection;
            PieceSize       = org.PieceSize;
            Text            = (char[])org.Text.Clone();
            DetailChunks    = (PdfChunk[])org.DetailChunks.Clone();
            TotalTextLength = org.TotalTextLength;

            OrderLevels = (byte[])org.OrderLevels.Clone();
            IndexChars  = (int[])org.IndexChars.Clone();

            Chunks         = new ArrayList(org.Chunks);
            IndexChunk     = org.IndexChunk;
            IndexChunkChar = org.IndexChunkChar;
            CurrentChar    = org.CurrentChar;

            StoredRunDirection    = org.StoredRunDirection;
            StoredText            = (char[])org.StoredText.Clone();
            StoredDetailChunks    = (PdfChunk[])org.StoredDetailChunks.Clone();
            StoredTotalTextLength = org.StoredTotalTextLength;

            StoredOrderLevels = (byte[])org.StoredOrderLevels.Clone();
            StoredIndexChars  = (int[])org.StoredIndexChars.Clone();

            StoredIndexChunk     = org.StoredIndexChunk;
            StoredIndexChunkChar = org.StoredIndexChunkChar;
            StoredCurrentChar    = org.StoredCurrentChar;

            ShortStore    = org.ShortStore;
            ArabicOptions = org.ArabicOptions;
        }
コード例 #2
0
 /**
  * Adds an element. Elements supported are <CODE>Paragraph</CODE>,
  * <CODE>List</CODE>, <CODE>PdfPTable</CODE>, <CODE>Image</CODE> and
  * <CODE>Graphic</CODE>. Also accepts a <code>Chunk</code> and a
  * <code>Phrase</code>, they are placed in a new <code>Paragraph<code>.
  * <p>
  * It removes all the text placed with <CODE>addText()</CODE>.
  *
  * @param element the <CODE>Element</CODE>
  */
 public void AddElement(IElement element) {
     if (element == null)
         return;
     if (element is Image) {
         Image img = (Image)element;
         PdfPTable t = new PdfPTable(1);
         float w = img.WidthPercentage;
         if (w == 0) {
             t.TotalWidth = img.ScaledWidth;
             t.LockedWidth = true;
         }
         else
             t.WidthPercentage = w;
         t.SpacingAfter = img.SpacingAfter;
         t.SpacingBefore = img.SpacingBefore;
         switch (img.Alignment) {
             case Image.LEFT_ALIGN:
                 t.HorizontalAlignment = Element.ALIGN_LEFT;
                 break;
             case Image.RIGHT_ALIGN:
                 t.HorizontalAlignment = Element.ALIGN_RIGHT;
                 break;
             default:
                 t.HorizontalAlignment = Element.ALIGN_CENTER;
                 break;
         }
         PdfPCell c = new PdfPCell(img, true);
         c.Padding = 0;
         c.Border = img.Border;
         c.BorderColor = img.BorderColor;
         c.BorderWidth = img.BorderWidth;
         c.BackgroundColor = img.BackgroundColor;
         t.AddCell(c);
         element = t;
     }
     if (element.Type == Element.CHUNK) {
         element = new Paragraph((Chunk)element);
     }
     else if (element.Type == Element.PHRASE) {
         element = new Paragraph((Phrase)element);
     }
     if (element.Type != Element.PARAGRAPH && element.Type != Element.LIST && element.Type != Element.PTABLE && element.Type != Element.YMARK && element.Type != Element.DIV)
         throw new ArgumentException(MessageLocalization.GetComposedMessage("element.not.allowed"));
     if (!composite) {
         composite = true;
         compositeElements = new List<IElement>();
         bidiLine = null;
         waitPhrase = null;
     }
     if (element.Type == Element.PARAGRAPH) {
         Paragraph p = (Paragraph)element;
         IList<IElement> paragraphElements = p.breakUp();
         foreach (IElement paragraphElement in paragraphElements) {
             compositeElements.Add(paragraphElement);    
         }
         return;
     }
     compositeElements.Add(element);
 }
コード例 #3
0
 /**
  * Replaces the current text array with this <CODE>Phrase</CODE>.
  * Anything added previously with AddElement() is lost.
  * @param phrase the text
  */
 public void SetText(Phrase phrase) {
     bidiLine = null;
     composite = false;
     compositeColumn = null;
     compositeElements = null;
     listIdx = 0;
     rowIdx = 0;
     splittedRow = -1;
     waitPhrase = phrase;
 }
コード例 #4
0
 private void AddWaitingPhrase() {
     if (bidiLine == null && waitPhrase != null) {
         bidiLine = new BidiLine();
         foreach (Chunk ck in waitPhrase.Chunks) {
             bidiLine.AddChunk(new PdfChunk(ck, null));
         }
         waitPhrase = null;
     }
 }
コード例 #5
0
 /** Makes this instance an independent copy of <CODE>org</CODE>.
  * @param org the original <CODE>ColumnText</CODE>
  * @return itself
  */    
 public ColumnText SetACopy(ColumnText org) {
     SetSimpleVars(org);
     if (org.bidiLine != null)
         bidiLine = new BidiLine(org.bidiLine);
     return this;
 }
コード例 #6
0
ファイル: BidiLine.cs プロジェクト: bmictech/iTextSharp
        public BidiLine(BidiLine org)
        {
            runDirection = org.runDirection;
            pieceSize = org.pieceSize;
            text = (char[])org.text.Clone();
            detailChunks = (PdfChunk[])org.detailChunks.Clone();
            totalTextLength = org.totalTextLength;

            orderLevels = (byte[])org.orderLevels.Clone();
            indexChars = (int[])org.indexChars.Clone();

            chunks = new ArrayList(org.chunks);
            indexChunk = org.indexChunk;
            indexChunkChar = org.indexChunkChar;
            currentChar = org.currentChar;

            storedRunDirection = org.storedRunDirection;
            storedText = (char[])org.storedText.Clone();
            storedDetailChunks = (PdfChunk[])org.storedDetailChunks.Clone();
            storedTotalTextLength = org.storedTotalTextLength;

            storedOrderLevels = (byte[])org.storedOrderLevels.Clone();
            storedIndexChars = (int[])org.storedIndexChars.Clone();

            storedIndexChunk = org.storedIndexChunk;
            storedIndexChunkChar = org.storedIndexChunkChar;
            storedCurrentChar = org.storedCurrentChar;

            shortStore = org.shortStore;
            arabicOptions = org.arabicOptions;
        }
コード例 #7
0
 virtual public String Process(String s)
 {
     return(BidiLine.ProcessLTR(s, runDirection, options));
 }
コード例 #8
0
ファイル: BidiLine.cs プロジェクト: joshaxey/Simple-PDFMerge
     /**
      * Method that changes a String with Arabic characters into a String in which the ligatures are made.
      * @param s	the original String
      * @param runDirection
      * @param arabicOptions
      * @return the String with the ligaturesc
      */
     public static String ProcessLTR(String s, int runDirection, int arabicOptions) {
 	    BidiLine bidi = new BidiLine();
 	    bidi.AddChunk(new PdfChunk(new Chunk(s), null));
 	    bidi.arabicOptions = arabicOptions;
 	    bidi.GetParagraph(runDirection);
 	    List<PdfChunk> arr = bidi.CreateArrayOfPdfChunks(0, bidi.totalTextLength - 1);
 	    StringBuilder sb = new StringBuilder();
 	    foreach (PdfChunk ck in arr) {
 		    sb.Append(ck.ToString());
 	    }
 	    return sb.ToString();
     }
コード例 #9
0
 /**
  * Adds an element. Elements supported are <CODE>Paragraph</CODE>,
  * <CODE>List</CODE>, <CODE>PdfPTable</CODE>, <CODE>Image</CODE> and
  * <CODE>Graphic</CODE>.
  * <p>
  * It removes all the text placed with <CODE>addText()</CODE>.
  * @param element the <CODE>Element</CODE>
  */    
 public void AddElement(IElement element) {
     if (element == null)
         return;
     if (element is Image) {
         Image img = (Image)element;
         PdfPTable t = new PdfPTable(1);
         float w = img.WidthPercentage;
         if (w == 0) {
             t.TotalWidth = img.ScaledWidth;
             t.LockedWidth = true;
         }
         else
             t.WidthPercentage = w;
         t.SpacingAfter = img.SpacingAfter;
         t.SpacingBefore = img.SpacingBefore;
         switch (img.Alignment) {
             case Image.LEFT_ALIGN:
                 t.HorizontalAlignment = Element.ALIGN_LEFT;
                 break;
             case Image.RIGHT_ALIGN:
                 t.HorizontalAlignment = Element.ALIGN_RIGHT;
                 break;
             default:
                 t.HorizontalAlignment = Element.ALIGN_CENTER;
                 break;
         }
         PdfPCell c = new PdfPCell(img, true);
         c.Padding = 0;
         c.Border = img.Border;
         c.BorderColor = img.BorderColor;
         c.BorderWidth = img.BorderWidth;
         c.BackgroundColor = img.BackgroundColor;
         t.AddCell(c);
         element = t;
     }
     if (element.Type == Element.CHUNK) {
         element = new Paragraph((Chunk)element);
     }
     else if (element.Type == Element.PHRASE) {
         element = new Paragraph((Phrase)element);
     }
     if (element is SimpleTable) {
         try {
             element = ((SimpleTable)element).CreatePdfPTable();
         } catch (DocumentException) {
             throw new ArgumentException("Element not allowed.");
         }
     }
     else if (element.Type != Element.PARAGRAPH && element.Type != Element.LIST && element.Type != Element.PTABLE && element.Type != Element.YMARK)
         throw new ArgumentException("Element not allowed.");
     if (!composite) {
         composite = true;
         compositeElements = new ArrayList();
         bidiLine = null;
         waitPhrase = null;
     }
     compositeElements.Add(element);
 }