コード例 #1
0
		/// <summary>
		/// Converts the specified paragraph.
		/// </summary>
		/// <param name="paragraph">The paragraph.</param>
		/// <returns>The PDF paragraph.</returns>
		public static iTextSharp.text.Paragraph Convert(AODL.Document.Content.Text.Paragraph paragraph)
		{
			try
			{
				iTextSharp.text.Font font;
				if ((ParagraphStyle)paragraph.Style != null 
					&& ((ParagraphStyle)paragraph.Style).TextProperties != null
					&& ((ParagraphStyle)paragraph.Style).TextProperties.FontName != null)
					font = TextPropertyConverter.GetFont(
						((ParagraphStyle)paragraph.Style).TextProperties);
				else
					font = DefaultDocumentStyles.Instance().DefaultTextFont;

				ParagraphExt paragraphPDF = new ParagraphExt("", font);				
				foreach(object obj in paragraph.MixedContent)
				{
					if (obj is AODL.Document.Content.Text.FormatedText)
					{
						paragraphPDF.Add(FormatedTextConverter.Convert(
							obj as AODL.Document.Content.Text.FormatedText));
					}
					if (obj is AODL.Document.Content.Text.SimpleText)
					{
						paragraphPDF.Add(SimpleTextConverter.Convert(
							obj as AODL.Document.Content.Text.SimpleText, font));
					}
					else if (obj is AODL.Document.Content.Text.TextControl.TabStop)
					{
						paragraphPDF.Add(SimpleTextConverter.ConvertTabs(
							obj as AODL.Document.Content.Text.TextControl.TabStop, font));
					}
					else if (obj is AODL.Document.Content.Text.TextControl.WhiteSpace)
					{
						paragraphPDF.Add(SimpleTextConverter.ConvertWhiteSpaces(
							obj as AODL.Document.Content.Text.TextControl.WhiteSpace, font));
					}
					else if (obj is AODL.Document.Content.Draw.Frame)
					{
						DrawFrameConverter dfc = new DrawFrameConverter();
						paragraphPDF.Add(dfc.Convert(
							obj as AODL.Document.Content.Draw.Frame));
					}
					else if (obj is AODL.Document.Content.Draw.Graphic)
					{
						ImageConverter ic = new ImageConverter();
						paragraphPDF.Add(ic.Convert(
							obj as AODL.Document.Content.Draw.Graphic));
					}
				}
				paragraphPDF = ParagraphConverter.ConvertParagraphStyles(paragraph, paragraphPDF);
				// add new line
				paragraphPDF.Add(iTextSharp.text.Chunk.NEWLINE);
				return paragraphPDF;
			}
			catch(Exception)
			{
				throw;
			}
		}
コード例 #2
0
		/// <summary>
		/// Converts the specified simple text.
		/// </summary>
		/// <param name="simpleText">The simple text.</param>
		/// <returns></returns>
		public static iTextSharp.text.Chunk Convert(AODL.Document.Content.Text.SimpleText simpleText, iTextSharp.text.Font font)
		{
			try
			{
				return new iTextSharp.text.Chunk(simpleText.Text, font);
			}
			catch(Exception)
			{
				throw;
			}
		}
