/// <summary>
 /// Constructs a new  RtfDestinationDocument  using
 /// the parameters to initialize the object.
 /// </summary>
 public RtfDestinationDocument(RtfParser parser) : base(parser)
 {
     _rtfDoc = parser.GetRtfDocument();
     _doc = parser.GetDocument();
     _conversionType = parser.GetConversionType();
     SetToDefaults();
     if (RtfParser.IsConvert())
     {
         RtfParser.GetState().Properties.AddRtfPropertyListener(this);
     }
 }
 public override void SetParser(RtfParser parser)
 {
     RtfParser = parser;
     _rtfDoc = parser.GetRtfDocument();
     _doc = parser.GetDocument();
     _conversionType = parser.GetConversionType();
     SetToDefaults();
     if (RtfParser.IsConvert())
     {
         RtfParser.GetState().Properties.AddRtfPropertyListener(this);
     }
 }
 private void addParagraphToDocument()
 {
     if (_iTextParagraph != null)
     {
         try
         {
             RtfParser.GetDocument().Add(_iTextParagraph);
         }
         catch
         {
         }
         _iTextParagraph = null;
     }
 }
        private bool addImage()
        {
            Image img = null;

            try
            {
                img = Image.GetInstance(_dataOs.ToArray());
            }
            catch
            {
            }
            //                if (img != null) {
            //                    FileOutputStream out =null;
            //                    try {
            //                        out = new FileOutputStream("c:\\test.png");
            //                        out.Write(img.GetOriginalData());
            //                        out.Close();
            //                    } catch (FileNotFoundException e1) {
            //                        // TODO Auto-generated catch block
            //                        e1.PrintStackTrace();
            //                    } catch (IOException e1) {
            //                        // TODO Auto-generated catch block
            //                        e1.PrintStackTrace();
            //                    }

            if (img != null)
            {
                img.ScaleAbsolute((float)_desiredWidth / PixelTwipsFactor, (float)_desiredHeight / PixelTwipsFactor);
                img.ScaleAbsolute((float)_width / PixelTwipsFactor, (float)_height / PixelTwipsFactor);
                img.ScalePercent(_scaleX, _scaleY);

                try
                {
                    if (RtfParser.IsImport())
                    {
                        var doc = RtfParser.GetDocument();
                        doc.Add(img);
                    }
                    if (RtfParser.IsConvert())
                    {
                        RtfParser.GetDocument().Add(img);
                    }
                }
                catch
                {
                }
            }
            _dataFormat = FORMAT_HEXADECIMAL;
            return(true);
        }
Exemple #5
0
 /// <summary>
 /// (non-Javadoc)
 /// @see com.lowagie.text.rtf.direct.RtfDestination#handleGroupEnd()
 /// </summary>
 public override bool HandleCloseGroup()
 {
     if (_text.Length > 0)
     {
         var doc = RtfParser.GetDocument();
         if (doc != null)
         {
             if (_elementName.Equals("author"))
             {
                 doc.AddAuthor(_text);
             }
             if (_elementName.Equals("title"))
             {
                 doc.AddTitle(_text);
             }
             if (_elementName.Equals("subject"))
             {
                 doc.AddSubject(_text);
             }
         }
         else
         {
             var rtfDoc = RtfParser.GetRtfDocument();
             if (rtfDoc != null)
             {
                 if (_elementName.Equals("author"))
                 {
                     var meta = new Meta(_elementName, _text);
                     var elem = new RtfInfoElement(rtfDoc, meta);
                     rtfDoc.GetDocumentHeader().AddInfoElement(elem);
                 }
                 if (_elementName.Equals("title"))
                 {
                     var meta = new Meta(_elementName, _text);
                     var elem = new RtfInfoElement(rtfDoc, meta);
                     rtfDoc.GetDocumentHeader().AddInfoElement(elem);
                 }
                 if (_elementName.Equals("subject"))
                 {
                     var meta = new Meta(_elementName, _text);
                     var elem = new RtfInfoElement(rtfDoc, meta);
                     rtfDoc.GetDocumentHeader().AddInfoElement(elem);
                 }
             }
         }
         SetToDefaults();
     }
     return(true);
 }