コード例 #3
0
		/// <summary>
		/// Creates the text document table.
		/// </summary>
		/// <param name="document">The document.</param>
		/// <param name="tableName">Name of the table.</param>
		/// <param name="styleName">Name of the style.</param>
		/// <param name="rows">The rows.</param>
		/// <param name="columns">The columns.</param>
		/// <param name="width">The width.</param>
		/// <param name="useTableRowHeader">if set to <c>true</c> [use table row header].</param>
		/// <param name="useBorder">The useBorder.</param>
		/// <returns></returns>
		public static Table CreateTextDocumentTable(
			AODL.Document.TextDocuments.TextDocument document, 
			string tableName, 
			string styleName, 
			int rows, 
			int columns, 
			double width, 
			bool useTableRowHeader, 
			bool useBorder)
		{
			string tableCnt							= document.DocumentMetadata.TableCount.ToString();
			Table table								= new Table(document, tableName, styleName);
			table.TableStyle.TableProperties.Width	= width.ToString().Replace(",",".")+"cm";

			for(int i=0; i<columns; i++)
			{
				Column column						= new Column(table, "co"+tableCnt+i.ToString());
				column.ColumnStyle.ColumnProperties.Width = GetColumnCellWidth(columns, width);
				table.ColumnCollection.Add(column);
			}

			if (useTableRowHeader)
			{
				rows--;
				RowHeader rowHeader					= new RowHeader(table);
				Row row								= new Row(table, "roh1"+tableCnt);
				for(int i=0; i<columns; i++)
				{
					Cell cell						= new Cell(table.Document, "rohce"+tableCnt+i.ToString());
					if (useBorder)
						cell.CellStyle.CellProperties.Border = Border.NormalSolid;
					row.Cells.Add(cell);
				}
				rowHeader.RowCollection.Add(row);
				table.RowHeader						= rowHeader;
			}

			for(int ir=0; ir<rows; ir++)
			{
				Row row								= new Row(table, "ro"+tableCnt+ir.ToString());
				
				for(int ic=0; ic<columns; ic++)
				{
					Cell cell						= new Cell(table.Document, "ce"+tableCnt+ir.ToString()+ic.ToString());
					if (useBorder)
						cell.CellStyle.CellProperties.Border = Border.NormalSolid;
					row.Cells.Add(cell);
				}

				table.Rows.Add(row);
			}

			return table;
		}
コード例 #4
0
		/// <summary>
		/// Converts the tabs.
		/// </summary>
		/// <param name="tabStop">The tab stop.</param>
		/// <returns>Chunkck containing whitespace for a tab.</returns>
		public static iTextSharp.text.Phrase ConvertTabs(AODL.Document.Content.Text.TextControl.TabStop tabStop, iTextSharp.text.Font font)
		{
			try
			{
				// Only a trick since PDF doesn't support tab stops as know from other
				// formats, so we only use whitespace character for the beginning
				// TODO: do it better
				iTextSharp.text.Phrase phrase = new iTextSharp.text.Phrase("     ", font);
				return phrase;
			}
			catch(Exception)
			{
				throw;
			}
		}
コード例 #5
0
		/// <summary>
		/// Converts the specified formated text.
		/// </summary>
		/// <param name="formatedText">The formated text.</param>
		/// <returns>The chunck object representing this formated text.</returns>
		public static iTextSharp.text.Phrase Convert(AODL.Document.Content.Text.FormatedText formatedText)
		{
			iTextSharp.text.Font font;
			if ((TextStyle)formatedText.Style != null
			    && ((TextStyle)formatedText.Style).TextProperties != null)
				font = TextPropertyConverter.GetFont(
					((TextStyle)formatedText.Style).TextProperties);
			else
				font = DefaultDocumentStyles.Instance().DefaultTextFont;

			iTextSharp.text.Phrase phrase = new iTextSharp.text.Phrase("", font); // default ctor protected - why ??
			phrase.AddRange(FormatedTextConverter.GetTextContents(formatedText.TextContent, font));

			return phrase;
		}
コード例 #6
0
		/// <summary>
		/// Exports the specified document.
		/// </summary>
		/// <param name="document">The document.</param>
		/// <param name="filename">The filename.</param>
		public void Export(AODL.Document.IDocument document, string filename)
		{
			try
			{
				PDFDocument pdfDocument = new PDFDocument();
				pdfDocument.DoExport(document, filename);
				if (this.OnExportFinished != null)
				{
					this.OnExportFinished();
				}
			}
			catch(Exception)
			{
				throw;
			}
		}
コード例 #7
0
		/// <summary>
		/// Converts the white spaces.
		/// </summary>
		/// <param name="whiteSpace">The white space.</param>
		/// <returns>Chunck containing the whitspaces.</returns>
		public static iTextSharp.text.Phrase ConvertWhiteSpaces(AODL.Document.Content.Text.TextControl.WhiteSpace whiteSpace, iTextSharp.text.Font font)
		{
			try
			{
				string simulatedWhitespaces = "";
				if (whiteSpace.Count != null)
				{
					for(int i=0; i < Int32.Parse(whiteSpace.Count); i++)
					{
						simulatedWhitespaces += " ";
					}
				}
				return new iTextSharp.text.Phrase(simulatedWhitespaces, font);
			}
			catch(Exception)
			{
				throw;
			}
		}
コード例 #8
0
ファイル: Row.cs プロジェクト: rabidbob/aodl-reloaded
		/// <summary>
		/// Merge cells. This is only possible if the rows table is part
		/// of a text document.
		/// </summary>
		/// <param name="document">The TextDocument this row belongs to.</param>
		/// <param name="cellStartIndex">Start index of the cell.</param>
		/// <param name="mergeCells">The count of cells to merge incl. the starting cell.</param>
		/// <param name="mergeContent">if set to <c>true</c> [merge content].</param>
		public void MergeCells(AODL.Document.TextDocuments.TextDocument document,int cellStartIndex, int mergeCells, bool mergeContent)
		{
			try
			{
				this.Cells[cellStartIndex].ColumnRepeating		= mergeCells.ToString();
				
				if (mergeContent)
				{
					for(int i=cellStartIndex+1; i<cellStartIndex+mergeCells; i++)
					{
						foreach(IContent content in this.Cells[i].Content)
							this.Cells[cellStartIndex].Content.Add(content);
					}
				}

				for(int i=cellStartIndex+mergeCells-1; i>cellStartIndex; i--)
				{
					this.Cells.RemoveAt(i);
					this.CellSpanCollection.Add(new CellSpan(this, (AODL.Document.TextDocuments.TextDocument)this.Document));
				}
			}
			catch(Exception)
			{
				throw;
			}
		}
コード例 #9
0
		/// <summary>
		/// Exports the specified document.
		/// </summary>
		/// <param name="document">The document.</param>
		/// <param name="filename">The filename.</param>
		public void Export(AODL.Document.IDocument document, string filename)
		{
				this._document			= document;
                String exportDir = Environment.CurrentDirectory + Path.DirectorySeparatorChar + folderGuid + Path.DirectorySeparatorChar;
				PrepareDirectory(exportDir);
				//Write content
				if (document is TextDocument)
				{
                    MoveBackMasterStyles();

                    this.WriteSingleFiles(((TextDocument)document).DocumentManifest.Manifest, exportDir + DocumentManifest.FolderName + Path.DirectorySeparatorChar + DocumentManifest.FileName);
					this.WriteSingleFiles(((TextDocument)document).DocumentMetadata.Meta, exportDir+DocumentMetadata.FileName);
					this.WriteSingleFiles(((TextDocument)document).DocumentSetting.Settings, exportDir+DocumentSetting.FileName);
					this.WriteSingleFiles(((TextDocument)document).DocumentStyles.Styles, exportDir+DocumentStyles.FileName);
					this.WriteSingleFiles(((TextDocument)document).XmlDoc, exportDir+"content.xml");
					//Save graphics, which were build during creating a new document
					this.CopyGraphics(((TextDocument)document), exportDir);
				}
				else if (document is AODL.Document.SpreadsheetDocuments.SpreadsheetDocument)
				{
                    this.WriteSingleFiles(((AODL.Document.SpreadsheetDocuments.SpreadsheetDocument)document).DocumentManifest.Manifest, exportDir + DocumentManifest.FolderName + Path.DirectorySeparatorChar + DocumentManifest.FileName);
					this.WriteSingleFiles(((AODL.Document.SpreadsheetDocuments.SpreadsheetDocument)document).DocumentMetadata.Meta, exportDir+DocumentMetadata.FileName);
					this.WriteSingleFiles(((AODL.Document.SpreadsheetDocuments.SpreadsheetDocument)document).DocumentSetting.Settings, exportDir+DocumentSetting.FileName);
					this.WriteSingleFiles(((AODL.Document.SpreadsheetDocuments.SpreadsheetDocument)document).DocumentStyles.Styles, exportDir+DocumentStyles.FileName);
					this.WriteSingleFiles(((AODL.Document.SpreadsheetDocuments.SpreadsheetDocument)document).XmlDoc, exportDir+"content.xml");
					
					if (document.EmbedObjects .Count !=0)
					{
						foreach ( EmbedObject eo in document.EmbedObjects)
						{
							if (eo.ObjectType.Equals("chart"))
							{
								((Chart)eo).SaveTo (exportDir);
							}
						}
					}

                    this.WriteSingleFiles(((AODL.Document.SpreadsheetDocuments.SpreadsheetDocument)document).DocumentManifest.Manifest, exportDir + DocumentManifest.FolderName + Path.DirectorySeparatorChar + DocumentManifest.FileName);
				}
				else
					throw new Exception("Unsupported document type!");
				//Write Pictures and Thumbnails
                //				this.SaveExistingGraphics(document.DocumentPictures, dir+"Pictures" + Path.DirectorySeparatorChar);
                //				this.SaveExistingGraphics(document.DocumentThumbnails, dir+"Thumbnails" + Path.DirectorySeparatorChar);
				//Don't know why VS couldn't read a textfile resource without file prefix
				WriteMimetypeFile(exportDir+ Path.DirectorySeparatorChar + "mimetype");
				//Now create the document
				CreateOpenDocument(filename, exportDir);
				
				DeleteExportDirectory(exportDir);
		}
コード例 #10
0
 /// <summary>
 /// Determines whether [contains] [the specified value].
 /// </summary>
 /// <param name="value">The value.</param>
 /// <returns>
 /// 	<c>true</c> if [contains] [the specified value]; otherwise, <c>false</c>.
 /// </returns>
 public bool Contains(AODL.Document.Styles.MasterStyles.TextMasterPage value)
 {
     return base.List.Contains(value as object);
 }
コード例 #11
0
 /// <summary>
 /// Removes the specified value.
 /// </summary>
 /// <param name="value">The value.</param>
 public void Remove(AODL.Document.Styles.TabStopStyle value)
 {
     this.Node.RemoveChild(((TabStopStyle)value).Node);
     base.List.Remove(value as object);
 }
コード例 #12
0
 /// <summary>
 /// Adds the specified value.
 /// </summary>
 /// <param name="value">The value.</param>
 /// <returns></returns>
 public int Add(AODL.Document.Styles.Properties.IProperty value)
 {
     return base.List.Add(value as object);
 }
コード例 #13
0
 /// <summary>
 /// Inserts the specified index.
 /// </summary>
 /// <param name="index">The index.</param>
 /// <param name="value">The value.</param>
 public void Insert(int index, AODL.Document.Styles.Properties.IProperty value)
 {
     base.List.Insert(index, value as object);
 }
コード例 #14
0
 /// <summary>
 /// Removes the specified value.
 /// </summary>
 /// <param name="value">The value.</param>
 public void Remove(AODL.Document.Styles.MasterStyles.TextMasterPage value)
 {
     base.List.Remove(value as object);
 }
コード例 #15
0
		/// <summary>
		/// MCP_s the on warning.
		/// </summary>
		/// <param name="warning">The warning.</param>
		private void mcp_OnWarning(AODL.Document.Exceptions.AODLWarning warning)
		{
			this._importError.Add(warning);
		}
コード例 #16
0
ファイル: CellCollection.cs プロジェクト: stuzzicadenti/aodl
 /// <summary>
 /// Removes the specified value.
 /// </summary>
 /// <param name="value">The value.</param>
 public void Remove(AODL.Document.Content.Tables.Cell value)
 {
     base.List.Remove(value as object);
 }
コード例 #17
0
 /// <summary>
 /// Adds the specified value.
 /// </summary>
 /// <param name="value">The value.</param>
 /// <returns></returns>
 public int Add(AODL.Document.Styles.MasterStyles.TextMasterPage value)
 {
     return base.List.Add(value as object);
 }
コード例 #18
0
ファイル: CellCollection.cs プロジェクト: stuzzicadenti/aodl
 /// <summary>
 /// Inserts the specified index.
 /// </summary>
 /// <param name="index">The index.</param>
 /// <param name="value">The value.</param>
 public void Insert(int index, AODL.Document.Content.Tables.Cell value)
 {
     base.List.Insert(index, value as object);
 }
コード例 #19
0
ファイル: CellCollection.cs プロジェクト: stuzzicadenti/aodl
 /// <summary>
 /// Determines whether [contains] [the specified value].
 /// </summary>
 /// <param name="value">The value.</param>
 /// <returns>
 /// 	<c>true</c> if [contains] [the specified value]; otherwise, <c>false</c>.
 /// </returns>
 public bool Contains(AODL.Document.Content.Tables.Cell value)
 {
     return base.List.Contains(value as object);
 }
コード例 #20
0
ファイル: CellCollection.cs プロジェクト: stuzzicadenti/aodl
 /// <summary>
 /// Adds the specified value.
 /// </summary>
 /// <param name="value">The value.</param>
 /// <returns></returns>
 public int Add(AODL.Document.Content.Tables.Cell value)
 {
     return base.List.Add(value as object);
 }
コード例 #21
0
		/// <summary>
		/// Converts the paragraph styles.
		/// </summary>
		/// <param name="paragraph">The paragraph.</param>
		/// <param name="paragraphPDF">The paragraph PDF.</param>
		/// <returns>The iText paragraph with converted styles</returns>
		public static ParagraphExt ConvertParagraphStyles(
			AODL.Document.Content.Text.Paragraph paragraph, 
			ParagraphExt paragraphPDF)
		{
			try
			{
				if (paragraph.Style != null)
				{
					if (paragraph.Style is ParagraphStyle 
						&& ((ParagraphStyle)paragraph.Style).ParagraphProperties != null)
					{
						paragraphPDF.Alignment = (ParagraphPropertyConverter.GetAlignMent(
							((ParagraphStyle)paragraph.Style).ParagraphProperties.Alignment));
						
					}

					if (paragraph.Style is ParagraphStyle 
						&& ((ParagraphStyle)paragraph.Style).ParagraphProperties != null
						&& ((ParagraphStyle)paragraph.Style).ParagraphProperties.BreakAfter != null
						&& ((ParagraphStyle)paragraph.Style).ParagraphProperties.BreakAfter.ToLower() == "page")
					{
						paragraphPDF.PageBreakAfter = true;
						
					}

					if (paragraph.Style is ParagraphStyle 
						&& ((ParagraphStyle)paragraph.Style).ParagraphProperties != null
						&& ((ParagraphStyle)paragraph.Style).ParagraphProperties.BreakBefore != null
						&& ((ParagraphStyle)paragraph.Style).ParagraphProperties.BreakBefore.ToLower() == "page")
					{
						paragraphPDF.PageBreakBefore = true;
						
					}
				}
				return paragraphPDF;
			}
			catch(Exception)
			{
				throw;
			}
		}
コード例 #22
0
 /// <summary>
 /// Inserts the specified index.
 /// </summary>
 /// <param name="index">The index.</param>
 /// <param name="value">The value.</param>
 public void Insert(int index, AODL.Document.Styles.MasterStyles.TextMasterPage value)
 {
     base.List.Insert(index, value as object);
 }
コード例 #23
0
 /// <summary>
 /// Exports the specified document.
 /// </summary>
 /// <param name="document">The document.</param>
 /// <param name="filename">The filename.</param>
 public void Export(AODL.Document.IDocument document, string filename)
 {
     try
     {
         this._document			= document;
         PrepareDirectory(dir);
         //Write content
         if(document is TextDocument)
         {
             this.WriteSingleFiles(((TextDocument)document).DocumentManifest.Manifest, dir+DocumentManifest.FolderName+"\\"+DocumentManifest.FileName);
             this.WriteSingleFiles(((TextDocument)document).DocumentMetadata.Meta, dir+DocumentMetadata.FileName);
             this.WriteSingleFiles(((TextDocument)document).DocumentSetting.Settings, dir+DocumentSetting.FileName);
             this.WriteSingleFiles(((TextDocument)document).DocumentStyles.Styles, dir+DocumentStyles.FileName);
             this.WriteSingleFiles(((TextDocument)document).XmlDoc, dir+"content.xml");
             //Save graphics, which were build during creating a new document
             SaveGraphic(((TextDocument)document), dir);
         }
         else if(document is AODL.Document.SpreadsheetDocuments.SpreadsheetDocument)
         {
             this.WriteSingleFiles(((AODL.Document.SpreadsheetDocuments.SpreadsheetDocument)document).DocumentManifest.Manifest, dir+DocumentManifest.FolderName+"\\"+DocumentManifest.FileName);
             this.WriteSingleFiles(((AODL.Document.SpreadsheetDocuments.SpreadsheetDocument)document).DocumentMetadata.Meta, dir+DocumentMetadata.FileName);
             this.WriteSingleFiles(((AODL.Document.SpreadsheetDocuments.SpreadsheetDocument)document).DocumentSetting.Settings, dir+DocumentSetting.FileName);
             this.WriteSingleFiles(((AODL.Document.SpreadsheetDocuments.SpreadsheetDocument)document).DocumentStyles.Styles, dir+DocumentStyles.FileName);
             this.WriteSingleFiles(((AODL.Document.SpreadsheetDocuments.SpreadsheetDocument)document).XmlDoc, dir+"content.xml");
         }
         else
             throw new Exception("Unsupported document type!");
         //Write Pictures and Thumbnails
     //				this.SaveExistingGraphics(document.DocumentPictures, dir+"Pictures\\");
     //				this.SaveExistingGraphics(document.DocumentThumbnails, dir+"Thumbnails\\");
         //Don't know why VS couldn't read a textfile resource without file prefix
         WriteMimetypeFile(dir+@"\mimetyp");
         //Now create the document
         CreateOpenDocument(filename, dir);
         //Clean up resources
         //this.CleanUpDirectory(dir);
     }
     catch(Exception ex)
     {
         throw;
     }
 }
コード例 #24
0
 /// <summary>
 /// Adds the specified value.
 /// </summary>
 /// <param name="value">The value.</param>
 /// <returns></returns>
 public int Add(AODL.Document.Styles.TabStopStyle value)
 {
     this.Node.AppendChild(((TabStopStyle)value).Node);
     return base.List.Add(value as object);
 }
コード例 #25
0
		private void TextContentProcessor_OnWarning(AODL.Document.Exceptions.AODLWarning warning)
		{
			this._importError.Add(warning);
		}
コード例 #26
0
 /// <summary>
 /// Determines whether [contains] [the specified value].
 /// </summary>
 /// <param name="value">The value.</param>
 /// <returns>
 /// 	<c>true</c> if [contains] [the specified value]; otherwise, <c>false</c>.
 /// </returns>
 public bool Contains(AODL.Document.Styles.TabStopStyle value)
 {
     return base.List.Contains(value as object);
 }
コード例 #27
0
 /// <summary>
 /// Determines whether [contains] [the specified value].
 /// </summary>
 /// <param name="value">The value.</param>
 /// <returns>
 /// 	<c>true</c> if [contains] [the specified value]; otherwise, <c>false</c>.
 /// </returns>
 public bool Contains(AODL.Document.Styles.Properties.IProperty value)
 {
     return base.List.Contains(value as object);
 }
コード例 #28
0
 /// <summary>
 /// Inserts the specified index.
 /// </summary>
 /// <param name="index">The index.</param>
 /// <param name="value">The value.</param>
 public void Insert(int index, AODL.Document.Styles.TabStopStyle value)
 {
     //It's not necessary to know the postion of the child node
     this.Node.AppendChild(((TabStopStyle)value).Node);
     base.List.Insert(index, value as object);
 }
コード例 #29
0
 /// <summary>
 /// Removes the specified value.
 /// </summary>
 /// <param name="value">The value.</param>
 public void Remove(AODL.Document.Styles.Properties.IProperty value)
 {
     base.List.Remove(value as object);
 }
コード例 #30
0
		/// <summary>
		/// Create a spreadsheet table.
		/// </summary>
		/// <param name="document">The document.</param>
		/// <param name="tableName">Name of the table.</param>
		/// <param name="styleName">Name of the style.</param>
		/// <returns></returns>
		public static Table CreateSpreadsheetTable(AODL.Document.SpreadsheetDocuments.SpreadsheetDocument document, string tableName, string styleName)
		{
			return new Table(document, tableName, styleName);
		}