Skip to content

Instantly share code, notes, and snippets.

@aspose-pdf
Last active January 16, 2017 06:04
Show Gist options
  • Save aspose-pdf/5570d471f025e92e2979d90138601dce to your computer and use it in GitHub Desktop.
Save aspose-pdf/5570d471f025e92e2979d90138601dce to your computer and use it in GitHub Desktop.
Gist to contain examples of AsposePdfGenerator
Aspose-Pdf-Generator
// For complete examples and data files, please go to https://github.com/aspose-pdf/Aspose.Pdf-for-.NET
// The path to the documents directory.
string dataDir = RunExamples.GetDataDir_AsposePdfGenerator_AdvanceFeatures();
// Instantiate Pdf instance by calling its empty constructor
Aspose.Pdf.Generator.Pdf pdf1 = new Aspose.Pdf.Generator.Pdf();
// Add a section in the Pdf
Aspose.Pdf.Generator.Section sec1 = pdf1.Sections.Add();
// Set the page border of the section using BorderInfo object
sec1.PageInfo.PageBorder = new Aspose.Pdf.Generator.BorderInfo((int)Aspose.Pdf.Generator.BorderSide.All, 0.2F);
// Set the left margin of page border of the section
sec1.PageInfo.PageBorderMargin.Left = 20;
// Add a text paragraph to the paragraphs collection of the section
sec1.Paragraphs.Add(new Aspose.Pdf.Generator.Text("Hello World"));
dataDir = dataDir + "AddPageBorder_out.pdf";
// Save the Pdf
pdf1.Save(dataDir);
// For complete examples and data files, please go to https://github.com/aspose-pdf/Aspose.Pdf-for-.NET
// The implementation of createDataTable method that is being called in the program
public static DataTable creatDataTable()
{
// Creating a DataTable object
DataTable dt = new DataTable("Sample");
// Adding columns to the DataTable
dt.Columns.Add("Beginning of lease", typeof(Int32));
dt.Columns.Add("End of lease", typeof(Int32));
dt.Columns.Add("Landlord's end-of-lease assessment", typeof(string));
dt.Columns.Add("Comments", typeof(string));
// Adding rows to the DataTable
DataRow dr = dt.NewRow();
dr[0] = 12;
dr[1] = 11;
dr[2] = "$32.38";
dr[3] = "M";
dt.Rows.Add(dr);
dr = dt.NewRow();
dr[0] = 22;
dr[1] = 22;
dr[2] = "$148.45";
dr[3] = "G";
dt.Rows.Add(dr);
dr = dt.NewRow();
dr[0] = 41;
dr[1] = 41;
dr[2] = "$11.42";
dr[3] = "S,R";
dt.Rows.Add(dr);
dr = dt.NewRow();
dr[0] = 47;
dr[1] = 40;
dr[2] = "$48.52";
dr[3] = "D";
dt.Rows.Add(dr);
dr = dt.NewRow();
dr[0] = 28;
dr[1] = 20;
dr[2] = "$78.43";
dr[3] = "R";
dt.Rows.Add(dr);
// Returning the instance of DataTable object
return dt;
}
// For complete examples and data files, please go to https://github.com/aspose-pdf/Aspose.Pdf-for-.NET
// The path to the documents directory.
string dataDir = RunExamples.GetDataDir_AsposePdfGenerator_AdvanceFeatures();
// Creating a new Pdf object
Aspose.Pdf.Generator.Pdf pdf = new Aspose.Pdf.Generator.Pdf();
// Binding the content from the named XML file
pdf.BindXML(dataDir + "Sample.xml", null);
// In a real scenario, data is usually input from Database. So, we can get data
// From a database. In this case, we are using a method that will provide us an
// Instance of DataTable. The implementation of this method is also given below.
DataTable getDT = creatDataTable();
// Accessing a table through its ID
Aspose.Pdf.Generator.Table contenTable = (Aspose.Pdf.Generator.Table)pdf.GetObjectByID("Content");
// Importing data from a DataTable and filling the table in PDF document
contenTable.ImportDataTable(getDT, false, 1, 1, 5, 4);
// Saving the results
pdf.Save(dataDir + "Sample_out.pdf");
// For complete examples and data files, please go to https://github.com/aspose-pdf/Aspose.Pdf-for-.NET
// The path to the documents directory.
string dataDir = RunExamples.GetDataDir_AsposePdfGenerator_AdvanceFeatures();
FileStream fs1 = new FileStream(dataDir + "XSLFOToPDF.xml", FileMode.Open);
FileStream fs2 = new FileStream(dataDir + "XSLFOToPDF.xsl", FileMode.Open);
// Instantiate the Pdf instance
Aspose.Pdf.Generator.Pdf pdf1 = new Aspose.Pdf.Generator.Pdf();
// Bind the XML and XSLT file
pdf1.BindXML(fs1, fs2);
// Save the resultant PDF
pdf1.Save(dataDir + "XMlXSLTMERGE_out.pdf");
fs1.Close();
fs2.Close();
// For complete examples and data files, please go to https://github.com/aspose-pdf/Aspose.Pdf-for-.NET
// The path to the documents directory.
string dataDir = RunExamples.GetDataDir_AsposePdfGenerator_AdvanceFeatures();
// Instantiate Pdf instance by calling its empty constructor
Aspose.Pdf.Generator.Pdf pdf1 = new Aspose.Pdf.Generator.Pdf();
MemoryStream stream = new MemoryStream();
HttpResponse Response = new HttpResponse(null);
pdf1.Save(stream);
Response.Clear();
Response.ClearHeaders();
Response.ClearContent();
Response.Charset = "UTF-8";
Response.AddHeader("Content-Length", stream.Length.ToString());
Response.AddHeader("content-disposition", String.Format("attachment;filename={0}", dataDir + "SendingPdfToBrowser.pdf"));
Response.ContentType = "application/pdf";
Response.BinaryWrite(stream.ToArray());
Response.Flush();
Response.End();
// For complete examples and data files, please go to https://github.com/aspose-pdf/Aspose.Pdf-for-.NET
// The path to the documents directory.
string dataDir = RunExamples.GetDataDir_AsposePdfGenerator_AdvanceFeatures();
// Instantiate Pdf instance by calling its empty constructor
Aspose.Pdf.Generator.Pdf pdf1 = new Aspose.Pdf.Generator.Pdf();
// Add a section in the Pdf
Aspose.Pdf.Generator.Section sec1 = pdf1.Sections.Add();
// Create a table object and add it to the paragraphs collection of the section
Aspose.Pdf.Generator.Table tab1 = new Aspose.Pdf.Generator.Table();
sec1.Paragraphs.Add(tab1);
// Set the column widths and default cell border of the table
tab1.ColumnWidths = "60 100 100";
tab1.DefaultCellBorder = new Aspose.Pdf.Generator.BorderInfo((int)Aspose.Pdf.Generator.BorderSide.All, 1F);
// Prepare an array of string values to be added to table
string[] darr = new string[]
{"Owner/Marketing Assistant","dhasf hh ddt", "dhaosdha djsd dsads",
"dsd dajd", "hdsah jj jj jdj", "ddfa jjj jhdusa"};
// Import the contents of the array created in above step
tab1.ImportArray(darr, 0, 0, true);
// Call GetMinColumnWidth and pass the column number whose minimum width is needed
float width = tab1.GetMinColumnWidth(pdf1, 0);
// Call SetColumnWidth and pass the column number with minimum width
tab1.SetColumnWidth(0, width);
dataDir = dataDir + "TableMinimumColumnWidth_out.pdf";
// Save the Pdf
pdf1.Save(dataDir);
// For complete examples and data files, please go to https://github.com/aspose-pdf/Aspose.Pdf-for-.NET
// The path to the documents directory.
string dataDir = RunExamples.GetDataDir_AsposePdfGenerator_AdvanceFeatures();
// Create a Pdf instance and bind the XML template file to Pdf instance
Aspose.Pdf.Generator.Pdf pdf1 = new Aspose.Pdf.Generator.Pdf();
pdf1.BindXML( dataDir + "Template.xml", null);
// Get the section and then table from the obtained section of the Pdf that
// Is built from the XML template
Aspose.Pdf.Generator.Section sec1 = pdf1.Sections["Section1"];
Aspose.Pdf.Generator.Table table1 = sec1.Paragraphs["Table1"] as Aspose.Pdf.Generator.Table;
// Clone a new table
Aspose.Pdf.Generator.Table table2 = table1.CompleteClone() as Aspose.Pdf.Generator.Table;
// Change the ID of table2 to "Table2" to make it different from table1
table2.ID = "Table2";
// Add table2 into the section
sec1.Paragraphs.Add(table2);
// Now there are 2 segments with ID "Item",
// We change the IDs to make sure they are different
Aspose.Pdf.Generator.Segment item = sec1.GetObjectByID("Item") as Aspose.Pdf.Generator.Segment;
item.ID = "Item1";
item = sec1.GetObjectByID("Item") as Aspose.Pdf.Generator.Segment;
item.ID = "Item2";
// Change the content
item.Content = "item 2";
// Now clone section1
Aspose.Pdf.Generator.Section sec2 = sec1.CompleteClone() as Aspose.Pdf.Generator.Section;
// Add a cloned section to the Pdf and change the contents of the text segments
// In the section2 of the Pdf object
pdf1.Sections.Add(sec2);
item = sec2.GetObjectByID("Item1") as Aspose.Pdf.Generator.Segment;
item.Content = "item1 sec2";
item = sec2.GetObjectByID("Item2") as Aspose.Pdf.Generator.Segment;
item.Content = "item2 sec2";
// Save the Pdf
pdf1.Save( dataDir + "XmlTemp_out.pdf");
// For complete examples and data files, please go to https://github.com/aspose-pdf/Aspose.Pdf-for-.NET
// The path to the documents directory.
string dataDir = RunExamples.GetDataDir_AsposePdfGenerator_AdvanceFeatures();
XmlDocument xmlDoc = new XmlDocument();
MemoryStream ms = new MemoryStream();
XslCompiledTransform xsl = new XslCompiledTransform();
xsl.Load(dataDir + "test.xsl");
xsl.Transform(xmlDoc, null, ms);
ms.Position = 0;
xmlDoc.Load(ms);
ms.Close();
// Instantiate the Pdf instance
Aspose.Pdf.Generator.Pdf pdf1 = new Aspose.Pdf.Generator.Pdf();
// Bind the XML file
pdf1.BindXML(xmlDoc, null);
// Save the resultant PDF
pdf1.Save(dataDir + "XSLToPdf_out.pdf");
// For complete examples and data files, please go to https://github.com/aspose-pdf/Aspose.Pdf-for-.NET
// The path to the documents directory.
string dataDir = RunExamples.GetDataDir_AsposePdfGenerator_Attachments();
// Instantiate Pdf document object
Aspose.Pdf.Generator.Pdf pdf1 = new Aspose.Pdf.Generator.Pdf();
// Create a section in the Pdf
Aspose.Pdf.Generator.Section sec1 = pdf1.Sections.Add();
// Instantiate attachment instance by calling its empty constructor
Aspose.Pdf.Generator.Attachment fileAttachment = new Aspose.Pdf.Generator.Attachment();
// Add attachment in the paragraphs collection of the section
sec1.Paragraphs.Add(fileAttachment);
// Set attachment type to File using AttachmentType enumeration
fileAttachment.AttachmentType = Aspose.Pdf.Generator.AttachmentType.File;
// Set the path of the attachment file. This could be any file like doc, tif etc
fileAttachment.AttachedFileName = dataDir + "input.pdf";
// Set the type of the file to be attached
fileAttachment.AttachedFileType = "pdf";
// Set the file icon type to Graph
fileAttachment.FileIconType = Aspose.Pdf.Generator.FileIconType.Graph;
// Set the color of the icon to Brown
fileAttachment.IconColor = new Aspose.Pdf.Generator.Color("Brown");
dataDir = dataDir + "AttachAnyFile_out.pdf";
// Save the Pdf
pdf1.Save(dataDir);
// For complete examples and data files, please go to https://github.com/aspose-pdf/Aspose.Pdf-for-.NET
// The path to the documents directory.
string dataDir = RunExamples.GetDataDir_AsposePdfGenerator_Attachments();
// Instantiate Pdf document object
Aspose.Pdf.Generator.Pdf pdf1 = new Aspose.Pdf.Generator.Pdf();
// Create a section in the Pdf
Aspose.Pdf.Generator.Section sec1 = pdf1.Sections.Add();
// Instantiate attachment instance
Aspose.Pdf.Generator.Attachment noteAttachment = new Aspose.Pdf.Generator.Attachment();
// Add the attachment in the paragraphs collection of the section
sec1.Paragraphs.Add(noteAttachment);
// Set the attachment type to note to make it a note annotation
noteAttachment.AttachmentType = Aspose.Pdf.Generator.AttachmentType.Note;
// Set the content of the note annotation
noteAttachment.NoteContent = "This is a note.";
// Set the title or heading of the note
noteAttachment.NoteHeading = "The title";
// Set the note to be opened when PDF document is opened
noteAttachment.IsNoteOpen = true;
dataDir = dataDir + "AttachNoteAnnotation_out.pdf";
// Save the Pdf
pdf1.Save(dataDir);
// For complete examples and data files, please go to https://github.com/aspose-pdf/Aspose.Pdf-for-.NET
// The path to the documents directory.
string dataDir = RunExamples.GetDataDir_AsposePdfGenerator_Attachments();
// Instantiate Pdf document object
Aspose.Pdf.Generator.Pdf pdf1 = new Aspose.Pdf.Generator.Pdf();
// Create a section in the Pdf
Aspose.Pdf.Generator.Section sec1 = pdf1.Sections.Add();
// Instantiate attachment instance by calling its empty constructor
Aspose.Pdf.Generator.Attachment noteAttachment = new Aspose.Pdf.Generator.Attachment();
// Add the attachment in the paragraphs collection of the section
sec1.Paragraphs.Add(noteAttachment);
// Set the attachment type to Note
noteAttachment.AttachmentType = Aspose.Pdf.Generator.AttachmentType.Note;
// Store some content for the note to display
noteAttachment.NoteContent =
"This is a test for note popup window positioning.";
// Set the heading or title of the note
noteAttachment.NoteHeading = "Test";
// Set the note to be opened when PDF document is opened
noteAttachment.IsNoteOpen = true;
// Set the positioning type of the note's popup window to Absolute
noteAttachment.NoteWindowPositioningType = Aspose.Pdf.Generator.NoteWindowPositioningType.Absolute;
// Set the position of the note's popup window
noteAttachment.NoteWindowPosition = new Aspose.Pdf.Generator.RectangleArea(100, 100, 160, 100);
dataDir = dataDir + "CustomizeNotePosition_out.pdf";
// Save the Pdf
pdf1.Save(dataDir);
// For complete examples and data files, please go to https://github.com/aspose-pdf/Aspose.Pdf-for-.NET
// The path to the documents directory.
string dataDir = RunExamples.GetDataDir_AsposePdfGenerator_Conversion();
// Instantiate an object PDF class
Aspose.Pdf.Generator.Pdf pdf = new Aspose.Pdf.Generator.Pdf();
// Add the section to PDF document sections collection
Aspose.Pdf.Generator.Section section = pdf.Sections.Add();
// Read the contents of HTML file into StreamReader object
StreamReader r = File.OpenText(dataDir + "resultant.html");
// Create text paragraphs containing HTML text
Aspose.Pdf.Generator.Text text2 = new Aspose.Pdf.Generator.Text(section, r.ReadToEnd());
// Enable the property to display HTML contents within their own formatting
text2.IsHtmlTagSupported = true;
text2.IfHtmlTagSupportedOverwriteHtmlFontNames = true;
text2.IfHtmlTagSupportedOverwriteHtmlFontSizes = true;
// Add the text paragraphs containing HTML text to the section
section.Paragraphs.Add(text2);
// Specify the URL which serves as images database
pdf.HtmlInfo.ImgUrl = dataDir;
// Following properties are added from Aspose.Pdf for .NET 8.4.0
pdf.HtmlInfo.BadHtmlHandlingStrategy = BadHtmlHandlingStrategy.TreatAsPlainText;
pdf.HtmlInfo.ShowUnknownHtmlTagsAsText = true;
// Save the Pdf document
pdf.Save(dataDir + "HTML2pdf_out.pdf");
// For complete examples and data files, please go to https://github.com/aspose-pdf/Aspose.Pdf-for-.NET
text2.IfHtmlTagSupportedOverwriteHtmlFontNames = true;
text2.IfHtmlTagSupportedOverwriteHtmlFontSizes = true;
// For complete examples and data files, please go to https://github.com/aspose-pdf/Aspose.Pdf-for-.NET
// Following properties are added from Aspose.Pdf for .NET 8.4.0
pdf.HtmlInfo.BadHtmlHandlingStrategy = BadHtmlHandlingStrategy.TreatAsPlainText;
pdf.HtmlInfo.ShowUnknownHtmlTagsAsText = true;
// For complete examples and data files, please go to https://github.com/aspose-pdf/Aspose.Pdf-for-.NET
// The path to the documents directory.
string dataDir = RunExamples.GetDataDir_AsposePdfGenerator_Conversion();
// Instantiate Pdf object
Aspose.Pdf.Generator.Pdf pdf = new Aspose.Pdf.Generator.Pdf();
// Specify the Character encoding for HTML file
pdf.HtmlInfo.CharSet = "UTF-8";
pdf.HtmlInfo.CharsetApplyingLevelOfForce = HtmlInfo.CharsetApplyingForceLevel.EnforceUseAlways;
// Load the HTML file to Stream object
using (Stream htmlAsStream = System.IO.File.OpenRead(dataDir + "resultant.html"))
{
// Bind the source HTML
pdf.BindHTML(htmlAsStream, "");
}
// Save the PDF file
pdf.Save(dataDir + "EnforceUseAlways_out.pdf");
// For complete examples and data files, please go to https://github.com/aspose-pdf/Aspose.Pdf-for-.NET
// The path to the documents directory.
string dataDir = RunExamples.GetDataDir_AsposePdfGenerator_Conversion();
// Instantiate Pdf object
Aspose.Pdf.Generator.Pdf pdf = new Aspose.Pdf.Generator.Pdf();
// Specify the Character encoding for HTML file
pdf.HtmlInfo.CharSet = "UTF-8";
pdf.HtmlInfo.CharsetApplyingLevelOfForce = HtmlInfo.CharsetApplyingForceLevel.UseWhenImpossibleDetectFromContent;
// Load the HTML file to Stream object
using (Stream htmlAsStream = System.IO.File.OpenRead(dataDir + "resultant.html"))
{
// Bind the source HTML
pdf.BindHTML(htmlAsStream, "");
}
// Save the PDF file
pdf.Save(dataDir + "HTMLToPDFUsingStream_out.pdf");
// For complete examples and data files, please go to https://github.com/aspose-pdf/Aspose.Pdf-for-.NET
// The path to the documents directory.
string dataDir = RunExamples.GetDataDir_AsposePdfGenerator_Conversion();
// Instantiate Pdf object
Aspose.Pdf.Generator.Pdf pdf = new Aspose.Pdf.Generator.Pdf();
// Bind the source PCL file
pdf.BindPCL( dataDir + "hidetext.pcl");
// Save the resultant PDF document
pdf.Save(dataDir + "PCLToPDF_out.pdf");
// For complete examples and data files, please go to https://github.com/aspose-pdf/Aspose.Pdf-for-.NET
// The path to the documents directory.
string dataDir = RunExamples.GetDataDir_AsposePdfGenerator_Conversion();
// Instantiate Pdf object
Aspose.Pdf.Generator.Pdf pdf = new Aspose.Pdf.Generator.Pdf();
// Bind the source SVG file
pdf.BindSvg( dataDir + "SVGToPDF.svg");
// Save the resultant PDF document
pdf.Save(dataDir + @"SVGToPDF_out.pdf");
// For complete examples and data files, please go to https://github.com/aspose-pdf/Aspose.Pdf-for-.NET
// The path to the documents directory.
string dataDir = RunExamples.GetDataDir_AsposePdfGenerator_Conversion();
// The address of the web URL which you need to convert into PDF format
string WebUrl = "http:// En.wikipedia.org/wiki/Main_Page";
// Create a Web Request object to connect to remote URL
HttpWebRequest request = (HttpWebRequest)WebRequest.Create(WebUrl);
// Set the Web Request timeout
request.Timeout = 10000; // 10 secs
// Retrieve request info headers
HttpWebResponse localWebResponse = (HttpWebResponse)request.GetResponse();
// Windows default Code Page (Include System.Text namespace in project)
Encoding encoding = Encoding.GetEncoding(1252);
// Read the contents of into StreamReader object
StreamReader localResponseStream = new StreamReader(localWebResponse.GetResponseStream(), encoding);
// Instantiate an object PDF class
Aspose.Pdf.Generator.Pdf pdf = new Aspose.Pdf.Generator.Pdf();
// Add the section to PDF document sections collection
Aspose.Pdf.Generator.Section section = pdf.Sections.Add();
// Create text paragraphs containing HTML text
Aspose.Pdf.Generator.Text text2 = new Aspose.Pdf.Generator.Text(section, localResponseStream.ReadToEnd());
// Enable the property to display HTML contents within their own formatting
text2.IsHtmlTagSupported = true;
// Add the text object containing HTML contents to PD Sections
section.Paragraphs.Add(text2);
// Specify the URL which serves as images database
// Pdf.HtmlInfo.ImgUrl = "http:// En.wikipedia.org/";
// Save the pdf document
pdf.Save(dataDir + "WebToPDF_out.pdf");
localWebResponse.Close();
localResponseStream.Close();
// For complete examples and data files, please go to https://github.com/aspose-pdf/Aspose.Pdf-for-.NET
// The path to the documents directory.
string dataDir = RunExamples.GetDataDir_AsposePdfGenerator_Conversion();
// Set up your product license.
// If you just want to evaluate Aspose.Pdf, you can annotate these two lines.
// License license = new License();
// License.SetLicense(dataDir + "Aspose.Total.lic");
// Create a Converter object..
Aspose.Pdf.Generator.Pdf app;
System.IO.Stream pdf;
string name = "XSLFOToPDF";
string fo = dataDir + name + ".fo";
string xml = dataDir + name + ".xml";
string xsl = dataDir + name + ".xsl";
// Create the XmlDocument.
XmlDocument doc_fo = new XmlDocument();
doc_fo.Load(new StreamReader(fo));
XPathDocument doc_xml = new XPathDocument(xml);
XmlDocument doc_xsl = new XmlDocument();
doc_xsl.Load(new StreamReader(xsl));
// 1. fo:string2string
app = new Aspose.Pdf.Generator.Pdf();
app.BindFO(fo);
app.Save(dataDir + name + "_fo_sring2string.pdf");
// 2. fo:string2stream
app = new Aspose.Pdf.Generator.Pdf();
app.BindFO(fo);
pdf = new System.IO.FileStream(name + "_fo_string2stream.pdf", System.IO.FileMode.Create);
app.Save(pdf);
// 3. fo:stream2string
app = new Aspose.Pdf.Generator.Pdf();
app.BindFO(doc_fo, doc_xsl);
app.Save(dataDir + name + "_fo_stream2string.pdf");
// 4. fo:stream2stream
app = new Aspose.Pdf.Generator.Pdf();
app.BindFO(doc_fo, doc_xsl);
pdf = new System.IO.FileStream(name + "_fo_stream2stream.pdf", System.IO.FileMode.Create);
app.Save(pdf);
// 5. fo:doc2string
app = new Aspose.Pdf.Generator.Pdf();
app.BindFO(doc_fo);
app.Save(dataDir + name + "_fo_doc2string.pdf");
// 6. fo:doc2stream
app = new Aspose.Pdf.Generator.Pdf();
app.BindFO(doc_fo);
pdf = new System.IO.FileStream(name + "_fo_doc2stream.pdf", System.IO.FileMode.Create);
app.Save(pdf);
// 7. xml:string2string
app = new Aspose.Pdf.Generator.Pdf();
app.BindFO(xml);
app.Save(dataDir + name + "_xml_string2string.pdf");
// 8. xml:string2stream
app = new Aspose.Pdf.Generator.Pdf();
app.BindFO(xml);//, xsl);
pdf = new System.IO.FileStream(name + "_xml_string2stream.pdf", System.IO.FileMode.Create);
app.Save(pdf);
// 9. xml:doc2string
app = new Aspose.Pdf.Generator.Pdf();
app.BindFO(xml);
app.Save(dataDir + name + "_xml_doc2string.pdf");
// 10. xml:doc2stream
app = new Aspose.Pdf.Generator.Pdf();
app.BindFO(xml);
pdf = new System.IO.FileStream(name + "_xml_doc2stream.pdf", System.IO.FileMode.Create);
app.Save(pdf);
// 0. An example of how to set the metadata of your generated pdf document
// If you do not want to set these tedious metadata of pdf, you can set the
// Second parameter of Save method to be "null" simply, as shown in above.
// At first create a IDictionary to contain your metadata.
System.Collections.IDictionary metadata = new System.Collections.Hashtable();
// Then set the various items.
// If you don't set them, Aspose.Pdf.Fo will set default value.
// A. title of your pdf doc:
metadata.Add("Title", "New Title");
// B. author of your pdf doc:
metadata.Add("Author", "New Author");
// C. subject of your pdf doc:
metadata.Add("Subject", "New Subject");
// D. keywords of your pdf doc:
metadata.Add("Keywords", "New Key Words");
// E. creator of your pdf doc:
metadata.Add("Creator", "New Creator");
// F. producer of your pdf doc:
metadata.Add("Producer", "New Producer");
// Make this IDictionary be the parameter of Save method, and start converting.
app = new Aspose.Pdf.Generator.Pdf();
// App.FoMetaData = metadata;
app.BindFO(fo);
app.Save(dataDir + "Test_out.pdf");
// For complete examples and data files, please go to https://github.com/aspose-pdf/Aspose.Pdf-for-.NET
// The path to the documents directory.
string dataDir = RunExamples.GetDataDir_AsposePdfGenerator_Conversion();
// Create pdf document
Aspose.Pdf.Generator.Pdf pdf = new Aspose.Pdf.Generator.Pdf();
// Bind FO document with Pdf object
pdf.BindFO( dataDir + "XSLFOToPDF.fo");
// Save the PDF document
pdf.Save(dataDir + "XSLFOToPDFUsingBind_out.pdf");
// For complete examples and data files, please go to https://github.com/aspose-pdf/Aspose.Pdf-for-.NET
// The path to the documents directory.
string dataDir = RunExamples.GetDataDir_AsposePdfGenerator_General();
// Instantiate Pdf instance by calling its empty constructor
Aspose.Pdf.Generator.Pdf pdf1 = new Aspose.Pdf.Generator.Pdf();
// Create section object and add it to sections collection of PDF
Aspose.Pdf.Generator.Section sec1 = pdf1.Sections.Add();
// Create FloatingBox with 108 as width and 80 as height
Aspose.Pdf.Generator.FloatingBox box1 = new Aspose.Pdf.Generator.FloatingBox(108, 80);
// Add FloatingBox to paragraphs collection of section object
sec1.Paragraphs.Add(box1);
box1.BoxHorizontalPositioning = Aspose.Pdf.Generator.BoxHorizontalPositioningType.Margin;
box1.BoxHorizontalAlignment = Aspose.Pdf.Generator.BoxHorizontalAlignmentType.Right;
box1.BoxVerticalPositioning = Aspose.Pdf.Generator.BoxVerticalPositioningType.Page;
box1.BoxVerticalAlignment = Aspose.Pdf.Generator.BoxVerticalAlignmentType.Center;
// Add sample text string to paragraphs collection of FloatingBox object
box1.Paragraphs.Add(new Aspose.Pdf.Generator.Text("Hello."));
dataDir = dataDir + "FloatingBox_out.pdf";
// Save the resultant PDF
pdf1.Save(dataDir);
// For complete examples and data files, please go to https://github.com/aspose-pdf/Aspose.Pdf-for-.NET
box1.BoxHorizontalPositioning = Aspose.Pdf.Generator.BoxHorizontalPositioningType.Margin;
box1.BoxHorizontalAlignment = Aspose.Pdf.Generator.BoxHorizontalAlignmentType.Right;
box1.BoxVerticalPositioning = Aspose.Pdf.Generator.BoxVerticalPositioningType.Page;
box1.BoxVerticalAlignment = Aspose.Pdf.Generator.BoxVerticalAlignmentType.Center;
// For complete examples and data files, please go to https://github.com/aspose-pdf/Aspose.Pdf-for-.NET
// The path to the documents directory.
string dataDir = RunExamples.GetDataDir_AsposePdfGenerator_General();
// Create pdf document
Aspose.Pdf.Generator.Pdf pdf1 = new Aspose.Pdf.Generator.Pdf();
// Instantiate License class and call its SetLicense method to use the license
Aspose.Pdf.License license = new Aspose.Pdf.License();
license.SetLicense("Aspose.Pdf.lic");
// Add a section into the pdf document
Aspose.Pdf.Generator.Section sec1 = pdf1.Sections.Add();
// Add a text paragraph into the section
sec1.Paragraphs.Add(new Aspose.Pdf.Generator.Text("Hello World"));
dataDir = dataDir + "HelloWorldUsingAPI_out.pdf";
// Save the document
pdf1.Save(dataDir);
// For complete examples and data files, please go to https://github.com/aspose-pdf/Aspose.Pdf-for-.NET
// The path to the documents directory.
string dataDir = RunExamples.GetDataDir_AsposePdfGenerator_General();
// Create pdf document
Aspose.Pdf.Generator.Pdf pdf1 = new Aspose.Pdf.Generator.Pdf();
// Instantiate License class and call its SetLicense method to use the license
Aspose.Pdf.License license = new Aspose.Pdf.License();
license.SetLicense("Aspose.Pdf.lic");
// Bind XML into the document
pdf1.BindXML(dataDir + "HelloWorld.XML", null);
dataDir = dataDir + "HelloWorldUsingXML_out.pdf";
// Save the document
pdf1.Save(dataDir);
// For complete examples and data files, please go to https://github.com/aspose-pdf/Aspose.Pdf-for-.NET
// The path to the documents directory.
string dataDir = RunExamples.GetDataDir_AsposePdfGenerator_General();
// Create pdf document
Aspose.Pdf.Generator.Pdf pdf1 = new Aspose.Pdf.Generator.Pdf();
// Instantiate License class and call its SetLicense method to use the license
Aspose.Pdf.License license = new Aspose.Pdf.License();
license.SetLicense("Aspose.Pdf.lic");
// Bind XML into the document
pdf1.BindXML(dataDir + "HelloWorldUsingAPI.XML", null);
// Get the first Section from the PDF document
Aspose.Pdf.Generator.Section sec1 = pdf1.Sections[0];
// Get the Text paragraph (whose ID is Text1) from the section
Aspose.Pdf.Generator.Text text1 = sec1.Paragraphs["Text1"] as Aspose.Pdf.Generator.Text;
// Add a text Segment to the text paragraph
text1.Segments.Add("Hello World");
dataDir = dataDir + "HelloWorldUsingXMLAndAPI_out.pdf";
// Save the document
pdf1.Save(dataDir);
// For complete examples and data files, please go to https://github.com/aspose-pdf/Aspose.Pdf-for-.NET
// The path to the documents directory.
string dataDir = RunExamples.GetDataDir_AsposePdfGenerator_General();
// Create pdf document
Aspose.Pdf.Generator.Pdf pdf1 = new Aspose.Pdf.Generator.Pdf();
// Instantiate License class and call its SetLicense method to use the license
Aspose.Pdf.License license = new Aspose.Pdf.License();
license.SetLicense("Aspose.Pdf.lic");
// Bind XML and XSLT files to the document
pdf1.BindXML(dataDir + "HelloWorldUsingXSLT.XML", dataDir + "HelloWorld.xslt");
dataDir = dataDir + "HelloWorldUsingXSLT_out.pdf";
// Save the document
pdf1.Save(dataDir);
// For complete examples and data files, please go to https://github.com/aspose-pdf/Aspose.Pdf-for-.NET
// Specify the Horizontal Positioning type for FloatingBox as Margin
box1.BoxHorizontalPositioning = Aspose.Pdf.Generator.BoxHorizontalPositioningType.Margin;
// Set the left margin information as 200
box1.Left = 200;
// Specify the Vertical Positioning type for FloatingBox object
box1.BoxVerticalPositioning = Aspose.Pdf.Generator.BoxVerticalPositioningType.Page;
// Set the Top margin information as 300
box1.Top = 300;
// For complete examples and data files, please go to https://github.com/aspose-pdf/Aspose.Pdf-for-.NET
// The path to the documents directory.
string dataDir = RunExamples.GetDataDir_AsposePdfGenerator_General();
// Instantiate Pdf instance by calling its empty constructor
Aspose.Pdf.Generator.Pdf pdf1 = new Aspose.Pdf.Generator.Pdf();
// Create section object and add it to sections collection of PDF
Aspose.Pdf.Generator.Section sec1 = pdf1.Sections.Add();
// Create FloatingBox with 108 as width and 80 as height
Aspose.Pdf.Generator.FloatingBox box1 = new Aspose.Pdf.Generator.FloatingBox(108, 80);
// Add FloatingBox to paragraphs collection of section object
sec1.Paragraphs.Add(box1);
// Specify the Horizontal Positioning type for FloatingBox as Margin
box1.BoxHorizontalPositioning = Aspose.Pdf.Generator.BoxHorizontalPositioningType.Margin;
// Set the left margin information as 200
box1.Left = 200;
// Specify the Vertical Positioning type for FloatingBox object
box1.BoxVerticalPositioning = Aspose.Pdf.Generator.BoxVerticalPositioningType.Page;
// Set the Top margin information as 300
box1.Top = 300;
// Add sample text string to paragraphs collection of FloatingBox object
box1.Paragraphs.Add(new Aspose.Pdf.Generator.Text("Hello."));
dataDir = dataDir + "PositionFloatingBox_out.pdf";
// Save the resultant PDF
pdf1.Save(dataDir);
// For complete examples and data files, please go to https://github.com/aspose-pdf/Aspose.Pdf-for-.NET
// The path to the documents directory.
string dataDir = RunExamples.GetDataDir_AsposePdfGenerator_Graphs();
// Instantiate a Pdf document object
Aspose.Pdf.Generator.Pdf pdf1 = new Aspose.Pdf.Generator.Pdf();
// Add a section to the Pdf document
Aspose.Pdf.Generator.Section sec1 = pdf1.Sections.Add();
// Create a graph object in the section with Width=100 and Height=400
Aspose.Pdf.Generator.Graph graph1 = new Aspose.Pdf.Generator.Graph(sec1,100,400);
// Add the graph object to the paragraphs collection of the section
sec1.Paragraphs.Add(graph1);
// Create an array containing the (X,Y) values of 4 control points
// Required to position a curve
float[] posArr = new float[]{0,0,200,80,300,40,350,90};
// Create a curve in the graph with the coordinates given as an array to
// The constructor of curve class
Aspose.Pdf.Generator.Curve curve1 = new Aspose.Pdf.Generator.Curve(graph1,posArr);
// Add the curve shape into the shapes collection of the graph
graph1.Shapes.Add(curve1);
dataDir = dataDir + "GraphCoordinate_out.pdf";
// Save the Pdf
pdf1.Save(dataDir);
// For complete examples and data files, please go to https://github.com/aspose-pdf/Aspose.Pdf-for-.NET
// The path to the documents directory.
string dataDir = RunExamples.GetDataDir_AsposePdfGenerator_Graphs();
// Instantiate Pdf document by calling its empty constructor
Aspose.Pdf.Generator.Pdf pdf1 = new Aspose.Pdf.Generator.Pdf();
// Create a section in the Pdf document
Aspose.Pdf.Generator.Section sec1 = pdf1.Sections.Add();
// Create a graph in the section with Width=100 and Height=400
Aspose.Pdf.Generator.Graph graph1 = new Aspose.Pdf.Generator.Graph(sec1, 100, 400);
// Add the graph object to paragraphs collection of the section
sec1.Paragraphs.Add(graph1);
// Create a circle shape in the graph with X=200, Y=50 and Radius=30
Aspose.Pdf.Generator.Circle circle1 = new Aspose.Pdf.Generator.Circle(graph1, 200, 50, 30);
// Add the circle in the shapes collection of the graph
graph1.Shapes.Add(circle1);
// Set fill color of the circle using GraphInfo property of circle object
circle1.GraphInfo.FillColor = new Aspose.Pdf.Generator.Color("Green");
// Enable the circle to be filled with the color specified above line
circle1.GraphInfo.IsFilled = true;
dataDir = dataDir + "GraphFormat_out.pdf";
// Save the Pdf
pdf1.Save(dataDir);
// For complete examples and data files, please go to https://github.com/aspose-pdf/Aspose.Pdf-for-.NET
// The path to the documents directory.
string dataDir = RunExamples.GetDataDir_AsposePdfGenerator_Graphs();
// Instantiate Pdf instance by calling its empty constructor
Aspose.Pdf.Generator.Pdf pdf1 = new Aspose.Pdf.Generator.Pdf();
// Create a section in the Pdf document
Aspose.Pdf.Generator.Section sec1 = pdf1.Sections.Add();
// Create 1st graph in the section with width=100 and height=400
Aspose.Pdf.Generator.Graph graph1 = new Aspose.Pdf.Generator.Graph(sec1, 100, 400);
// Add 1st graph into the paragraphs collection of the section
sec1.Paragraphs.Add(graph1);
// Create a rectangle shape with specified coordinates
Aspose.Pdf.Generator.Rectangle rect1 = new Aspose.Pdf.Generator.Rectangle(graph1, 85, 100, 100, 50);
// Add the rectangle into the shapes collection of the 1st graph
graph1.Shapes.Add(rect1);
// Create 2nd graph in the section with width=100 and height=400
Aspose.Pdf.Generator.Graph graph2 = new Aspose.Pdf.Generator.Graph(sec1, 100, 400);
// Add 2nd graph into the paragraphs collection of the section
sec1.Paragraphs.Add(graph2);
// Create a rectangle shape with specified coordinates
Aspose.Pdf.Generator.Rectangle rect2 = new Aspose.Pdf.Generator.Rectangle(graph2, 85, 100, 100, 50);
// Add the rectangle into the shapes collection of the 2nd graph
graph2.Shapes.Add(rect2);
// Rotate the 2nd graph to 30 degree using RotationAngle property
graph2.GraphInfo.RotationAngle = 30;
// Create 3rd graph in the section with width=100 and height=400
Aspose.Pdf.Generator.Graph graph3 = new Aspose.Pdf.Generator.Graph(sec1, 100, 400);
// Add 3rd graph into the paragraphs collection of the section
sec1.Paragraphs.Add(graph3);
// Create a rectangle shape with specified coordinates
Aspose.Pdf.Generator.Rectangle rect3 = new Aspose.Pdf.Generator.Rectangle(graph3, 85, 100, 100, 50);
// Add the rectangle into the shapes collection of the 3rd graph
graph3.Shapes.Add(rect3);
// Adjust the horizontal size of the 3rd graph using ScalingRateX property
graph3.GraphInfo.ScalingRateX = 1.5f;
dataDir = dataDir + "RotationAndScaling_out.pdf";
// Save the Pdf
pdf1.Save(dataDir);
// For complete examples and data files, please go to https://github.com/aspose-pdf/Aspose.Pdf-for-.NET
// The path to the documents directory.
string dataDir = RunExamples.GetDataDir_AsposePdfGenerator_Headings();
// Instntiate the Pdf object by calling its empty constructor
Aspose.Pdf.Generator.Pdf pdf1 = new Aspose.Pdf.Generator.Pdf();
// Create the section in the Pdf object
Aspose.Pdf.Generator.Section sec1 = pdf1.Sections.Add();
/*
* Create 1st heading in the Pdf object's section with level=1. Then create
* a text segment and add it in the heading. Set its numbering style to "Arab"
* using HeadingType enumeration. And don't forget to set IsAutoSequence=true.
* If IsAutoSeguence property is set to true then the heading's sequence is
* controlled automatically by Aspose.Pdf. After setting all properties, add
* heading into the paragraphs collection of the section
*/
Aspose.Pdf.Generator.Heading heading1 = new Aspose.Pdf.Generator.Heading(pdf1, sec1, 1);
Aspose.Pdf.Generator.Segment segment1 = new Aspose.Pdf.Generator.Segment(heading1);
heading1.Segments.Add(segment1);
segment1.Content = "Arab";
heading1.HeadingType = Aspose.Pdf.Generator.HeadingType.Arab;
heading1.IsAutoSequence = true;
sec1.Paragraphs.Add(heading1);
/*
* Create 2nd heading in the Pdf object's section with level=1. Then create
* a text segment and add it in the heading. Set its numbering style to "RomanUpper"
* using HeadingType enumeration. And don't forget to set IsAutoSequence=true.
* If IsAutoSeguence property is set to true then the heading's sequence is
* controlled automatically by Aspose.Pdf for .NET. After setting all properties, add
* heading into the paragraphs collection of the section
*/
Aspose.Pdf.Generator.Heading heading2 = new Aspose.Pdf.Generator.Heading(pdf1, sec1, 1);
Aspose.Pdf.Generator.Segment segment2 = new Aspose.Pdf.Generator.Segment(heading2);
heading2.Segments.Add(segment2);
segment2.Content = "RomanUpper";
heading2.HeadingType = Aspose.Pdf.Generator.HeadingType.RomanUpper;
heading2.IsAutoSequence = true;
sec1.Paragraphs.Add(heading2);
/*
* Create 3rd heading in the Pdf object's section with level=1. Then create
* a text segment and add it in the heading. Set its numbering style to "RomanLower"
* using HeadingType enumeration. And don't forget to set IsAutoSequence=true.
* If IsAutoSeguence property is set to true then the heading's sequence is
* controlled automatically by Aspose.Pdf for .NET. After setting all properties, add
* heading into the paragraphs collection of the section
*/
Aspose.Pdf.Generator.Heading heading3 = new Aspose.Pdf.Generator.Heading(pdf1, sec1, 1);
Aspose.Pdf.Generator.Segment segment3 = new Aspose.Pdf.Generator.Segment(heading3);
heading3.Segments.Add(segment3);
segment3.Content = "RomanLower";
heading3.HeadingType = Aspose.Pdf.Generator.HeadingType.RomanLower;
heading3.IsAutoSequence = true;
sec1.Paragraphs.Add(heading3);
/*
* Create 4th heading in the Pdf object's section with level=1. Then create a
* text segment and add it in the heading. Set its numbering style to "EnglishUpper"
* using HeadingType enumeration. And don't forget to set IsAutoSequence=true.
* If IsAutoSeguence property is set to true then the heading's sequence is
* controlled automatically by Aspose.Pdf for .NET. After setting all properties, add
* heading into the paragraphs collection of the section
*/
Aspose.Pdf.Generator.Heading heading4 = new Aspose.Pdf.Generator.Heading(pdf1, sec1, 1);
Aspose.Pdf.Generator.Segment segment4 = new Aspose.Pdf.Generator.Segment(heading4);
heading4.Segments.Add(segment4);
segment4.Content = "EnglishUpper";
heading4.HeadingType = Aspose.Pdf.Generator.HeadingType.EnglishUpper;
heading4.IsAutoSequence = true;
sec1.Paragraphs.Add(heading4);
/*
* Create 5th heading in the Pdf object's section with level=1. Then create a
* text segment and add it in the heading. Set its numbering style to "EnglishLower"
* using HeadingType enumeration. And don't forget to set IsAutoSequence=true.
* If IsAutoSeguence property is set to true then the heading's sequence is
* controlled automatically by Aspose.Pdf for .NET. After setting all properties, add
* heading into the paragraphs collection of the section
*/
Aspose.Pdf.Generator.Heading heading5 = new Aspose.Pdf.Generator.Heading(pdf1, sec1, 1);
Aspose.Pdf.Generator.Segment segment5 = new Aspose.Pdf.Generator.Segment(heading5);
heading5.Segments.Add(segment5);
segment5.Content = "EnglishLower";
heading5.HeadingType = Aspose.Pdf.Generator.HeadingType.EnglishLower;
heading5.IsAutoSequence = true;
sec1.Paragraphs.Add(heading5);
pdf1.Save( dataDir + "headings_out.pdf");
// For complete examples and data files, please go to https://github.com/aspose-pdf/Aspose.Pdf-for-.NET
// The path to the documents directory.
string dataDir = RunExamples.GetDataDir_AsposePdfGenerator_Headings();
// Instntiate the Pdf object by calling its empty constructor
Aspose.Pdf.Generator.Pdf pdf1 = new Aspose.Pdf.Generator.Pdf();
// Create the section in the Pdf object
Aspose.Pdf.Generator.Section sec1 = pdf1.Sections.Add();
/*
* Create 1st heading in the Pdf object's section with level=1. Then create
* a text segment and add it in the heading. Set its StartNumber=6 to start
* the numbering from 6 and onwards. And don't forget to set IsAutoSequence=true.
* If IsAutoSeguence property is set to true then the heading's sequence is
* controlled automatically by Aspose.Pdf for .NET. After setting all properties, add
* heading into the paragraphs collection of the section
*/
Aspose.Pdf.Generator.Heading heading1 = new Aspose.Pdf.Generator.Heading(pdf1, sec1, 1);
Aspose.Pdf.Generator.Segment segment1 = new Aspose.Pdf.Generator.Segment(heading1);
heading1.Segments.Add(segment1);
segment1.Content = "Level 1";
heading1.IsAutoSequence = true;
heading1.StartNumber = 6;
sec1.Paragraphs.Add(heading1);
/*
* Create 2nd heading in the Pdf object's section with level=2. Then create
* a text segment and add it in the heading. And don't forget to set
* IsAutoSequence=true.If IsAutoSeguence property is set to true then the
* heading's sequence is controlled automatically by Aspose.Pdf for .NET. After setting
* all properties, add heading into the paragraphs collection of the section
*/
Aspose.Pdf.Generator.Heading heading2 = new Aspose.Pdf.Generator.Heading(pdf1, sec1, 2);
Aspose.Pdf.Generator.Segment segment2 = new Aspose.Pdf.Generator.Segment(heading2);
heading2.Segments.Add(segment2);
segment2.Content = "Level 2";
heading2.IsAutoSequence = true;
sec1.Paragraphs.Add(heading2);
/*
* Create 3rd heading in the Pdf object's section with level=3. Then create
* a text segment and add it in the heading. And don't forget to set
* IsAutoSequence=true.If IsAutoSeguence property is set to true then the
* heading's sequence is controlled automatically by Aspose.Pdf for .NET. After setting
* all properties, add heading into the paragraphs collection of the section
*/
Aspose.Pdf.Generator.Heading heading3 = new Aspose.Pdf.Generator.Heading(pdf1, sec1, 3);
Aspose.Pdf.Generator.Segment segment3 = new Aspose.Pdf.Generator.Segment(heading3);
heading3.Segments.Add(segment3);
segment3.Content = "Level 3";
heading3.IsAutoSequence = true;
sec1.Paragraphs.Add(heading3);
pdf1.Save(dataDir + "SpecifyHeadingLevel_out.pdf");
// For complete examples and data files, please go to https://github.com/aspose-pdf/Aspose.Pdf-for-.NET
// The path to the documents directory.
string dataDir = RunExamples.GetDataDir_AsposePdfGenerator_Headings();
// Instntiate the Pdf object by calling its empty constructor
Aspose.Pdf.Generator.Pdf pdf1 = new Aspose.Pdf.Generator.Pdf();
// Create the section in the Pdf object
Aspose.Pdf.Generator.Section sec1 = pdf1.Sections.Add();
/*
* Create 1st heading in the Pdf object's section with level=1. Then create
* a text segment and add it in the heading. Set its UserLabel="Bullet1" to
* use system defined bullet. After setting all properties, add heading into
* the paragraphs collection of the section
*/
Aspose.Pdf.Generator.Heading heading1 = new Aspose.Pdf.Generator.Heading(pdf1, sec1, 1);
Aspose.Pdf.Generator.Segment segment1 = new Aspose.Pdf.Generator.Segment(heading1);
heading1.Segments.Add(segment1);
segment1.Content = "Bullet1";
heading1.UserLabel = "Bullet1";
sec1.Paragraphs.Add(heading1);
/*
* Create 2nd heading in the Pdf object's section with level=2. Then create
* a text segment and add it in the heading. Set its UserLabel="Bullet2" to
* use system defined bullet. After setting all properties, add heading into
* the paragraphs collection of the section
*/
Aspose.Pdf.Generator.Heading heading2 = new Aspose.Pdf.Generator.Heading(pdf1, sec1, 2);
Aspose.Pdf.Generator.Segment segment2 = new Aspose.Pdf.Generator.Segment(heading2);
heading2.Segments.Add(segment2);
segment2.Content = "Bullet2";
heading2.UserLabel = "Bullet2";
sec1.Paragraphs.Add(heading2);
/*
* Create 3rd heading in the Pdf object's section with level=3. Then create
* a text segment and add it in the heading. Set its UserLabel="Bullet3" to
* use system defined bullet. After setting all properties, add heading into
* the paragraphs collection of the section
*/
Aspose.Pdf.Generator.Heading heading3 = new Aspose.Pdf.Generator.Heading(pdf1, sec1, 3);
Aspose.Pdf.Generator.Segment segment3 = new Aspose.Pdf.Generator.Segment(heading3);
heading3.Segments.Add(segment3);
segment3.Content = "Bullet3";
heading3.UserLabel = "Bullet3";
sec1.Paragraphs.Add(heading3);
pdf1.Save(dataDir + "SystemBullets_out.pdf");
// For complete examples and data files, please go to https://github.com/aspose-pdf/Aspose.Pdf-for-.NET
// The path to the documents directory.
string dataDir = RunExamples.GetDataDir_AsposePdfGenerator_Headings();
// Instntiate the Pdf object by calling its empty constructor
Aspose.Pdf.Generator.Pdf pdf1 = new Aspose.Pdf.Generator.Pdf();
// Create the section in the Pdf object
Aspose.Pdf.Generator.Section sec1 = pdf1.Sections.Add();
/*
* Create 1st heading in the Pdf object's section with level=1. Then create a text
* segment and add it in the heading. Set its UserLabel="98" to use a user defined
* bullet. You must set BulletFontName to "Symbol" or "ZapfDingbats". After setting
* all properties, add heading into the paragraphs collection of the section
*/
Aspose.Pdf.Generator.Heading heading1 = new Aspose.Pdf.Generator.Heading(pdf1, sec1, 1);
Aspose.Pdf.Generator.Segment segment1 = new Aspose.Pdf.Generator.Segment(heading1);
heading1.Segments.Add(segment1);
segment1.Content = "Symbol";
heading1.BulletFontName = "Symbol";
heading1.UserLabel = "98";
sec1.Paragraphs.Add(heading1);
/*
* Create 2nd heading in the Pdf object's section with level=2. Then create a text
* segment and add it in the heading. Set its UserLabel="99" to use a user defined
* bullet. You must set BulletFontName to "Symbol" or "ZapfDingbats". After setting
* all properties, add heading into the paragraphs collection of the section
*/
Aspose.Pdf.Generator.Heading heading2 = new Aspose.Pdf.Generator.Heading(pdf1, sec1, 2);
Aspose.Pdf.Generator.Segment segment2 = new Aspose.Pdf.Generator.Segment(heading2);
heading2.Segments.Add(segment2);
segment2.Content = "Symbol";
heading2.BulletFontName = "Symbol";
heading2.UserLabel = "99";
sec1.Paragraphs.Add(heading2);
/*
* Create 3rd heading in the Pdf object's section with level=3. Then create a text
* segment and add it in the heading. Set its UserLabel="100" to use a user defined
* bullet. You must set BulletFontName to "Symbol" or "ZapfDingbats". After setting
* all properties, add heading into the paragraphs collection of the section
*/
Aspose.Pdf.Generator.Heading heading3 = new Aspose.Pdf.Generator.Heading(pdf1, sec1, 3);
Aspose.Pdf.Generator.Segment segment3 = new Aspose.Pdf.Generator.Segment(heading3);
heading3.Segments.Add(segment3);
segment3.Content = "Symbol";
heading3.BulletFontName = "Symbol";
heading3.UserLabel = "100";
sec1.Paragraphs.Add(heading3);
pdf1.Save(dataDir + "UserDefinedBullets_out.pdf");
// For complete examples and data files, please go to https://github.com/aspose-pdf/Aspose.Pdf-for-.NET
// The path to the documents directory.
string dataDir = RunExamples.GetDataDir_AsposePdfGenerator_Images();
string faxImageFile = "";
if (faxImageFile != "")
{
// Instantiate a Pdf object by calling its empty constructor
Aspose.Pdf.Generator.Pdf pdf1 = new Aspose.Pdf.Generator.Pdf();
// Create a section in the Pdf object
Aspose.Pdf.Generator.Section sec1 = pdf1.Sections.Add();
// Instantiate an image object
Aspose.Pdf.Generator.Image img1 = new Aspose.Pdf.Generator.Image(sec1);
// Add image object into the Paragraphs collection of the section
sec1.Paragraphs.Add(img1);
// Set the path of image file
img1.ImageInfo.File = faxImageFile;
// Set the file type of the image
img1.ImageInfo.ImageFileType = Aspose.Pdf.Generator.ImageFileType.Ccitt;
// Set the image width
img1.ImageInfo.CcittImageWidth = 2560;
// Set the image height
img1.ImageInfo.CcittImageHeight = 1779;
// Set the sub-format of the ccitt image
img1.ImageInfo.CcittSubFormat = Aspose.Pdf.Generator.CcittSubFormat.Group31D;
// Set the desired scaling of the image
img1.ImageScale = 0.1F;
pdf1.Save( dataDir + "CCITTImage_out.pdf");
// For complete examples and data files, please go to https://github.com/aspose-pdf/Aspose.Pdf-for-.NET
// The path to the documents directory.
string dataDir = RunExamples.GetDataDir_AsposePdfGenerator_Images();
// Instantiate a Pdf object by calling its empty constructor
Aspose.Pdf.Generator.Pdf pdf1 = new Aspose.Pdf.Generator.Pdf();
// Create a section in the Pdf object
Aspose.Pdf.Generator.Section sec1 = pdf1.Sections.Add();
// Create an image object in the section
Aspose.Pdf.Generator.Image image1 = new Aspose.Pdf.Generator.Image(sec1);
// Add image object into the Paragraphs collection of the section
sec1.Paragraphs.Add(image1);
// Set the path of image file
image1.ImageInfo.File = dataDir + "aspose-logo.jpg";
// Set the type of image using ImageFileType enumeration
image1.ImageInfo.ImageFileType = Aspose.Pdf.Generator.ImageFileType.Jpeg;
// Set image title
image1.ImageInfo.Title = "JPEG image";
// Save the Pdf
pdf1.Save(dataDir + "ImageFromLocalDisk_out.pdf");
// For complete examples and data files, please go to https://github.com/aspose-pdf/Aspose.Pdf-for-.NET
// The path to the documents directory.
string dataDir = RunExamples.GetDataDir_AsposePdfGenerator_General();
// Set the license for Aspose.Pdf
Aspose.Pdf.License license = new Aspose.Pdf.License();
license.SetLicense("Aspose.Custom.lic");
// Create a memory stream object
System.IO.MemoryStream mstream = new System.IO.MemoryStream();
// Instantiate a Pdf object
Aspose.Pdf.Generator.Pdf pdf1 = new Aspose.Pdf.Generator.Pdf();
// Create a new section in the Pdf document
Aspose.Pdf.Generator.Section sec1 = new Aspose.Pdf.Generator.Section(pdf1);
// Add the section in the sections collection of the Pdf document
pdf1.Sections.Add(sec1);
// Create an image object
Aspose.Pdf.Generator.Image image1 = new Aspose.Pdf.Generator.Image(sec1);
// Add the image into paragraphs collection of the section
sec1.Paragraphs.Add(image1);
image1.ImageInfo.ImageFileType = Aspose.Pdf.Generator.ImageFileType.Bmp;
// Set the ImageStream to a MemoryStream object
image1.ImageInfo.ImageStream = mstream ;
// Set desired the image scale
image1.ImageScale = 0.5F;
// Save the Pdf
pdf1.Save(dataDir + "ImageFromMemory_out.pdf");
// For complete examples and data files, please go to https://github.com/aspose-pdf/Aspose.Pdf-for-.NET
// The path to the documents directory.
string dataDir = RunExamples.GetDataDir_AsposePdfGenerator_Images();
// Instantiate a Pdf object by calling its empty constructor
Aspose.Pdf.Generator.Pdf pdf1 = new Aspose.Pdf.Generator.Pdf();
// Create a section in the Pdf object
Aspose.Pdf.Generator.Section sec1 = pdf1.Sections.Add();
// Create an image object in the section
Aspose.Pdf.Generator.Image image1 = new Aspose.Pdf.Generator.Image(sec1);
// Add image object into the Paragraphs collection of the section
sec1.Paragraphs.Add(image1);
// Set the path of image file
image1.ImageInfo.File = "http:// Www.aspose.com/Images/Apple.jpg";
// Set the type of image using ImageFileType enumeration
image1.ImageInfo.ImageFileType = Aspose.Pdf.Generator.ImageFileType.Jpeg;
// Set image title
image1.ImageInfo.Title = "JPEG image";
// Save the Pdf
pdf1.Save(dataDir + "ImageFromLocalDisk_out.pdf");
// For complete examples and data files, please go to https://github.com/aspose-pdf/Aspose.Pdf-for-.NET
// The path to the documents directory.
string dataDir = RunExamples.GetDataDir_AsposePdfGenerator_Paragraphs();
// Instantiate Pdf object by calling its empty constructor and add a new section to the Pdf object
Aspose.Pdf.Generator.Pdf pdf1 = new Aspose.Pdf.Generator.Pdf();
Aspose.Pdf.Generator.Section sec1 = pdf1.Sections.Add();
// Create a text paragraph with the reference of a section, sec1 and add the text paragraph in the section
Aspose.Pdf.Generator.Text text3 = new Aspose.Pdf.Generator.Text(sec1, "product 1 info ...");
sec1.Paragraphs.Add(text3);
// Set the text paragraph to be the first paragraph among the other ones
text3.IsFirstParagraph = true;
// Assign and ID to the text paragraph
text3.ID = "product1";
dataDir = dataDir + "AssignID_out.pdf";
// Save the resultant PDF
pdf1.Save(dataDir);
// For complete examples and data files, please go to https://github.com/aspose-pdf/Aspose.Pdf-for-.NET
// The path to the documents directory.
string dataDir = RunExamples.GetDataDir_AsposePdfGenerator_Paragraphs();
// Instantiate Pdf instance by calling its empty constructor
Aspose.Pdf.Generator.Pdf pdf1 = new Aspose.Pdf.Generator.Pdf();
// Create a section in the Pdf document and add a text paragraph in the section
Aspose.Pdf.Generator.Section sec1 = pdf1.Sections.Add();
sec1.Paragraphs.Add(new Aspose.Pdf.Generator.Text("page 1"));
// Create another text paragraph that has to be rendered
Aspose.Pdf.Generator.Text t2 = new Aspose.Pdf.Generator.Text("page2");
// Set the IsFirstParagraph property of the text paragraph to true to render it to a new page
t2.IsFirstParagraph = true;
// Add the text paragraph to be rendered to the section
sec1.Paragraphs.Add(t2);
dataDir = dataDir + "RenderParagraph_out.pdf";
// Save the Pdf document
pdf1.Save(dataDir);
// For complete examples and data files, please go to https://github.com/aspose-pdf/Aspose.Pdf-for-.NET
// The path to the documents directory.
string dataDir = RunExamples.GetDataDir_AsposePdfGenerator_Paragraphs();
// Instantiate Pdf object by calling its empty constructor and add a new section to the Pdf object
Aspose.Pdf.Generator.Pdf pdf1 = new Aspose.Pdf.Generator.Pdf();
Aspose.Pdf.Generator.Section sec1 = pdf1.Sections.Add();
// Instantiate a graph object, associate it with a section and pass the height & width of the graph
Aspose.Pdf.Generator.Graph g1 = new Aspose.Pdf.Generator.Graph(sec1, 100, 100);
// Add a graph object to the paragraphs collection of the section
sec1.Paragraphs.Add(g1);
// Add a circle object to the shapes collection of graph object
g1.Shapes.Add(new Aspose.Pdf.Generator.Circle(g1, 50, 50, 30));
// Instantiate another Graph object, associate it with a section and pass the height & width of the graph
Aspose.Pdf.Generator.Graph g2 = new Aspose.Pdf.Generator.Graph(sec1, 100, 100);
// Set left and top margin values
g2.Margin.Left = 150;
g2.Margin.Top = -100;
// Add the paragraph object "g2" to paragraphs collection of the section
sec1.Paragraphs.Add(g2);
// Add a rectangle to the graph object (g2) in its shapes collection
g2.Shapes.Add(new Aspose.Pdf.Generator.Rectangle(g2, 20, 20, 60, 60));
dataDir = dataDir + "SetMargins_out.pdf";
// Save the resultant PDF
pdf1.Save(dataDir);
// For complete examples and data files, please go to https://github.com/aspose-pdf/Aspose.Pdf-for-.NET
// The path to the documents directory.
string dataDir = RunExamples.GetDataDir_AsposePdfGenerator_Sections();
// Instantiate a PDF Object
Aspose.Pdf.Generator.Pdf pdf1 = new Aspose.Pdf.Generator.Pdf();
// Create a Section object by calling Add method of Sections collection of Pdf class
Aspose.Pdf.Generator.Section sec1 = pdf1.Sections.Add();
// Instantiate First HeaderFooter object and pass the Section reference in which
// The header or footer is to be added
Aspose.Pdf.Generator.HeaderFooter hf1 = new Aspose.Pdf.Generator.HeaderFooter(sec1);
// Set the header of odd pages of the PDF document
sec1.OddHeader = hf1;
// Set the header of even pages of the PDF document
sec1.EvenHeader = hf1;
// Enable this header for first page only
hf1.IsFirstPageOnly = true;
// Add Distance From Edge Property to 80 unit Points
hf1.DistanceFromEdge = 80;
// Set the First HeaderFooter, top and bottom property respectively
hf1.Margin.Bottom = 50;
hf1.Margin.Top = 100;
// Instantiate a Text paragraph that will store the content to show as header
Aspose.Pdf.Generator.Text text = new Aspose.Pdf.Generator.Text(hf1, "header for first page");
// Add the text object to the Paragraphs collection of HeaderFooter object to
// Display header on the pages of PDF document
hf1.Paragraphs.Add(text);
/*
*Second Header "hf2" for odd subsequent pages only
*/
// Instantiate Second HeaderFooter object and pass the Section reference in which
// The header or footer is to be added
Aspose.Pdf.Generator.HeaderFooter hf2 = new Aspose.Pdf.Generator.HeaderFooter(sec1);
// Set the additional header of odd pages of the PDF document
sec1.AdditionalOddHeader = hf2;
// Enable this header for subsequent page only
hf2.IsSubsequentPagesOnly = true;
// Add Distance From Edge Property of header to 150 unit Points
hf2.DistanceFromEdge = 150;
hf2.Margin.Bottom = 70;
// Instantiate a Text paragraph that will store the content to show as header
text = new Aspose.Pdf.Generator.Text(hf2, "odd header for subsequent pages");
// Add the text object to the Paragraphs collection of HeaderFooter object to
// Display header on the pages of PDF document
hf2.Paragraphs.Add(text);
/*
*Third Header "hf3" for even subsequent pages only
*/
// Instantiate Third HeaderFooter object and pass the Section reference in which
// The header or footer is to be added
Aspose.Pdf.Generator.HeaderFooter hf3 = new Aspose.Pdf.Generator.HeaderFooter(sec1);
// Set the additional header of even pages of the PDF document
sec1.AdditionalEvenHeader = hf3;
// Enable this header for subsequent page only
hf3.IsSubsequentPagesOnly = true;
// Add the Distance from Edge for the third Header
hf3.DistanceFromEdge = 180;
hf3.Margin.Top = 90;
// Instantiate a Text paragraph that will store the content to show as header
text = new Aspose.Pdf.Generator.Text(hf3, "even header for subsequent pages");
// Add the text object to the Paragraphs collection of HeaderFooter object to
// Display header on the pages of PDF document
hf3.Paragraphs.Add(text);
dataDir = dataDir + "AdvancedHeaderAndFooter_out.pdf";
// Save Pdf Document
pdf1.Save(dataDir);
// For complete examples and data files, please go to https://github.com/aspose-pdf/Aspose.Pdf-for-.NET
// Instantiate HeaderFooter object and pass the Section reference in which
// The header or footer is to be added
Aspose.Pdf.Generator.HeaderFooter hf1 = new Aspose.Pdf.Generator.HeaderFooter(section1);
// Set the header of odd pages of the PDF document
section1.OddHeader = hf1;
// Set the header of even pages of the PDF document
section1.EvenHeader = hf1;
// Instantiate a Text paragraph that will store the content to show as header
Aspose.Pdf.Generator.Text text = new Aspose.Pdf.Generator.Text(hf1, "header");
// Add the text object to the Paragraphs collection of HeaderFooter object to
// Display header on the pages of PDF document
hf1.Paragraphs.Add(text);
// For complete examples and data files, please go to https://github.com/aspose-pdf/Aspose.Pdf-for-.NET
// The path to the documents directory.
string dataDir = RunExamples.GetDataDir_AsposePdfGenerator_Sections();
// Instantiate a PDF Object
Aspose.Pdf.Generator.Pdf pdf = new Aspose.Pdf.Generator.Pdf();
// Add a section into the pdf document
Aspose.Pdf.Generator.Section section1 = pdf.Sections.Add();
// Assign the image file path to BackgroundImageFile property of section
section1.BackgroundImageFile = dataDir+ "aspose-logo.jpg";
// Set the image type using ImageFileType enumeration
section1.BackgroundImageType = Aspose.Pdf.Generator.ImageFileType.Jpeg;
dataDir = dataDir + "SetPageBackgroundImage_out.pdf";
// Save Pdf Document
pdf.Save(dataDir);
// For complete examples and data files, please go to https://github.com/aspose-pdf/Aspose.Pdf-for-.NET
// Instantiate the MarginInfo instance
Aspose.Pdf.Generator.MarginInfo marginInfo = new Aspose.Pdf.Generator.MarginInfo();
// Set the margin Top. This value is in points but other units like
// Inches and centi meters can also be used as 12inch or 12cm
marginInfo.Top = 72;
// Set the margin Bottom. This value is in points but other units like
// Inches and centi meters can also be used as 12inch or 12cm
marginInfo.Bottom = 72;
// Set the margin Left. This value is in points but other units like
// Inches and centi meters can also be used as 12inch or 12cm
marginInfo.Left = 90;
// Set the margin Right. This value is in points but other units like
// Inches and centi meters can also be used as 12inch or 12cm
marginInfo.Right = 90;
// Assign the marginInfo instance to Margin property of sec1.PageInfo
section1.PageInfo.Margin = marginInfo;
// For complete examples and data files, please go to https://github.com/aspose-pdf/Aspose.Pdf-for-.NET
section1.PageInfo.PageWidth = 576;
section1.PageInfo.PageHeight = 707.5F;
// For complete examples and data files, please go to https://github.com/aspose-pdf/Aspose.Pdf-for-.NET
section1.PageInfo.PageWidth = Aspose.Pdf.Generator.PageSize.A3Width;
section1.PageInfo.PageHeight = Aspose.Pdf.Generator.PageSize.A3Height;
// For complete examples and data files, please go to https://github.com/aspose-pdf/Aspose.Pdf-for-.NET
// The path to the documents directory.
string dataDir = RunExamples.GetDataDir_AsposePdfGenerator_SecurityFeatures();
// Instantiate Pdf instance by calling its empty constructor
Aspose.Pdf.Generator.Pdf pdf1 = new Aspose.Pdf.Generator.Pdf();
// Assign a security instance to Pdf object
pdf1.Security = new Aspose.Pdf.Generator.Security();
// Restrict annotation modification
pdf1.Security.IsAnnotationsModifyingAllowed = false;
// Restrict contents modification
pdf1.Security.IsContentsModifyingAllowed = false;
// Restrict copying the data
pdf1.Security.IsCopyingAllowed = false;
// Allow to print the document
pdf1.Security.IsPrintingAllowed = true;
// Restrict form filling
pdf1.Security.IsFormFillingAllowed = false;
// Add a section in the Pdf
Aspose.Pdf.Generator.Section sec1 = pdf1.Sections.Add();
// Create a text paragraph
Aspose.Pdf.Generator.Text text1 = new Aspose.Pdf.Generator.Text(sec1, "this is text content");
// Set the top maring of text paragraph to 30
text1.Margin.Top = 30;
// Add the text paragraph to the section
sec1.Paragraphs.Add(text1);
dataDir = dataDir + "AllowDisallowPrivileges_out.pdf";
// Save the Pdf
pdf1.Save(dataDir);
// For complete examples and data files, please go to https://github.com/aspose-pdf/Aspose.Pdf-for-.NET
// The path to the documents directory.
string dataDir = RunExamples.GetDataDir_AsposePdfGenerator_SecurityFeatures();
// Instantiate Pdf instance by calling its empty constructor
Aspose.Pdf.Generator.Pdf pdf1 = new Aspose.Pdf.Generator.Pdf();
// Assign a security instance to Pdf object
pdf1.Security = new Aspose.Pdf.Generator.Security();
// Set encryption level to 128 bits
pdf1.Security.Is128BitsEncrypted = true;
// Add a section in the Pdf
Aspose.Pdf.Generator.Section sec1 = pdf1.Sections.Add();
// Create a text paragraph
Aspose.Pdf.Generator.Text text1 = new Aspose.Pdf.Generator.Text(sec1,"this is text content");
// Set the top maring of text paragraph to 30
text1.Margin.Top = 30;
// Add the text paragraph to the section
sec1.Paragraphs.Add(text1);
dataDir = dataDir + "SetEncryption_out.pdf";
// Save the Pdf
pdf1.Save(dataDir);
// For complete examples and data files, please go to https://github.com/aspose-pdf/Aspose.Pdf-for-.NET
// The path to the documents directory.
string dataDir = RunExamples.GetDataDir_AsposePdfGenerator_SecurityFeatures();
// Instantiate Pdf instance by calling its empty constructor
Aspose.Pdf.Generator.Pdf pdf1 = new Aspose.Pdf.Generator.Pdf();
// Assign a security instance to Pdf object
pdf1.Security = new Aspose.Pdf.Generator.Security();
// Set the master password for the PDF document
pdf1.Security.MasterPassword="master";
// Set the user password for the PDF document
pdf1.Security.UserPassword="user";
// Add a section in the Pdf
Aspose.Pdf.Generator.Section sec1 = pdf1.Sections.Add();
// Create a text paragraph
Aspose.Pdf.Generator.Text text1 = new Aspose.Pdf.Generator.Text(sec1,"this is text content");
// Set the top maring of text paragraph to 30
text1.Margin.Top = 30;
// Add the text paragraph to the section
sec1.Paragraphs.Add(text1);
dataDir = dataDir +"SetPassword_out.pdf";
// Save the Pdf
pdf1.Save(dataDir);
// For complete examples and data files, please go to https://github.com/aspose-pdf/Aspose.Pdf-for-.NET
// The path to the documents directory.
string dataDir = RunExamples.GetDataDir_AsposePdfGenerator_Tables();
// Instntiate the Pdf object by calling its empty constructor
Aspose.Pdf.Generator.Pdf pdf1 = new Aspose.Pdf.Generator.Pdf();
// Create the section in the Pdf object
Aspose.Pdf.Generator.Section sec1 = pdf1.Sections.Add();
// Create Table instance
Aspose.Pdf.Generator.Table tab1 = new Aspose.Pdf.Generator.Table();
// Add the table object in the paragraphs collection of the section
sec1.Paragraphs.Add(tab1);
// Set the column widths of the table
tab1.ColumnWidths = "50 50 50";
// Set default text color for the text contents of each cell in the table to blue
tab1.DefaultCellTextInfo.Color = new Aspose.Pdf.Generator.Color("Blue");
// Set default left side padding of the cell
tab1.DefaultCellPadding.Left = 5;
// Set default border of the cell using BorderInfo object
tab1.DefaultCellBorder = new Aspose.Pdf.Generator.BorderInfo((int)Aspose.Pdf.Generator.BorderSide.All, 0.1F);
// After setting default cell format information for the table, you can add rows
// And columns in the table
Aspose.Pdf.Generator.Row row1 = tab1.Rows.Add();
row1.Cells.Add("col1");
row1.Cells.Add("col2");
row1.Cells.Add("col3");
// Save the Pdf
pdf1.Save(dataDir + "CellInformation_out.pdf");
// For complete examples and data files, please go to https://github.com/aspose-pdf/Aspose.Pdf-for-.NET
// The path to the documents directory.
string dataDir = RunExamples.GetDataDir_AsposePdfGenerator_Tables();
// Instantiate a Pdf object by calling its empty constructor
Aspose.Pdf.Generator.Pdf pdf1 = new Aspose.Pdf.Generator.Pdf();
// Call BindXML method to read information from RepeatExample.xml document. Second
// Parameter is for Xsl file. In our case, we don't need it so leave it as null.
pdf1.BindXML( dataDir + "RepeatExample.xml", null);
// Obtain the first section from the Pdf
Aspose.Pdf.Generator.Section sec1 = pdf1.Sections[0];
// Obtain a table named "table1" from the Pdf
Aspose.Pdf.Generator.Table table1 = sec1.Paragraphs["table1"] as Aspose.Pdf.Generator.Table;
// Declare a table instance
Aspose.Pdf.Generator.Table curTable;
// Create an array of string containing three values, "item1", "item2" and "item3"
string[] items = new string[] { "item1", "item2", "item3" };
// Run a for loop for 5 times
for (int i = 0; i < 5; i++)
{
// Copy the table structure of "table1" by calling its Clone method
curTable = table1.Clone() as Aspose.Pdf.Generator.Table;
// Set the top margin of the cloned table to 10
curTable.Margin.Top = 10;
// Copy a row (with structure and data) of "table1" by calling its
// CompleteClone method. And then add that row to the cloned table
curTable.Rows.Add(table1.Rows[0].CompleteClone() as Aspose.Pdf.Generator.Row);
// Import an array of string "items" into the table
curTable.ImportArray(items, 1, 0, false);
// Add the cloned table to the paragraphs collection of the section
sec1.Paragraphs.Add(curTable);
}
// Save the Pdf
pdf1.Save(dataDir + "CompleteClone_out.pdf");
// For complete examples and data files, please go to https://github.com/aspose-pdf/Aspose.Pdf-for-.NET
// The path to the documents directory.
string dataDir = RunExamples.GetDataDir_AsposePdfGenerator_Tables();
DataTable dt = new DataTable("Employee");
dt.Columns.Add("Employee_ID",typeof(Int32));
dt.Columns.Add("Employee_Name",typeof(string));
dt.Columns.Add("Gender",typeof(string));
// Add 2 rows into the DataTable object programmatically
DataRow dr = dt.NewRow();
dr[0] = 1;
dr[1] = "John Smith";
dr[2] = "Male";
dt.Rows.Add(dr);
dr = dt.NewRow();
dr[0] = 2;
dr[1] = "Mary Miller";
dr[2] = "Female";
dt.Rows.Add(dr);
// Instantiate a Pdf instance
Aspose.Pdf.Generator.Pdf pdf1 = new Aspose.Pdf.Generator.Pdf();
// Create a section in the Pdf instance
Aspose.Pdf.Generator.Section sec1 = pdf1.Sections.Add();
// Create a Table object
Aspose.Pdf.Generator.Table tab1 = new Aspose.Pdf.Generator.Table();
// Add the Table object in the paragraphs collection of the section
sec1.Paragraphs.Add(tab1);
// Set column widths of the table
tab1.ColumnWidths = "40 100 100 100";
// Set default cell border of the table using BorderInfo object
tab1.DefaultCellBorder = new Aspose.Pdf.Generator.BorderInfo((int) Aspose.Pdf.Generator.BorderSide.All,0.1F);
// Import data into the Table object from the DataTable created above
tab1.ImportDataTable(dt,true,0,1,3,3);
// Get 1st row from the table
Aspose.Pdf.Generator.Row row1 = tab1.Rows[0];
// Iterate through all cells in the row and set their background color to blue
foreach(Aspose.Pdf.Generator.Cell curCell in row1.Cells)
curCell.BackgroundColor = new Aspose.Pdf.Generator.Color("Blue");
// Save the Pdf
pdf1.Save(dataDir + "IntegrateWithDatabase_out.pdf");
// For complete examples and data files, please go to https://github.com/aspose-pdf/Aspose.Pdf-for-.NET
// The path to the documents directory.
string dataDir = RunExamples.GetDataDir_AsposePdfGenerator_Tables();
// Instantiate Pdf document object
Aspose.Pdf.Generator.Pdf pdf1 = new Aspose.Pdf.Generator.Pdf();
// Create a section in the Pdf
Aspose.Pdf.Generator.Section sec1 = pdf1.Sections.Add();
// Create a table
Aspose.Pdf.Generator.Table tab1 = new Aspose.Pdf.Generator.Table();
// Add the table into the paragraphs collection of section
sec1.Paragraphs.Add(tab1);
// Set the column widths of the table
tab1.ColumnWidths = "100 200";
// Set the default cell border using BorderInfo instance
tab1.DefaultCellBorder = new Aspose.Pdf.Generator.BorderInfo((int) Aspose.Pdf.Generator.BorderSide.All);
// Add a row into the table
Aspose.Pdf.Generator.Row row1 = tab1.Rows.Add();
// Add 1st cell in the row
row1.Cells.Add("left cell");
// Add 2nd cell in the row
Aspose.Pdf.Generator.Cell cell2 = row1.Cells.Add();
// Create a table to be nested with the reference of 2nd cell in the row
Aspose.Pdf.Generator.Table tab2 = new Aspose.Pdf.Generator.Table(cell2);
// Add the nested table into the paragraphs collection of the 2nd cell
cell2.Paragraphs.Add(tab2);
// Set the column widths of the nested table
tab2.ColumnWidths = "100 100";
// Create 1st row in the nested table
Aspose.Pdf.Generator.Row row21 = tab2.Rows.Add();
// Create 1st cell in the 1st row of the nested table
Aspose.Pdf.Generator.Cell cell21 = row21.Cells.Add("top cell");
// Set the column span of the 1st cell (in the 1st row of the nested table) to 2
cell21.ColumnsSpan = 2;
// Create 2nd row in the nested table
Aspose.Pdf.Generator.Row row22 = tab2.Rows.Add();
// Create 1st cell in the 2nd row of the nested table
row22.Cells.Add("left bottom cell");
// Create 2nd cell in the 2nd row of the nested table
row22.Cells.Add("right bottom cell");
// Save the Pdf
pdf1.Save(dataDir + "NestedTables_out.pdf");
// For complete examples and data files, please go to https://github.com/aspose-pdf/Aspose.Pdf-for-.NET
// The path to the documents directory.
string dataDir = RunExamples.GetDataDir_AsposePdfGenerator_Tables();
// Instantiate the Pdf object by calling its empty constructor
Aspose.Pdf.Generator.Pdf pdf1 = new Aspose.Pdf.Generator.Pdf();
// Create the section in the Pdf object
Aspose.Pdf.Generator.Section sec1 = pdf1.Sections.Add();
// Instantiate a table object
Aspose.Pdf.Generator.Table tab1 = new Aspose.Pdf.Generator.Table();
// Add the table in paragraphs collection of the desired section
sec1.Paragraphs.Add(tab1);
// Set with column widths of the table
tab1.ColumnWidths = "110 120 50";
// Set default cell border using BorderInfo object
tab1.DefaultCellBorder = new Aspose.Pdf.Generator.BorderInfo((int)Aspose.Pdf.Generator.BorderSide.All, 0.1F);
// Set table border using another customized BorderInfo object
tab1.Border = new Aspose.Pdf.Generator.BorderInfo((int)Aspose.Pdf.Generator.BorderSide.All, 1F);
// Create MarginInfo object and set its left, bottom, right and top margins
Aspose.Pdf.Generator.MarginInfo margin = new Aspose.Pdf.Generator.MarginInfo();
margin.Top = 5f;
margin.Left = 5f;
margin.Right = 5f;
margin.Bottom = 5f;
// Set the default cell padding to the MarginInfo object
tab1.DefaultCellPadding = margin;
// Create rows in the table and then cells in the rows
Aspose.Pdf.Generator.Row row1 = tab1.Rows.Add();
row1.DefaultCellTextInfo.FontName = "Arial Unicode MS";
row1.Cells.Add("Arabic Sample مَرْحَبا بكِ كُلَّ الْتَرْحيبْ");
row1.Cells[0].DefaultCellTextInfo.IsRightToLeft = true;
// Row1.Cells[0].DefaultCellTextInfo.FontName = "Arial Unicode MS";
row1.Cells.Add("Persian alphabet الفبای فارسی");
row1.Cells[1].DefaultCellTextInfo.IsRightToLeft = true;
// Row1.Cells[1].DefaultCellTextInfo.FontName = "Arial Unicode MS";
row1.Cells.Add("English Text");
// Include the subset of Font supporting Non-English text in PDF file
pdf1.SetUnicode();
// Save the Pdf
pdf1.Save(dataDir + "Arabic_Farsi_Text_in_TableCell_out.pdf");
// For complete examples and data files, please go to https://github.com/aspose-pdf/Aspose.Pdf-for-.NET
Aspose.Pdf.Generator.BorderInfo binfo = new Aspose.Pdf.Generator.BorderInfo((int)BorderSide.All, 1f, new Aspose.Pdf.Generator.Color("Red"));
// For complete examples and data files, please go to https://github.com/aspose-pdf/Aspose.Pdf-for-.NET
// The path to the documents directory.
string dataDir = RunExamples.GetDataDir_AsposePdfGenerator_Tables();
// Instantiate Pdf object
Aspose.Pdf.Generator.Pdf pdf1 = new Aspose.Pdf.Generator.Pdf();
// Create the section in the Pdf object
Aspose.Pdf.Generator.Section sec1 = pdf1.Sections.Add();
// Instantiate a table object
Aspose.Pdf.Generator.Table tab1 = new Aspose.Pdf.Generator.Table();
// Add the table in paragraphs collection of the desired section
sec1.Paragraphs.Add(tab1);
// Set with column widths of the table
tab1.ColumnWidths = "100";
// Set fixed table row height
tab1.FixedHeight = 30;
// Create a blank BorderInfo object
Aspose.Pdf.Generator.BorderInfo bInfo = new Aspose.Pdf.Generator.BorderInfo();
// Create a GraphInfo object without any argument to its constructor
Aspose.Pdf.Generator.GraphInfo gInfo = new Aspose.Pdf.Generator.GraphInfo();
// Set the corner radius for GraphInfo
gInfo.CornerRadius = 15F;
// Specify the line color information
gInfo.Color = new Aspose.Pdf.Generator.Color("Red");
// Set the rounded corner table border
bInfo.Round = gInfo;
// Specify the Corner style for table border as Round
tab1.CornerStyle = Aspose.Pdf.Generator.BorderCornerStyle.Round;
// Set the table border information
tab1.Border = bInfo;
// Create rows in the table and then cells in the rows
Aspose.Pdf.Generator.Row row1 = tab1.Rows.Add();
// Add sample string to paragraphs collection of table cell
row1.Cells.Add("Hello World...");
// Set the vertical alignment of text as center aligned
row1.Cells[0].DefaultCellTextInfo.Alignment = Aspose.Pdf.Generator.AlignmentType.Center;
// Set the horizontal alignment of text as center aligned
row1.Cells[0].VerticalAlignment = Aspose.Pdf.Generator.VerticalAlignmentType.Center;
// Save the Pdf
pdf1.Save(dataDir + "Rounded_Corner-Table_out.pdf");
// For complete examples and data files, please go to https://github.com/aspose-pdf/Aspose.Pdf-for-.NET
// The path to the documents directory.
string dataDir = RunExamples.GetDataDir_AsposePdfGenerator_Tables();
// Instantiate Pdf document object
Aspose.Pdf.Generator.Pdf pdf1 = new Aspose.Pdf.Generator.Pdf();
// Create a section in the Pdf
Aspose.Pdf.Generator.Section sec1 = pdf1.Sections.Add();
// Create a table
Aspose.Pdf.Generator.Table tab1 = new Aspose.Pdf.Generator.Table();
// Add table in the paragraphs collection of the section
sec1.Paragraphs.Add(tab1);
// Set the column widths of the table
tab1.ColumnWidths = "60 100 100";
// Create a TextInfo instance
Aspose.Pdf.Generator.TextInfo tinfo = new Aspose.Pdf.Generator.TextInfo();
// Set the font name to "Courier" for the TextInfo object
tinfo.FontName = "Courier";
// Set default table border using the BorderInfo object
tab1.DefaultCellBorder = new Aspose.Pdf.Generator.BorderInfo((int)Aspose.Pdf.Generator.BorderSide.All, 0.1F);
// Apply the text format settings in TextInfo object to table cells
tab1.DefaultCellTextInfo = tinfo;
// Create an array of double values
double[] darr = new Double[] { 1.5, 3.1415926, 100000, 20, 4000, 30.4512, 45.67, 890, 23.45 };
// Import the values in array to table
tab1.ImportArray(darr, 0, 0, false);
// Set background color for the first row
Aspose.Pdf.Generator.TextInfo tinfo1 = tinfo.Clone() as Aspose.Pdf.Generator.TextInfo;
tinfo1.BackgroundColor = new Aspose.Pdf.Generator.Color("#0000ff");
tab1.Rows[0].DefaultCellTextInfo = tinfo1;
// Align text in the last column to right hand side
Aspose.Pdf.Generator.TextInfo tinfo2 = tinfo.Clone() as Aspose.Pdf.Generator.TextInfo;
tinfo2.Alignment = Aspose.Pdf.Generator.AlignmentType.Right;
tab1.SetColumnTextInfo(2, tinfo2);
// We have to reset text format settings of the upper right cell
tinfo1.Alignment = Aspose.Pdf.Generator.AlignmentType.Right;
tab1.Rows[0].Cells[2].DefaultCellTextInfo = tinfo1;
// Save the Pdf
pdf1.Save(dataDir + "RowAndColumnFormat_out.pdf");
// For complete examples and data files, please go to https://github.com/aspose-pdf/Aspose.Pdf-for-.NET
// The path to the documents directory.
string dataDir = RunExamples.GetDataDir_AsposePdfGenerator_Tables();
// Instntiate the Pdf object by calling its empty constructor
Aspose.Pdf.Generator.Pdf pdf1 = new Aspose.Pdf.Generator.Pdf();
// Create the section in the Pdf object
Aspose.Pdf.Generator.Section sec1 = pdf1.Sections.Add();
// Instantiate a table object
Aspose.Pdf.Generator.Table tab1 = new Aspose.Pdf.Generator.Table();
// Add the table in paragraphs collection of the desired section
sec1.Paragraphs.Add(tab1);
// Set with column widths of the table
tab1.ColumnWidths = "50 50 50";
// Set default cell border using BorderInfo object
tab1.DefaultCellBorder = new Aspose.Pdf.Generator.BorderInfo((int)Aspose.Pdf.Generator.BorderSide.All, 0.1F);
// Set table border using another customized BorderInfo object
tab1.Border = new Aspose.Pdf.Generator.BorderInfo((int)Aspose.Pdf.Generator.BorderSide.All, 1F);
// Create MarginInfo object and set its left, bottom, right and top margins
Aspose.Pdf.Generator.MarginInfo margin = new Aspose.Pdf.Generator.MarginInfo();
margin.Top = 5f;
margin.Left = 5f;
margin.Right = 5f;
margin.Bottom = 5f;
// Set the default cell padding to the MarginInfo object
tab1.DefaultCellPadding = margin;
// Create rows in the table and then cells in the rows
Aspose.Pdf.Generator.Row row1 = tab1.Rows.Add();
row1.Cells.Add("col1");
row1.Cells.Add("col2");
row1.Cells.Add("col3");
Aspose.Pdf.Generator.Row row2 = tab1.Rows.Add();
row2.Cells.Add("item1");
row2.Cells.Add("item2");
row2.Cells.Add("item3");
// Save the Pdf
pdf1.Save(dataDir + "SetBorderAndPadding_out.pdf");
// For complete examples and data files, please go to https://github.com/aspose-pdf/Aspose.Pdf-for-.NET
row1.Cells[1].FitWidth = 2;
// For complete examples and data files, please go to https://github.com/aspose-pdf/Aspose.Pdf-for-.NET
row1.Cells[1].ColumnsSpan = 2;
// For complete examples and data files, please go to https://github.com/aspose-pdf/Aspose.Pdf-for-.NET
// Set with column widths of the table
tab1.ColumnWidths = "70 2cm";
// For complete examples and data files, please go to https://github.com/aspose-pdf/Aspose.Pdf-for-.NET
tab1.IsBroken = false;
// For complete examples and data files, please go to https://github.com/aspose-pdf/Aspose.Pdf-for-.NET
tab1.IsFirstRowRepeated = true;
// For complete examples and data files, please go to https://github.com/aspose-pdf/Aspose.Pdf-for-.NET
// The path to the documents directory.
string dataDir = RunExamples.GetDataDir_AsposePdfGenerator_TechnicalArticles();
// Instantiate a Pdf object
Aspose.Pdf.Generator.Pdf pdfConv = new Aspose.Pdf.Generator.Pdf();
// Create a section in the pdf document
Aspose.Pdf.Generator.Section sec1 = pdfConv.Sections.Add();
// Instantiate a table object
Aspose.Pdf.Generator.Table tab1 = new Aspose.Pdf.Generator.Table();
// Add the table in paragraphs collection of the desired section
sec1.Paragraphs.Add(tab1);
// Set default cell border using BorderInfo object
tab1.DefaultCellBorder = new Aspose.Pdf.Generator.BorderInfo((int)Aspose.Pdf.Generator.BorderSide.All, 0.1F);
// Set with column widths of the table
tab1.ColumnWidths = "100 100 120";
Aspose.Pdf.Generator.Image img = new Aspose.Pdf.Generator.Image();
img.ImageInfo.File = dataDir + "aspose-logo.jpg";
img.ImageInfo.ImageFileType = Aspose.Pdf.Generator.ImageFileType.Jpeg;
// Create rows in the table and then cells in the rows
Aspose.Pdf.Generator.Row row1 = tab1.Rows.Add();
row1.Cells.Add("Sample text in cell");
// Add the cell which holds the image
Aspose.Pdf.Generator.Cell cell2 = row1.Cells.Add();
// Add the image to the table cell
cell2.Paragraphs.Add(img);
row1.Cells.Add("Previous cell with image");
row1.Cells[2].VerticalAlignment = Aspose.Pdf.Generator.VerticalAlignmentType.Center;
// Save the Pdf file
pdfConv.Save(dataDir + "AddImageInTableCell_out.pdf");
// For complete examples and data files, please go to https://github.com/aspose-pdf/Aspose.Pdf-for-.NET
// The path to the documents directory.
string dataDir = RunExamples.GetDataDir_AsposePdfGenerator_TechnicalArticles();
XmlDocument xmlDoc = new XmlDocument();
xmlDoc.LoadXml(dataDir + "Sample.xml");
Aspose.Pdf.Generator.Pdf pdf = new Aspose.Pdf.Generator.Pdf();
// Object xmlDoc contains all contents from original word document in XML format defined in Aspose.PDF XML Schema.
pdf.BindXML(xmlDoc, null);
// Before saving, to add bookmarks from headings.
pdf.IsBookmarked = true;
foreach (Aspose.Pdf.Generator.Section sec in pdf.Sections)
{
foreach (Aspose.Pdf.Generator.Paragraph para in sec.Paragraphs)
{
if (para is Aspose.Pdf.Generator.Heading)
{
Aspose.Pdf.Generator.Heading h = para as Aspose.Pdf.Generator.Heading;
h.IsInList = true;
}
}
}
pdf.Save(dataDir + "BindXML_out.pdf");
// For complete examples and data files, please go to https://github.com/aspose-pdf/Aspose.Pdf-for-.NET
// The path to the documents directory.
string dataDir = RunExamples.GetDataDir_AsposePdfGenerator_TechnicalArticles();
// Instantiate Pdf instance by calling its empty constructor
Aspose.Pdf.Generator.Pdf pdf1 = new Aspose.Pdf.Generator.Pdf();
// Add a section into the pdf document
Aspose.Pdf.Generator.Section sec = pdf1.Sections.Add();
// Create a FileStream object to read the imag file
FileStream fs = File.OpenRead(dataDir + "aspose-logo.jpg");
// Read the image into Byte array
byte[] data = new byte[fs.Length];
fs.Read(data, 0, data.Length);
// Create a MemoryStream object from image Byte array
MemoryStream ms = new MemoryStream(data);
// Create an image object in the section
Aspose.Pdf.Generator.Image imageht = new Aspose.Pdf.Generator.Image(sec);
// Set the type of image using ImageFileType enumeration
imageht.ImageInfo.ImageFileType = Aspose.Pdf.Generator.ImageFileType.Jpeg;
// Specify the image source as MemoryStream
imageht.ImageInfo.ImageStream = ms;
// Add image object into the Paragraphs collection of the section
sec.Paragraphs.Add(imageht);
// Save the Pdf
pdf1.Save(dataDir + "ConvertMemoryStreamImageToPdf_out.pdf");
// Close the MemoryStream Object
ms.Close();
// For complete examples and data files, please go to https://github.com/aspose-pdf/Aspose.Pdf-for-.NET
// The path to the documents directory.
string dataDir = RunExamples.GetDataDir_AsposePdfGenerator_TechnicalArticles();
// Instantiate Pdf pbject by calling its empty constructor
Aspose.Pdf.Generator.Pdf pdf1 = new Aspose.Pdf.Generator.Pdf();
// Create a new section in the Pdf object
Aspose.Pdf.Generator.Section sec1 = pdf1.Sections.Add();
// Specify the location of input text file
String FILE_NAME = dataDir + "test.txt";
if (File.Exists(FILE_NAME))
{
System.IO.TextReader objReader = new System.IO.StreamReader(FILE_NAME);
// Read the file till the end of the file has come
do
{
// Create a new text paragraph & pass text to its constructor as argument
Aspose.Pdf.Generator.Text t2 = new Aspose.Pdf.Generator.Text(objReader.ReadLine());
// Add the text object to paragraphs collection of section
sec1.Paragraphs.Add(t2);
// Read till the end of file
} while (objReader.Peek() != -1);
// Close the StreamReader object
objReader.Close();
}
else
Console.WriteLine("File Does Not Exist");
// Save the PDF file
pdf1.Save(dataDir + "ConvertLargeTextFile_out.pdf");
// For complete examples and data files, please go to https://github.com/aspose-pdf/Aspose.Pdf-for-.NET
// The path to the documents directory.
string dataDir = RunExamples.GetDataDir_AsposePdfGenerator_TechnicalArticles();
// Read the source text file
System.IO.TextReader tr = new StreamReader(dataDir + "test.txt");
// Instantiate Pdf pbject by calling its empty constructor
Aspose.Pdf.Generator.Pdf pdf1 = new Aspose.Pdf.Generator.Pdf();
// Create a new section in the Pdf object
Aspose.Pdf.Generator.Section sec1 = pdf1.Sections.Add();
// Create a new text paragraph and pass the text to its constructor as argument
Aspose.Pdf.Generator.Text t2 = new Aspose.Pdf.Generator.Text(tr.ReadToEnd());
sec1.Paragraphs.Add(t2);
pdf1.Save(dataDir + "ConvertTextFile_out.Pdf");
// For complete examples and data files, please go to https://github.com/aspose-pdf/Aspose.Pdf-for-.NET
// The path to the documents directory.
string dataDir = RunExamples.GetDataDir_AsposePdfGenerator_TechnicalArticles();
// Create a PDF object
Aspose.Pdf.Generator.Pdf pdf = new Aspose.Pdf.Generator.Pdf();
Aspose.Pdf.Generator.Section sec1 = pdf.Sections.Add();
// Create a text object
Aspose.Pdf.Generator.Text t1 = new Aspose.Pdf.Generator.Text(sec1);
// Add the text object to Paragraphs collection of section
sec1.Paragraphs.Add(t1);
Aspose.Pdf.Generator.Segment seg1 = new Aspose.Pdf.Generator.Segment(t1);
// Add the contents for Segment1
seg1.Content = "paragraph 3 segment 1";
// Specify the Font fore color for segement1
seg1.TextInfo.Color = new Aspose.Pdf.Generator.Color("red");
// Specify the font size information for segment1
seg1.TextInfo.FontSize = 12;
// Specify the value for Opacity of text. Default is 1.0. Use it for multilayer effect
t1.Opacity = 0F;
// Add the segment to segments collection of Text1
t1.Segments.Add(seg1);
// Jpg image cover the underlayer text
Aspose.Pdf.Generator.Image image1 = new Aspose.Pdf.Generator.Image(sec1);
image1.ImageInfo.File = dataDir + "aspose-logo.jpg";
image1.ImageInfo.ImageFileType = Aspose.Pdf.Generator.ImageFileType.Jpeg;
// Create a Floating Box object that will hold image file
Aspose.Pdf.Generator.FloatingBox box1 = new Aspose.Pdf.Generator.FloatingBox(117, 21);
// Add Floating box to paragraphs collection of Section1
sec1.Paragraphs.Add(box1);
// Specify the left margin of FloatingBox1
box1.Left = -4;
// Specify the Top margin of FloatingBox1
box1.Top = -4;
// Add the image file to paragraphs collection of FloatingBox
box1.Paragraphs.Add(image1);
// Save the reusltant PDF document
pdf.Save(dataDir + "CreateMultiLayerPdf_out.pdf");
// For complete examples and data files, please go to https://github.com/aspose-pdf/Aspose.Pdf-for-.NET
// The path to the documents directory.
string dataDir = RunExamples.GetDataDir_AsposePdfGenerator_TechnicalArticles();
// Create a PDF object
Aspose.Pdf.Generator.Pdf pdf = new Aspose.Pdf.Generator.Pdf();
Aspose.Pdf.Generator.Section sec1 = pdf.Sections.Add();
// Create a text object
Aspose.Pdf.Generator.Text t1 = new Aspose.Pdf.Generator.Text(sec1);
// Create a Floating Box object that will hold image file
Aspose.Pdf.Generator.FloatingBox TextFloatingBox1 = new Aspose.Pdf.Generator.FloatingBox(117, 21);
// Specify the ZIndex value for TextFloatingBox
TextFloatingBox1.ZIndex = 1;
TextFloatingBox1.Left = -4;
TextFloatingBox1.Top = -4;
// Add Floating box to paragraphs collection of Section1
sec1.Paragraphs.Add(TextFloatingBox1);
// Add the text object to Paragraphs collection of FloatingBox
TextFloatingBox1.Paragraphs.Add(t1);
Aspose.Pdf.Generator.Segment seg1 = new Aspose.Pdf.Generator.Segment(t1);
// Add the contents for Segment1
seg1.Content = "paragraph 3 segment 1";
// Specify the Font fore color for segement1
seg1.TextInfo.Color = new Aspose.Pdf.Generator.Color("red");
// Specify the font size information for segment1
seg1.TextInfo.FontSize = 12;
// Specify the value for Opacity of text. Default is 1.0. Use it for multilayer effect
t1.Opacity = 0F;
// Add the segment to segments collection of Text1
t1.Segments.Add(seg1);
// JPeg image cover the underlayer text
Aspose.Pdf.Generator.Image image1 = new Aspose.Pdf.Generator.Image(sec1);
image1.ImageInfo.File = dataDir + "aspose-logo.jpg";
image1.ImageInfo.ImageFileType = Aspose.Pdf.Generator.ImageFileType.Jpeg;
// Create a Floating Box object that will hold image file
Aspose.Pdf.Generator.FloatingBox ImageFloatingBox = new Aspose.Pdf.Generator.FloatingBox(117, 21);
// Add Floating box to paragraphs collection of Section1
sec1.Paragraphs.Add(ImageFloatingBox);
// Specify the left margin of FloatingBox1
ImageFloatingBox.Left = -4;
// Specify the Top margin of FloatingBox1
ImageFloatingBox.Top = -4;
// Specify the ZIndex of ImageFloatingBox
ImageFloatingBox.ZIndex = 2;
// Add the image file to paragraphs collection of FloatingBox
ImageFloatingBox.Paragraphs.Add(image1);
// Save the reusltant PDF document
pdf.Save(dataDir + @"Multilayer-2ndApproach_out.pdf");
// For complete examples and data files, please go to https://github.com/aspose-pdf/Aspose.Pdf-for-.NET
// The path to the documents directory.
string dataDir = RunExamples.GetDataDir_AsposePdfGenerator_TechnicalArticles();
// Create pdf document
Aspose.Pdf.Generator.Pdf pdf1 = new Aspose.Pdf.Generator.Pdf();
// Instantiate License class and call its SetLicense method to use the license
Aspose.Pdf.License license = new Aspose.Pdf.License();
license.SetLicense("Aspose.Custom.lic");
// Set the conformance property of Pdf class to predefined value
pdf1.Conformance = Aspose.Pdf.Generator.PdfConformance.PdfA1B;
// Add a section into the pdf document
Aspose.Pdf.Generator.Section sec1 = pdf1.Sections.Add();
// Save the document
pdf1.Save(dataDir + "CreatePdfA1_out.pdf");
// For complete examples and data files, please go to https://github.com/aspose-pdf/Aspose.Pdf-for-.NET
// Create an object of TableFormatInfo class.
Aspose.Pdf.Generator.TableFormatInfo tfi = new Aspose.Pdf.Generator.TableFormatInfo();
// Sets a string value that indicate currency symbol of money, the default is "$".
tfi.CurrencySymbol = "$";
// Instantiate a table object
Aspose.Pdf.Generator.Table tab1 = new Aspose.Pdf.Generator.Table();
// Format the table in specified columns and rows with given TableFormatInfo
tab1.FormatTableWithFormatInfo(tfi, 1, 1, 1, 1);
// For complete examples and data files, please go to https://github.com/aspose-pdf/Aspose.Pdf-for-.NET
// The path to the documents directory.
string dataDir = RunExamples.GetDataDir_AsposePdfGenerator_TechnicalArticles();
// Instantiate an object PDF class
Aspose.Pdf.Generator.Pdf pdf = new Aspose.Pdf.Generator.Pdf();
// Add the section to PDF document sections collection
Aspose.Pdf.Generator.Section section = pdf.Sections.Add();
// Instantiate a table object
Aspose.Pdf.Generator.Table table1 = new Aspose.Pdf.Generator.Table();
table1.Margin.Top = 300;
// Add the table in paragraphs collection of the desired section
section.Paragraphs.Add(table1);
// Set with column widths of the table
table1.ColumnWidths = "100 100 100";
// Set default cell border using BorderInfo object
table1.DefaultCellBorder = new Aspose.Pdf.Generator.BorderInfo((int)Aspose.Pdf.Generator.BorderSide.All, 0.1F);
// Set table border using another customized BorderInfo object
table1.Border = new Aspose.Pdf.Generator.BorderInfo((int)Aspose.Pdf.Generator.BorderSide.All, 1F);
// Create MarginInfo object and set its left, bottom, right and top margins
Aspose.Pdf.Generator.MarginInfo margin = new Aspose.Pdf.Generator.MarginInfo();
margin.Top = 5f;
margin.Left = 5f;
margin.Right = 5f;
margin.Bottom = 5f;
// Set the default cell padding to the MarginInfo object
table1.DefaultCellPadding = margin;
// If you increase the counter to 17, table will break
// Because it cannot be accommodated any more over this page
for (int RowCounter = 0; RowCounter <= 16; RowCounter++)
{
// Create rows in the table and then cells in the rows
Aspose.Pdf.Generator.Row row1 = table1.Rows.Add();
row1.Cells.Add("col " + RowCounter.ToString() + ", 1");
row1.Cells.Add("col " + RowCounter.ToString() + ", 2");
row1.Cells.Add("col " + RowCounter.ToString() + ", 3");
}
// Get the Page Height information
float PageHeight = pdf.PageSetup.PageHeight;
// Get the total height information of Page Top & Bottom margin, table Top margin and table height.
float TotalObjectsHeight = section.PageInfo.Margin.Top + section.PageInfo.Margin.Bottom + table1.Margin.Top + table1.GetHeight(pdf);
// Display Page Height, Table Height, table Top margin and Page Top and Bottom margin information
Console.WriteLine("PDF document Height = " + pdf.PageSetup.PageHeight.ToString() + "\nTop Margin Info = " + section.PageInfo.Margin.Top.ToString() + "\nBottom Margin Info = " + section.PageInfo.Margin.Bottom.ToString() + "\n\nTable-Top Margin Info = " + table1.Margin.Top.ToString() + "\nAverage Row Height = " + table1.Rows[0].GetHeight(pdf).ToString() + " \nTable height " + table1.GetHeight(pdf).ToString() + "\n ----------------------------------------" + "\nTotal Page Height =" + PageHeight.ToString() + "\nCummulative height including Table =" + TotalObjectsHeight.ToString());
// Check if we deduct the sume of Page top margin + Page Bottom margin + Table Top margin and table height from Page height and its less
// Than 10 (an average row can be greater than 10)
if ((PageHeight - TotalObjectsHeight) <= 10)
// If the value is less than 10, then display the message.
// Which shows that another row can not be placed and if we add new
// Row, table will break. It depends upon the row height value.
Console.WriteLine("Page Height - Objects Height < 10, so table will break");
// Save the pdf document
pdf.Save(dataDir + "FigureOutTableBreak_out.pdf");
// For complete examples and data files, please go to https://github.com/aspose-pdf/Aspose.Pdf-for-.NET
// The path to the documents directory.
string dataDir = RunExamples.GetDataDir_AsposePdfGenerator_TechnicalArticles();
// Instantiate Pdf instance by calling it empty constructor
Aspose.Pdf.Generator.Pdf pdf1 = new Aspose.Pdf.Generator.Pdf();
// Create a section in the Pdf object
Aspose.Pdf.Generator.Section sec1 = pdf1.Sections.Add();
// Create a text paragraph inheriting text format settings from the section
Aspose.Pdf.Generator.Text text1 = new Aspose.Pdf.Generator.Text(sec1);
// Add the text paragraph to the section
sec1.Paragraphs.Add(text1);
// Create a text segment
Aspose.Pdf.Generator.Segment s1 = new Aspose.Pdf.Generator.Segment(" This is a sample text using Custom font");
// Set the font name to the TextInfo.FontName property of segment, where �Almonto Snow� is custom font name
s1.TextInfo.FontName = "Almonte Snow";
// Set the value for property to include the font description into Pdf file
s1.TextInfo.IsFontEmbedded = true;
// Set the value for property to include a subset of font into Pdf file
s1.TextInfo.IsUnicode = true;
// Add the text segment to the text paragraph
text1.Segments.Add(s1);
// Save the Pdf
pdf1.Save(dataDir + @"FontsEmbedding_out.pdf");
// For complete examples and data files, please go to https://github.com/aspose-pdf/Aspose.Pdf-for-.NET
// The path to the documents directory.
string dataDir = RunExamples.GetDataDir_AsposePdfGenerator_TechnicalArticles();
// Instantiate a pdf document
Aspose.Pdf.Generator.Pdf pdf1 = new Aspose.Pdf.Generator.Pdf();
// Create a section in the pdf document
Aspose.Pdf.Generator.Section sec1 = pdf1.Sections.Add();
// Create string variables with text containing html tags
string s = "<html><body><font isUnicode='true' face='Bete Noir NF' size=18><i>Sample text </i>with Custome font Embedded </font><br><font isUnicode='true' face='Courier New' size=10><s>Sample Text </s>in <u>Courier New</u> font</font></body></html>";
// Create text paragraphs containing HTML text
Aspose.Pdf.Generator.Text t1 = new Aspose.Pdf.Generator.Text(s);
// Enable the HTML tag support property
t1.IsHtmlTagSupported = true;
// Add the text paragraphs containing HTML text to the section
sec1.Paragraphs.Add(t1);
// Save the pdf document
pdf1.Save( dataDir + "inLineFormated_HtmlSuported_out.pdf");
// For complete examples and data files, please go to https://github.com/aspose-pdf/Aspose.Pdf-for-.NET
// Set the value for property to include a subset of font into Pdf file
s1.TextInfo.IsUnicode = true;
// For complete examples and data files, please go to https://github.com/aspose-pdf/Aspose.Pdf-for-.NET
// The path to the documents directory.
string dataDir = RunExamples.GetDataDir_AsposePdfGenerator_TechnicalArticles();
// Create pdf document
Aspose.Pdf.Generator.Pdf pdf1 = new Aspose.Pdf.Generator.Pdf();
// Instantiate License class and call its SetLicense method to use the license
Aspose.Pdf.License license = new Aspose.Pdf.License();
license.SetLicense("Aspose.Pdf.lic");
// Bind XML into the document
pdf1.BindXML(dataDir + "Hyphen-test.xml", null);
// Enable hyphenation function. Default value is false.
pdf1.IsAutoHyphenated = true;
// Set the hyphenation dictionary path.
pdf1.HyphenationDictionaryPath = dataDir + "Hyphen.xml";
// Set the hyphenation area width. Default value is 12 points.
pdf1.HyphenationZoneWidth = 0;
// Set the maximum number of consecutive hyphenations. Default value is zero that means no // Limits.
pdf1.ConsecutiveHyphensLimits = 0;
// Save the Pdf file
pdf1.Save(dataDir + "Hyphen-test_out.pdf");
// For complete examples and data files, please go to https://github.com/aspose-pdf/Aspose.Pdf-for-.NET
// The path to the documents directory.
string dataDir = RunExamples.GetDataDir_AsposePdfGenerator_TechnicalArticles();
// Instantiate a Pdf object by calling its empty constructor
Aspose.Pdf.Generator.Pdf pdf1 = new Aspose.Pdf.Generator.Pdf();
// Create a section in the Pdf object
Aspose.Pdf.Generator.Section sec1 = pdf1.Sections.Add();
//=====================================================//
// Header to show an Image
//=====================================================//
// Create Header Section of the document
Aspose.Pdf.Generator.HeaderFooter header = new Aspose.Pdf.Generator.HeaderFooter(sec1);
// Set the Odd header for the PDF file
sec1.OddHeader = header;
// Set the Even Header for the PDF file
sec1.EvenHeader = header;
// Create an image object in the section
Aspose.Pdf.Generator.Image image1 = new Aspose.Pdf.Generator.Image(sec1);
// Set the path of image file
image1.ImageInfo.File = dataDir + "aspose-logo.jpg";
// Set the type of image using ImageFileType enumeration
image1.ImageInfo.ImageFileType = Aspose.Pdf.Generator.ImageFileType.Jpeg;
// Add image to Header section of the Pdf file
header.Paragraphs.Add(image1);
//=====================================================//
// Footer to show Page Number
//=====================================================//
// Create a Footer Section of the document
Aspose.Pdf.Generator.HeaderFooter footer = new Aspose.Pdf.Generator.HeaderFooter(sec1);
// Set the Odd footer of the PDF file
sec1.OddFooter = footer;
// Set the Even footer of the PDF file
sec1.EvenFooter = footer;
// Create a Text object
Aspose.Pdf.Generator.Text txt = new Aspose.Pdf.Generator.Text("Page: ($p of $P ) ");
// Add text to Header section of the Pdf file
footer.Paragraphs.Add(txt);
// Save the Pdf file
pdf1.Save(dataDir + "ImageAndPageNumberInHeaderFooter_out.pdf");
// For complete examples and data files, please go to https://github.com/aspose-pdf/Aspose.Pdf-for-.NET
// The path to the documents directory.
string dataDir = RunExamples.GetDataDir_AsposePdfGenerator_TechnicalArticles();
// Instantiate Pdf instance
Aspose.Pdf.Generator.Pdf pdf = new Aspose.Pdf.Generator.Pdf();
// Add a section into the pdf document
Aspose.Pdf.Generator.Section section = pdf.Sections.Add();
// Initializes a new instance of the FloatingBox class
Aspose.Pdf.Generator.FloatingBox box1 = new Aspose.Pdf.Generator.FloatingBox(140, 80);
// Indicate the horizontal positioning type of the floating box
box1.BoxHorizontalPositioning = Aspose.Pdf.Generator.BoxHorizontalPositioningType.Margin;
// Float value that indicates left position of the paragraph
box1.Left = 2;
// Indicate the vertical alignment type of the floating box
box1.BoxVerticalPositioning = Aspose.Pdf.Generator.BoxVerticalPositioningType.Page;
// Float value that indicates top position of the paragraph
box1.Top = 10;
// Add the macros to the paragraphs collection of the FloatingBox
box1.Paragraphs.Add(new Aspose.Pdf.Generator.Text("Page: ($p/ $P )"));
// Add a floatingBox to the section
section.Paragraphs.Add(box1);
// Save the document
pdf.Save( dataDir + "PageNumber_using_FloatingBox_out.pdf");
// For complete examples and data files, please go to https://github.com/aspose-pdf/Aspose.Pdf-for-.NET
// The path to the documents directory.
string dataDir = RunExamples.GetDataDir_AsposePdfGenerator_TechnicalArticles();
// Instantiate a Pdf object by calling its empty constructor
Aspose.Pdf.Generator.Pdf pdf1 = new Aspose.Pdf.Generator.Pdf();
// Create a section in the Pdf object
Aspose.Pdf.Generator.Section sec1 = pdf1.Sections.Add();
//=====================================================//
// Header to show an Image inline with text
//=====================================================//
// Create Header Section of the document
Aspose.Pdf.Generator.HeaderFooter header = new Aspose.Pdf.Generator.HeaderFooter(sec1);
// Set the Odd header for the PDF file
sec1.OddHeader = header;
// Set the Even Header for the PDF file
sec1.EvenHeader = header;
// Create a Text object
Aspose.Pdf.Generator.Text txt1 = new Aspose.Pdf.Generator.Text();
// Add text to Header section of the Pdf file
header.Paragraphs.Add(txt1);
// Add the text string to Segment of text object
txt1.Segments.Add("Aspose.Pdf is a Robust component by");
// Specify the color & Font information using TextInfo property
txt1.TextInfo.Color = new Aspose.Pdf.Generator.Color("Blue");
txt1.TextInfo.FontName = "Helvetica";
// Create a new segment to be added to text object
Aspose.Pdf.Generator.Segment seg1 = txt1.Segments.Add();
// Create an image object in the section
Aspose.Pdf.Generator.Image image1 = new Aspose.Pdf.Generator.Image(sec1);
// Set the path of image file
image1.ImageInfo.File = dataDir + "aspose-logo.jpg";
// Set the type of image using ImageFileType enumeration
image1.ImageInfo.ImageFileType = Aspose.Pdf.Generator.ImageFileType.Jpeg;
// Set the image width Information
image1.ImageInfo.FixWidth = 150;
// Indicate seg1's InlineParagraph is a image.
seg1.InlineParagraph = image1;
// Create a new segment to be added to text object
Aspose.Pdf.Generator.Segment seg2 = txt1.Segments.Add("Pty Ltd.");
seg2.TextInfo.Color = new Aspose.Pdf.Generator.Color("Maroon");
// Save the Pdf
pdf1.Save( dataDir + "ImageAndPageNumberInHeaderFooter_UsingInlineParagraph_out.pdf");
// For complete examples and data files, please go to https://github.com/aspose-pdf/Aspose.Pdf-for-.NET
// The path to the documents directory.
string dataDir = RunExamples.GetDataDir_AsposePdfGenerator_TechnicalArticles();
// Create a PDF object
Aspose.Pdf.Generator.Pdf pdf = new Aspose.Pdf.Generator.Pdf();
// Create a section and add it to pdf document
Aspose.Pdf.Generator.Section MainSection = pdf.Sections.Add();
// Create an image object
Aspose.Pdf.Generator.Image sample_image = new Aspose.Pdf.Generator.Image();
// Specify the image file path information
sample_image.ImageInfo.File = dataDir + "barbara_gray.bmp";
// Specify the image file type
sample_image.ImageInfo.ImageFileType = Aspose.Pdf.Generator.ImageFileType.Bmp;
// Specify the image width information equal to page width
sample_image.ImageInfo.FixWidth = MainSection.PageInfo.PageWidth - MainSection.PageInfo.Margin.Left - MainSection.PageInfo.Margin.Right;
// Specify the image Height information equal to page Height
sample_image.ImageInfo.FixWidth = MainSection.PageInfo.PageHeight - MainSection.PageInfo.Margin.Top - MainSection.PageInfo.Margin.Bottom;
// Create bitmap image object to load image information
Bitmap myimage = new Bitmap( dataDir + "barbara_gray.bmp");
// Check if the width of the image file is greater than Page width or not
if (myimage.Width > MainSection.PageInfo.PageWidth)
// If the Image width is greater than page width, then set the page orientation to Landscape
MainSection.IsLandscape = true;
else
// If the Image width is less than page width, then set the page orientation to Portrait
MainSection.IsLandscape = false;
// Add image to paragraphs collection of section
MainSection.Paragraphs.Add(sample_image);
// Save the resultant PDF
pdf.Save(dataDir + "ConvertBMPImageToPdf_out.pdf");
// For complete examples and data files, please go to https://github.com/aspose-pdf/Aspose.Pdf-for-.NET
// The path to the documents directory.
string dataDir = RunExamples.GetDataDir_AsposePdfGenerator_TechnicalArticles();
// Instantiate a Pdf object by calling its empty constructor
Aspose.Pdf.Generator.Pdf pdf1 = new Aspose.Pdf.Generator.Pdf();
// Create a section in the Pdf object
Aspose.Pdf.Generator.Section sec1 = pdf1.Sections.Add();
// Create an image object in the section
Aspose.Pdf.Generator.Image image1 = new Aspose.Pdf.Generator.Image(sec1);
// Add image object into the Paragraphs collection of the section
sec1.Paragraphs.Add(image1);
// Set the path of image file
image1.ImageInfo.File = dataDir + "aspose-logo.jpg";
// Set the type of image using ImageFileType enumeration
image1.ImageInfo.ImageFileType = Aspose.Pdf.Generator.ImageFileType.Jpeg;
// Set image title
image1.ImageInfo.Title = "JPEG image";
// Save the Pdf file
pdf1.Save(dataDir + "JPGImageToPdf_out.pdf");
// For complete examples and data files, please go to https://github.com/aspose-pdf/Aspose.Pdf-for-.NET
// The path to the documents directory.
string dataDir = RunExamples.GetDataDir_AsposePdfGenerator_TechnicalArticles();
// Get a list of tiff image files
string[] files = System.IO.Directory.GetFiles(dataDir);
// Instantiate a Pdf object
Aspose.Pdf.Generator.Pdf pdf1 = new Aspose.Pdf.Generator.Pdf();
// Navigate through the files and them in the pdf file
foreach (string myFile in files)
{
// Load all tiff files in byte array
FileStream fs = new FileStream(myFile, FileMode.Open, FileAccess.Read);
byte[] tmpBytes = new byte[fs.Length];
fs.Read(tmpBytes, 0, Convert.ToInt32(fs.Length));
MemoryStream mystream = new MemoryStream(tmpBytes);
Bitmap b = new Bitmap(mystream);
// Create a new section in the Pdf document
Aspose.Pdf.Generator.Section sec1 = new Aspose.Pdf.Generator.Section(pdf1);
// Set margins so image will fit, etc.
sec1.PageInfo.Margin.Top = 5;
sec1.PageInfo.Margin.Bottom = 5;
sec1.PageInfo.Margin.Left = 5;
sec1.PageInfo.Margin.Right = 5;
sec1.PageInfo.PageWidth = (b.Width / b.HorizontalResolution) * 72;
sec1.PageInfo.PageHeight = (b.Height / b.VerticalResolution) * 72;
// Add the section in the sections collection of the Pdf document
pdf1.Sections.Add(sec1);
// Create an image object
Aspose.Pdf.Generator.Image image1 = new Aspose.Pdf.Generator.Image(sec1);
// Add the image into paragraphs collection of the section
sec1.Paragraphs.Add(image1);
image1.ImageInfo.ImageFileType = Aspose.Pdf.Generator.ImageFileType.Tiff;
// Set IsBlackWhite property to true for performance improvement
image1.ImageInfo.IsBlackWhite = true;
// Set the ImageStream to a MemoryStream object
image1.ImageInfo.ImageStream = mystream;
// Set desired image scale
image1.ImageScale = 0.95F;
}
// Save the Pdf
pdf1.Save(dataDir + "PerformaceImprovement_out.pdf");
// For complete examples and data files, please go to https://github.com/aspose-pdf/Aspose.Pdf-for-.NET
// The path to the documents directory.
string dataDir = RunExamples.GetDataDir_AsposePdfGenerator_TechnicalArticles();
// Instantiate Pdf document object
Aspose.Pdf.Generator.Pdf pdf1 = new Aspose.Pdf.Generator.Pdf();
// Create a section in the Pdf
Aspose.Pdf.Generator.Section sec1 = pdf1.Sections.Add();
// Instantiate a table object
Aspose.Pdf.Generator.Table table1 = new Aspose.Pdf.Generator.Table();
// Add the table in paragraphs collection of the desired section
sec1.Paragraphs.Add(table1);
// Set with column widths of the table
table1.ColumnWidths = "120 270";
// Create MarginInfo object and set its left, bottom, right and top margins
Aspose.Pdf.Generator.MarginInfo margin = new Aspose.Pdf.Generator.MarginInfo();
margin.Top = 5f;
margin.Left = 5f;
margin.Right = 5f;
margin.Bottom = 5f;
// Set the default cell padding to the MarginInfo object
table1.DefaultCellPadding = margin;
// Create rows in the table and then cells in the rows
Aspose.Pdf.Generator.Row row1 = table1.Rows.Add();
// Create an image object
Aspose.Pdf.Generator.Image logo = new Aspose.Pdf.Generator.Image();
// Specify the image file path
logo.ImageInfo.File = dataDir + "aspose-logo.jpg";
// Specify the image Fixed Height
logo.ImageInfo.FixHeight = 120;
// Specify the image Fixed Width
logo.ImageInfo.FixWidth = 110;
row1.Cells.Add();
// Add the image to paragraphs collection of the table cell
row1.Cells[0].Paragraphs.Add(logo);
// Create string variables with text containing html tags
string TitleString = "<font face=\"Arial\" size=6 color=\"#101090\"><b> Aspose.Pdf for .NET</b></font>";
// Create a text object to be added to the right of image
Aspose.Pdf.Generator.Text TitleText = new Aspose.Pdf.Generator.Text(TitleString);
TitleText.IsHtmlTagSupported = true;
row1.Cells.Add();
// Add the text paragraphs containing HTML text to the table cell
row1.Cells[1].Paragraphs.Add(TitleText);
// Set the vertical alignment of the row contents as Top
row1.VerticalAlignment = Aspose.Pdf.Generator.VerticalAlignmentType.Top;
string BodyString1 = "<font face=\"Arial\" size=2><br/>Aspose.Pdf for .NET is a non-graphical PDF� document reporting component that enables .NET applications to <b> create PDF documents from scratch </b> without utilizing Adobe Acrobat�. Aspose.Pdf for .NET is very affordably priced and offers a wealth of strong features including: compression, tables, graphs, images, hyperlinks, security and custom fonts. </font>";
// Add a text segment to segments collection of the text object
TitleText.Segments.Add(BodyString1);
// Create rows in the table and then cells in the rows
Aspose.Pdf.Generator.Row SecondRow = table1.Rows.Add();
SecondRow.Cells.Add();
// Set the row span value for Second row as 2
SecondRow.Cells[0].ColumnsSpan = 2;
// Set the vertical alignment of the second row as Top
SecondRow.VerticalAlignment = Aspose.Pdf.Generator.VerticalAlignmentType.Top;
string SecondRowString = "<font face=\"Arial\" size=2>Aspose.Pdf for .NET supports the creation of PDF files through API and XML or XSL-FO templates. Aspose.Pdf for .NET is very easy to use and is provided with 14 fully featured demos written in both C# and Visual Basic.</font>";
Aspose.Pdf.Generator.Text SecondRowText = new Aspose.Pdf.Generator.Text(SecondRowString);
SecondRowText.IsHtmlTagSupported = true;
// Add the text paragraphs containing HTML text to the table cell
SecondRow.Cells[0].Paragraphs.Add(SecondRowText);
// Save the Pdf file
pdf1.Save(dataDir + "PlacingTextAroundImage_out.pdf");
// For complete examples and data files, please go to https://github.com/aspose-pdf/Aspose.Pdf-for-.NET
// The path to the documents directory.
string dataDir = RunExamples.GetDataDir_AsposePdfGenerator_TechnicalArticles();
// Create an object of Pdf class
Aspose.Pdf.Generator.Pdf pdf = new Aspose.Pdf.Generator.Pdf();
// Bind the source HTML file with Pdf object
pdf.BindHTML(File.ReadAllText(dataDir + "Sample.htm"));
// Get traverse through each segment inside text paragraph
foreach (Aspose.Pdf.Generator.Segment seg in (pdf.Sections[0].Paragraphs[0] as Aspose.Pdf.Generator.Text).Segments)
{
// Verify that the segment URL value is not null
if (seg.Hyperlink.Url != null)
{
// Specify the LinkType of Segment object as none
seg.Hyperlink.LinkType = Aspose.Pdf.Generator.HyperlinkType.None;
// Set the value of URL for segment object as blank
seg.Hyperlink.Url = "";
// Remove the Underline from segment
seg.TextInfo.IsUnderline = false;
// Change font color to black instread of default Blue for Hyperlinks, you may also comment the following line to display in blue
seg.TextInfo.Color = new Aspose.Pdf.Generator.Color("Black");
}
}
// Save the resultant PDF
pdf.Save(dataDir + "RemoveHyperlinksFromText_out.pdf");
// For complete examples and data files, please go to https://github.com/aspose-pdf/Aspose.Pdf-for-.NET
// The path to the documents directory.
string dataDir = RunExamples.GetDataDir_AsposePdfGenerator_TechnicalArticles();
// Instantiate a Pdf object by calling its empty constructor
Aspose.Pdf.Generator.Pdf pdf = new Aspose.Pdf.Generator.Pdf();
// Retrieve names of all the Pdf files in a particular Directory
string[] fileEntries = Directory.GetFiles(dataDir, "*.JPG");
int counter;
for (counter = 0; counter < fileEntries.Length - 1; counter++)
{
// Create a section object
Aspose.Pdf.Generator.Section section1 = pdf.Sections.Add();
// Creat an image object
Aspose.Pdf.Generator.Image image1 = new Aspose.Pdf.Generator.Image(section1);
image1.ImageInfo.File = fileEntries[counter];
image1.ImageInfo.ImageFileType = Aspose.Pdf.Generator.ImageFileType.Jpeg;
// Create a BitMap object in order to get the information of image file
Bitmap myimage = new Bitmap(fileEntries[counter]);
// Check if the width of the image file is greater than Page width or not
if (myimage.Width > section1.PageInfo.PageWidth)
// If the Image width is greater than page width, then set the page orientation to Landscape
section1.IsLandscape = true;
else
// If the Image width is less than page width, then set the page orientation to Portrait
section1.IsLandscape = false;
// Add the image to paragraphs collection of the PDF document
section1.Paragraphs.Add(image1);
}
// Save the Pdf file
pdf.Save(dataDir + "SetPageOrientation_out.pdf");
// For complete examples and data files, please go to https://github.com/aspose-pdf/Aspose.Pdf-for-.NET
// The path to the documents directory.
string dataDir = RunExamples.GetDataDir_AsposePdfGenerator_TechnicalArticles();
// Create Pdf Instance
Aspose.Pdf.Generator.Pdf pdf = new Aspose.Pdf.Generator.Pdf();
// Create section object and add it to pdf object
Aspose.Pdf.Generator.Section sec1 = pdf.Sections.Add();
// Create a table instance
Aspose.Pdf.Generator.Table mytable = new Aspose.Pdf.Generator.Table();
// Specify the default border for table object and set its color as Navy
mytable.DefaultCellBorder = new Aspose.Pdf.Generator.BorderInfo((int)Aspose.Pdf.Generator.BorderSide.All, 1f, new Aspose.Pdf.Generator.Color("Navy"));
// Specify the border information for table object
mytable.Border = new Aspose.Pdf.Generator.BorderInfo((int)Aspose.Pdf.Generator.BorderSide.All, 1f, new Aspose.Pdf.Generator.Color("Navy"));
// Define initial width information for table cells
mytable.ColumnWidths = "100 100";
// Create a row object and add it to table
Aspose.Pdf.Generator.Row row1 = mytable.Rows.Add();
// Create loop to add specify the number of columns to be added to table row
for (int Column_Counter = 1; Column_Counter <= 7; Column_Counter++)
{
// Create a cell object and add it to table row
Aspose.Pdf.Generator.Cell Cell = row1.Cells.Add("Cell (1," + Column_Counter.ToString() + ")");
}
// Define the variable to keep record of number of columns in table
int TableColumn = 0;
// Traverse through each table cell in row object
foreach (Aspose.Pdf.Generator.Cell InnerCell in row1.Cells)
{
// Specify the width information for each column based on section objects margin and width values
// Set the width value as, get the total width of section and subtract left and right margin and divide
// It with total number of cells in a particular table row
mytable.SetColumnWidth(TableColumn, (sec1.PageInfo.PageWidth - sec1.PageInfo.Margin.Left - sec1.PageInfo.Margin.Right) / row1.Cells.Count);
// Increase the value of variable holding the column count information
TableColumn += 1;
}
// Add table to paragraphs collection of section
sec1.Paragraphs.Add(mytable);
// Save the resultant PDF document
pdf.Save(dataDir + "SetTableColumnsWidth_out.pdf");
// For complete examples and data files, please go to https://github.com/aspose-pdf/Aspose.Pdf-for-.NET
// The path to the documents directory.
string dataDir = RunExamples.GetDataDir_AsposePdfGenerator_TechnicalArticles();
// Instantiate PDF instance by calling empty constructor
Aspose.Pdf.Generator.Pdf pdfConv = new Aspose.Pdf.Generator.Pdf();
// Create a section in the pdf document
Aspose.Pdf.Generator.Section sec1 = pdfConv.Sections.Add();
// Create a Header Section of the PDF file
Aspose.Pdf.Generator.HeaderFooter header = new Aspose.Pdf.Generator.HeaderFooter(sec1);
// Set the Odd Header for the PDF file
sec1.OddHeader = header;
// Set the top margin for the header section
header.Margin.Top = 20;
// Instantiate a table object
Aspose.Pdf.Generator.Table tab1 = new Aspose.Pdf.Generator.Table();
// Add the table in paragraphs collection of the desired section
header.Paragraphs.Add(tab1);
// Set default cell border using BorderInfo object
tab1.DefaultCellBorder = new Aspose.Pdf.Generator.BorderInfo((int)Aspose.Pdf.Generator.BorderSide.All, 0.1F);
// Set with column widths of the table
tab1.ColumnWidths = "60 300";
Aspose.Pdf.Generator.Image img = new Aspose.Pdf.Generator.Image();
img.ImageInfo.File = dataDir + "aspose-logo.jpg";
img.ImageInfo.ImageFileType = Aspose.Pdf.Generator.ImageFileType.Jpeg;
// Create rows in the table and then cells in the rows
Aspose.Pdf.Generator.Row row1 = tab1.Rows.Add();
row1.Cells.Add("Table in Header Section");
row1.BackgroundColor = new Aspose.Pdf.Generator.Color("#CCCCCC");
row1.DefaultCellTextInfo.Color = new Aspose.Pdf.Generator.Color("#6699FF");
// Set the font face for the text in the row
row1.DefaultCellTextInfo.FontName = "Helvetica";
// Set the row span value for first row as 2
tab1.Rows[0].Cells[0].ColumnsSpan = 2;
// Create rows in the table and then cells in the rows
Aspose.Pdf.Generator.Row row2 = tab1.Rows.Add();
// Set the background color for Row2
row2.BackgroundColor = new Aspose.Pdf.Generator.Color("#FFFFCC");
// Add the cell which holds the image
Aspose.Pdf.Generator.Cell cell2 = row2.Cells.Add();
// Set the image width to 60
img.ImageInfo.FixWidth = 60;
Aspose.Pdf.Generator.Text txt2 = new Aspose.Pdf.Generator.Text();
// Add a text segment to hold image and text together
Aspose.Pdf.Generator.Segment seg1 = new Aspose.Pdf.Generator.Segment();
seg1.InlineParagraph = img;
txt2.Segments.Add(seg1);
// Add the image to the table cell
cell2.Paragraphs.Add(txt2);
row2.Cells.Add("Penguin is looking very lovely !");
row2.DefaultCellTextInfo.FontName = "Helvetica";
// Set the vertical allignment of the text as center alligned
row2.Cells[1].VerticalAlignment = Aspose.Pdf.Generator.VerticalAlignmentType.Center;
row2.Cells[1].Alignment = Aspose.Pdf.Generator.AlignmentType.Center;
// Save the Pdf file
pdfConv.Save(dataDir + "TableInHeaderFooterSection_out.pdf");
// For complete examples and data files, please go to https://github.com/aspose-pdf/Aspose.Pdf-for-.NET
// The path to the documents directory.
string dataDir = RunExamples.GetDataDir_AsposePdfGenerator_Text();
// Instantiate a pdf document
Aspose.Pdf.Generator.Pdf pdf = new Aspose.Pdf.Generator.Pdf();
// Create Section
Aspose.Pdf.Generator.Section sec = pdf.Sections.Add();
// Create Text Paragraph
Aspose.Pdf.Generator.Text text = new Aspose.Pdf.Generator.Text();
// Create Segment
Aspose.Pdf.Generator.Segment segment = new Aspose.Pdf.Generator.Segment("This is the First Segment");
// Create EndNote and Assign an EndNote property of Segment to its object
Aspose.Pdf.Generator.EndNote endnote1 = new Aspose.Pdf.Generator.EndNote("Endnotes for First Segment");
segment.EndNote = endnote1;
// Add Segment in Text Paragraph
text.Segments.Add(segment);
// Add Text in Section
sec.Paragraphs.Add(text);
// Save the document
pdf.Save(dataDir + "AddEndnote_out.pdf");
// For complete examples and data files, please go to https://github.com/aspose-pdf/Aspose.Pdf-for-.NET
// The path to the documents directory.
string dataDir = RunExamples.GetDataDir_AsposePdfGenerator_Text();
// Instantiate a pdf document
Aspose.Pdf.Generator.Pdf pdf = new Aspose.Pdf.Generator.Pdf();
// Create Section
Aspose.Pdf.Generator.Section sec = pdf.Sections.Add();
// Create Text Paragraph
Aspose.Pdf.Generator.Text text = new Aspose.Pdf.Generator.Text();
// Create Segment
Aspose.Pdf.Generator.Segment segment = new Aspose.Pdf.Generator.Segment("This is the First Segment");
// Create FootNote and Assign FootNote property of Segment to its object
segment.FootNote = new Aspose.Pdf.Generator.FootNote("Footnotes for First Segment");
// Add Segment in Text Paragraph
text.Segments.Add(segment);
// Add Text in Section
sec.Paragraphs.Add(text);
// Save the document
pdf.Save(dataDir + "AddFootnotes_out.pdf");
// For complete examples and data files, please go to https://github.com/aspose-pdf/Aspose.Pdf-for-.NET
// The path to the documents directory.
string dataDir = RunExamples.GetDataDir_AsposePdfGenerator_Text();
// Instantiate Pdf instance by calling its empty constructor
Aspose.Pdf.Generator.Pdf pdf1 = new Aspose.Pdf.Generator.Pdf();
// Create a new section in the Pdf object
Aspose.Pdf.Generator.Section sec1 = pdf1.Sections.Add();
// Set text color to blue in the whole section
sec1.TextInfo.Color = new Aspose.Pdf.Generator.Color("Blue");
// Add 1st paragraph (inheriting the text format settings from the section)
// To the section
sec1.Paragraphs.Add(new Aspose.Pdf.Generator.Text(sec1, "paragraph 1 "));
// Add 2nd paragraph (inheriting the text format settings from the section)
// To the section
sec1.Paragraphs.Add(new Aspose.Pdf.Generator.Text(sec1, "paragraph 2"));
// Create 3rd paragraph (inheriting the text format settings from the section)
Aspose.Pdf.Generator.Text t3 = new Aspose.Pdf.Generator.Text(sec1);
// Create a segment "seg1" in the paragraph "t3"
Aspose.Pdf.Generator.Segment seg1 = new Aspose.Pdf.Generator.Segment(t3);
// Assign some content to the segment
seg1.Content = "paragraph 3 segment 1";
// Set the color of the segment to red
seg1.TextInfo.Color = new Aspose.Pdf.Generator.Color("Red");
// Add segment (with red text color) to the paragraph
t3.Segments.Add(seg1);
// Create a new segment "seg2" in the paragraph "t3"
Aspose.Pdf.Generator.Segment seg2 = new Aspose.Pdf.Generator.Segment(t3);
// Assign some content to the segment
seg2.Content = "paragraph 3 segment 2";
// Set the color of the segment to green
seg2.TextInfo.Color = new Aspose.Pdf.Generator.Color("Green");
// Add segment (with green text color) to the paragraph
t3.Segments.Add(seg2);
// Add 3rd text paragraph to the section with overridden text format settings
sec1.Paragraphs.Add(t3);
// Add 4th paragraph (inheriting the text format settings from the section)
// To the section
sec1.Paragraphs.Add(new Aspose.Pdf.Generator.Text(sec1, "paragraph 4"));
Aspose.Pdf.Generator.TextInfo info1 = t3.TextInfo.Clone() as Aspose.Pdf.Generator.TextInfo;
// Modify the font side to 16 pt
info1.FontSize = 16;
// Set TextInfo property of the text paragraph to newly cloned instance "info1"
t3.TextInfo = info1;
// Save the document
pdf1.Save(dataDir + "ChangeTextFormat_out.pdf");
// For complete examples and data files, please go to https://github.com/aspose-pdf/Aspose.Pdf-for-.NET
// The path to the documents directory.
string dataDir = RunExamples.GetDataDir_AsposePdfGenerator_Text();
// Instantiate Pdf instance by calling it empty constructor
Aspose.Pdf.Generator.Pdf pdf = new Aspose.Pdf.Generator.Pdf();
// Create a text object
Aspose.Pdf.Generator.Text text1 = new Aspose.Pdf.Generator.Text("This #$TAB is a example for custom TAB stop positions.");
// Assign an instance of TabStops to the TabStops property of text object
text1.TabStops = new Aspose.Pdf.Generator.TabStops();
// Call Add method of TabStops and pass a specified position as argument
text1.TabStops.Add(150);
// Call Add method with specified position and tab leader type as Dot
text1.TabStops.Add(350, Aspose.Pdf.Generator.TabLeaderType.Dot);
pdf.Save(dataDir + "CustomTabStops_out.pdf");
// For complete examples and data files, please go to https://github.com/aspose-pdf/Aspose.Pdf-for-.NET
// Create a text object in a section
Aspose.Pdf.Generator.Text t1 = new Aspose.Pdf.Generator.Text(sec1, "Arial Bold MT");
// Set the font name of a segment in the text object
t1.Segments[0].TextInfo.FontName = "Arial-BoldMT";
// Set the PFM file for the text segment
t1.Segments[0].TextInfo.FontPfmFile = "_AB_____.PFM";
// Set the font encoding file for the text segment
t1.Segments[0].TextInfo.FontEncodingFile = "CP1250.txt";
// Set the font encoding name of the text segment
t1.Segments[0].TextInfo.FontEncoding = "cp1250";
// Set the font outline file for the text segment
t1.Segments[0].TextInfo.FontOutlineFile = "_AB_____.PFB";
// Set IsFontEmbedded to true
t1.Segments[0].TextInfo.IsFontEmbedded = true;
// For complete examples and data files, please go to https://github.com/aspose-pdf/Aspose.Pdf-for-.NET
// Create a text object in the section
Aspose.Pdf.Generator.Text t1 = new Aspose.Pdf.Generator.Text(sec1, "Courier New Bold font");
// Set font name of a specific text segment to courier new
t1.Segments[0].TextInfo.FontName = "Courier New";
// Set the font to bold
t1.Segments[0].TextInfo.IsTrueTypeFontBold = true;
// For complete examples and data files, please go to https://github.com/aspose-pdf/Aspose.Pdf-for-.NET
// Create a text object in the section
Aspose.Pdf.Generator.Text t1 = new Aspose.Pdf.Generator.Text(sec1, "Courier New Bold font");
// Set font name of a specific text segment to courier new
t1.Segments[0].TextInfo.FontName = "Courier New";
// For complete examples and data files, please go to https://github.com/aspose-pdf/Aspose.Pdf-for-.NET
// The path to the documents directory.
string dataDir = RunExamples.GetDataDir_AsposePdfGenerator_Text();
// Instantiate Pdf instance by calling it empty constructor
Aspose.Pdf.Generator.Pdf pdf = new Aspose.Pdf.Generator.Pdf();
// Set the property to make your application run faster. It will help load the Truetype font faster
pdf.IsTruetypeFontMapCached = true;
// Create a section in the Pdf object
Aspose.Pdf.Generator.Section sec1 = pdf.Sections.Add();
// To assign a unicode character by it's coding
Aspose.Pdf.Generator.Text t1 = new Aspose.Pdf.Generator.Text(((char)0x25a0).ToString());
// Specify the font face name for first segment in text object
t1.Segments[0].TextInfo.FontName = "Times New Roman";
// Specify that first segment in text is UniCode
t1.Segments[0].TextInfo.IsUnicode = true;
// Add text to paragraphs collection of section object
sec1.Paragraphs.Add(t1);
// Save the PDF document
pdf.Save(dataDir + "Unicode_out.pdf");
// For complete examples and data files, please go to https://github.com/aspose-pdf/Aspose.Pdf-for-.NET
// The path to the documents directory.
string dataDir = RunExamples.GetDataDir_AsposePdfGenerator_Text();
// Instantiate a pdf document
Aspose.Pdf.Generator.Pdf pdf1 = new Aspose.Pdf.Generator.Pdf();
// Create a section in the pdf document
Aspose.Pdf.Generator.Section sec1 = pdf1.Sections.Add();
// Create a string variable with text containing hyperlink tag
string string1 = "<a href=\"http:// Www.aspose.com/\">This is a test</a>";
// Create text paragraph containing HTML hyperlink tag
Aspose.Pdf.Generator.Text text1 = new Aspose.Pdf.Generator.Text(string1);
text1.IsHtmlTagSupported = true;
// Add the text paragraph containing HTML text to the section
sec1.Paragraphs.Add(text1);
// Save the document
pdf1.Save(dataDir + "HyperlinkTags_out.pdf");
// For complete examples and data files, please go to https://github.com/aspose-pdf/Aspose.Pdf-for-.NET
// The path to the documents directory.
string dataDir = RunExamples.GetDataDir_AsposePdfGenerator_Text();
// Instantiate Pdf instance by calling its empty constructor
Aspose.Pdf.Generator.Pdf pdf1 = new Aspose.Pdf.Generator.Pdf();
// Create a new section in the Pdf object
Aspose.Pdf.Generator.Section sec1 = pdf1.Sections.Add();
// Set text color to blue in the whole section
sec1.TextInfo.Color = new Aspose.Pdf.Generator.Color("Blue");
// Add 1st paragraph (inheriting the text format settings from the section)
// To the section
sec1.Paragraphs.Add(new Aspose.Pdf.Generator.Text(sec1, "paragraph 1 "));
// Add 2nd paragraph (inheriting the text format settings from the section)
// To the section
sec1.Paragraphs.Add(new Aspose.Pdf.Generator.Text(sec1, "paragraph 2"));
// Create 3rd paragraph (inheriting the text format settings from the section)
Aspose.Pdf.Generator.Text t3 = new Aspose.Pdf.Generator.Text(sec1);
// Create a segment "seg1" in the paragraph "t3"
Aspose.Pdf.Generator.Segment seg1 = new Aspose.Pdf.Generator.Segment(t3);
// Assign some content to the segment
seg1.Content = "paragraph 3 segment 1";
// Set the color of the segment to red
seg1.TextInfo.Color = new Aspose.Pdf.Generator.Color("Red");
// Add segment (with red text color) to the paragraph
t3.Segments.Add(seg1);
// Create a new segment "seg2" in the paragraph "t3"
Aspose.Pdf.Generator.Segment seg2 = new Aspose.Pdf.Generator.Segment(t3);
// Assign some content to the segment
seg2.Content = "paragraph 3 segment 2";
// Set the color of the segment to green
seg2.TextInfo.Color = new Aspose.Pdf.Generator.Color("Green");
// Add segment (with green text color) to the paragraph
t3.Segments.Add(seg2);
// Add 3rd text paragraph to the section with overridden text format settings
sec1.Paragraphs.Add(t3);
// Add 4th paragraph (inheriting the text format settings from the section)
// To the section
sec1.Paragraphs.Add(new Aspose.Pdf.Generator.Text(sec1, "paragraph 4"));
dataDir = dataDir + "InheritTextFormat_out.pdf";
// Save the document
pdf1.Save(dataDir);
// For complete examples and data files, please go to https://github.com/aspose-pdf/Aspose.Pdf-for-.NET
// The path to the documents directory.
string dataDir = RunExamples.GetDataDir_AsposePdfGenerator_Text();
// Create pdf document
Aspose.Pdf.Generator.Pdf pdf1 = new Aspose.Pdf.Generator.Pdf();
// Bind XML into the document
pdf1.BindXML(dataDir + "InlineHTMLFromXML.xml", null);
// Save the document
pdf1.Save(dataDir + "InlineHTMLFromXML_out.pdf");
// For complete examples and data files, please go to https://github.com/aspose-pdf/Aspose.Pdf-for-.NET
string dataDir = RunExamples.GetDataDir_AsposePdfGenerator_Text();
// Instantiate a pdf document
Aspose.Pdf.Generator.Pdf pdf1 = new Aspose.Pdf.Generator.Pdf();
// Create a section in the pdf document
Aspose.Pdf.Generator.Section sec1 = pdf1.Sections.Add();
// Create string variables with text containing html tags
string s = "<font face=\"Times New Roman\" size=18><u>" +
"This is a test </u><i> for <strong> HTML </<strong> support </i>" +
"<s> in Text paragraph. </s></font>";
string s1 = "<font color=\"#800080\">This is a test for <b>HTML</b>" +
"with colored text.</font>";
string s2 = "<p><font face=\"Verdana\" color=\"#0033ff\"> This is a test for" +
"<strong>HTML</strong> in text paragraph.</font></p>";
// Create text paragraphs containing HTML text
Aspose.Pdf.Generator.Text text1 = new Aspose.Pdf.Generator.Text(s);
text1.IsHtmlTagSupported = true;
Aspose.Pdf.Generator.Text text2 = new Aspose.Pdf.Generator.Text(s1);
text2.IsHtmlTagSupported = true;
Aspose.Pdf.Generator.Text text3 = new Aspose.Pdf.Generator.Text(s2);
text3.IsHtmlTagSupported = true;
// Add the text paragraphs containing HTML text to the section
sec1.Paragraphs.Add(text1);
sec1.Paragraphs.Add(text2);
sec1.Paragraphs.Add(text3);
// Save the pdf document
pdf1.Save(dataDir + "InlineHTMLFromXML_out.pdf");
// For complete examples and data files, please go to https://github.com/aspose-pdf/Aspose.Pdf-for-.NET
// The path to the documents directory.
string dataDir = RunExamples.GetDataDir_AsposePdfGenerator_Text();
// Instantiate Pdf instance by calling its empty constructor
Aspose.Pdf.Generator.Pdf pdf1 = new Aspose.Pdf.Generator.Pdf();
// Create section object and add it to sections collection of PDF
Aspose.Pdf.Generator.Section sec1 = pdf1.Sections.Add();
// Create a text object
Aspose.Pdf.Generator.Text text1 = new Aspose.Pdf.Generator.Text();
// Add text object to paragraphs collection of section
sec1.Paragraphs.Add(text1);
// Add sample text to segments collection of text object
text1.Segments.Add("This is a test for inline");
// Create segment 2 and add it to segements collection of text object
Aspose.Pdf.Generator.Segment seg2 = text1.Segments.Add();
// Create a Image object to contain logo gif.
Aspose.Pdf.Generator.Image img1 = new Aspose.Pdf.Generator.Image();
// Specify the image file path
img1.ImageInfo.File = dataDir + "aspose-logo.jpg";
// Indicate seg2's InlineParagraph is a image.
seg2.InlineParagraph = img1;
dataDir = dataDir + "InlineImage_out.pdf";
// Create the result PDF Document
pdf1.Save(dataDir);
// For complete examples and data files, please go to https://github.com/aspose-pdf/Aspose.Pdf-for-.NET
// The path to the documents directory.
string dataDir = RunExamples.GetDataDir_AsposePdfGenerator_Text();
// Create Pdf Instance
Aspose.Pdf.Generator.Pdf pdf1 = new Aspose.Pdf.Generator.Pdf();
// Add A Section
Aspose.Pdf.Generator.Section sec1 = pdf1.Sections.Add();
// Add Text Paragraph
Aspose.Pdf.Generator.Text text1 = new Aspose.Pdf.Generator.Text();
// Add Text Paragraph to paragraphs collection of section
sec1.Paragraphs.Add(text1);
// Add a segment with sample text to segments collection of Text Paragraph
text1.Segments.Add("This is a test for inline radiobutton: ");
// Specify Inline Radio button field name
text1.InlineRadioButtonFieldName = "inlineradio";
// Specify the checked index for inline radio button
text1.InlineRadioButtonCheckedIndex = 1;
// Add segments
Aspose.Pdf.Generator.Segment seg1 = text1.Segments.Add();
// 1st Radio Button and set the Inline Paragraph property of segment equal to radioButton
Aspose.Pdf.Generator.RadioButton radio1 = new Aspose.Pdf.Generator.RadioButton();
seg1.InlineParagraph = radio1;
Aspose.Pdf.Generator.Segment seg11 = text1.Segments.Add("radio1 ");
Aspose.Pdf.Generator.Segment seg2 = text1.Segments.Add();
Aspose.Pdf.Generator.RadioButton radio2 = new Aspose.Pdf.Generator.RadioButton();
radio2.ID = "radio2";
seg2.InlineParagraph = radio2;
Aspose.Pdf.Generator.Segment seg22 = text1.Segments.Add("radio2 ");
Aspose.Pdf.Generator.Segment seg3 = text1.Segments.Add();
Aspose.Pdf.Generator.RadioButton radio3 = new Aspose.Pdf.Generator.RadioButton();
seg3.InlineParagraph = radio3;
Aspose.Pdf.Generator.Segment seg33 = text1.Segments.Add("radio3 ");
// Save the document
pdf1.Save(dataDir + "InlineRadioButton_out.pdf");
// For complete examples and data files, please go to https://github.com/aspose-pdf/Aspose.Pdf-for-.NET
// Create a text object in a section
Aspose.Pdf.Generator.Text t1 = new Aspose.Pdf.Generator.Text(sec1, "Arial Bold MT");
// Set the font name of a segment in the text object
t1.Segments[0].TextInfo.FontName = "Arial-BoldMT";
// Set the PFM file for the text segment
t1.Segments[0].TextInfo.FontPfmFile = "_AB_____.PFM";
// Set the font encoding file for the text segment
t1.Segments[0].TextInfo.FontEncodingFile = @"CP1250.txt";
// Set the font encoding name of the text segment
t1.Segments[0].TextInfo.FontEncoding = "cp1250";
// For complete examples and data files, please go to https://github.com/aspose-pdf/Aspose.Pdf-for-.NET
// The path to the documents directory.
string dataDir = RunExamples.GetDataDir_AsposePdfGenerator_Text();
// Instantiate Pdf instance by calling it empty constructor
Aspose.Pdf.Generator.Pdf pdf1 = new Aspose.Pdf.Generator.Pdf();
// Create a section in the pdf object
Aspose.Pdf.Generator.Section sec1 = pdf1.Sections.Add();
// Create a HeaderFooter object for the section
Aspose.Pdf.Generator.HeaderFooter hf = new Aspose.Pdf.Generator.HeaderFooter(sec1);
// Set the HeaderFooter object to odd and even footers
sec1.OddFooter = sec1.EvenFooter = hf;
// Add a text paragraph containing current page number of total number of pages
hf.Paragraphs.Add(new Aspose.Pdf.Generator.Text(hf, "page $p of $P"));
dataDir = dataDir + "ReplaceableSymbols_out.pdf";
// Create the result PDF Document
pdf1.Save(dataDir);
// For complete examples and data files, please go to https://github.com/aspose-pdf/Aspose.Pdf-for-.NET
// The path to the documents directory.
string dataDir = RunExamples.GetDataDir_AsposePdfGenerator_Text();
// Instantiate Pdf instance by calling it empty constructor
Aspose.Pdf.Generator.Pdf pdf1 = new Aspose.Pdf.Generator.Pdf();
// Create a section in the Pdf object
Aspose.Pdf.Generator.Section sec1 = pdf1.Sections.Add();
// Create a sample text paragraph
Aspose.Pdf.Generator.Text text1 = new Aspose.Pdf.Generator.Text("page 1");
// Specify the ID for text paragraph
text1.ID = "page1";
// Add text to paragraphs collection of section
sec1.Paragraphs.Add(text1);
// Add a new text paragraph with symbol to print page number information for text paragraph with ID page4
sec1.Paragraphs.Add(new Aspose.Pdf.Generator.Text("The last page is #$REFPAGE(page4)."));
// Create a new Text paragraph with sample text
Aspose.Pdf.Generator.Text text2 = new Aspose.Pdf.Generator.Text("page 2");
// Specify the ID for text paragraph
text2.ID = "page2";
// Specify that text2 is first paragraph of section
text2.IsFirstParagraph = true;
// Add text paragraph to paragraphs collection of section object
sec1.Paragraphs.Add(text2);
Aspose.Pdf.Generator.Text text3 = new Aspose.Pdf.Generator.Text("page 3");
text3.ID = "page3";
text3.IsFirstParagraph = true;
sec1.Paragraphs.Add(text3);
Aspose.Pdf.Generator.Section sec2 = pdf1.Sections.Add();
Aspose.Pdf.Generator.Text text4 = new Aspose.Pdf.Generator.Text("page 4");
text4.ID = "page4";
sec2.Paragraphs.Add(text4);
pdf1.Save( dataDir + "test_out.pdf");
// For complete examples and data files, please go to https://github.com/aspose-pdf/Aspose.Pdf-for-.NET
// The path to the documents directory.
string dataDir = RunExamples.GetDataDir_AsposePdfGenerator_Text();
// Instantiate Pdf instance by calling it empty constructor
Aspose.Pdf.Generator.Pdf pdf = new Aspose.Pdf.Generator.Pdf();
// Create a section in the Pdf object
pdf.Sections.Add();
pdf.IsTruetypeFontMapCached = true;
// Specify the location where to save TruetypeFontMap.xml
pdf.TruetypeFontMapPath = dataDir+ "" ;
// Create a text object and pass the string object carrying arabic text in it
Aspose.Pdf.Generator.Text text1 = new Aspose.Pdf.Generator.Text();
// Create a segment and add it to segments collection of text object
Aspose.Pdf.Generator.Segment seg0 = text1.Segments.Add();
// Specify contents for segment
seg0.Content = "أسبوز هو بائع عنصر ال";
Aspose.Pdf.Generator.Segment seg1 = text1.Segments.Add();
seg1.Content = ".NET";
Aspose.Pdf.Generator.Segment seg2 = text1.Segments.Add();
seg2.Content = "البارز";
// Enable text alignment from right to left
seg0.TextInfo.IsRightToLeft = true;
seg1.TextInfo.IsRightToLeft = false; // Default
seg2.TextInfo.IsRightToLeft = true;
// Enable unicode character set for the text segment
seg0.TextInfo.IsUnicode = true;
seg1.TextInfo.IsUnicode = true;
seg2.TextInfo.IsUnicode = true;
// Set Font Name
seg0.TextInfo.FontName = "Times New Roman";
seg1.TextInfo.FontName = "Times New Roman";
seg2.TextInfo.FontName = "Times New Roman";
// Set font size
seg0.TextInfo.FontSize = 14;
seg1.TextInfo.FontSize = 14;
seg2.TextInfo.FontSize = 14;
// Align text to right hand side using AlignmentType enumeration
// Make the text right aligned(The meaning of Alignment.Left and AlignmentType.Right are // Exchanged when processing RTL language).
text1.TextInfo.Alignment = Aspose.Pdf.Generator.AlignmentType.Left;
pdf.Sections[0].Paragraphs.Add(text1);
pdf.IsRtlInSegmentMode = true; // Default
pdf.Save(dataDir + "RTLLanguages_out.pdf");
// For complete examples and data files, please go to https://github.com/aspose-pdf/Aspose.Pdf-for-.NET
// The path to the documents directory.
string dataDir = RunExamples.GetDataDir_AsposePdfGenerator_Text();
// Instantiate Pdf instance by calling its empty constructor
Aspose.Pdf.Generator.Pdf pdf1 = new Aspose.Pdf.Generator.Pdf();
// Create a section in the Pdf object
Aspose.Pdf.Generator.Section sec1 = pdf1.Sections.Add();
// Create 1st text paragraph
Aspose.Pdf.Generator.Text text1 = new Aspose.Pdf.Generator.Text(sec1,"FillText mode");
// Set rendering mode to FillText
text1.TextInfo.RenderingMode= Aspose.Pdf.Generator.RenderingMode.FillText;
// Create 2nd text paragraph
Aspose.Pdf.Generator.Text text2 = new Aspose.Pdf.Generator.Text(sec1,"StrokeText mode (outline)");
// Set rendering mode to StrokeText
text2.TextInfo.RenderingMode= Aspose.Pdf.Generator.RenderingMode.StrokeText;
// Create 3rd text paragraph
Aspose.Pdf.Generator.Text text3 = new Aspose.Pdf.Generator.Text(sec1,"FillStrokeText mode");
// Set rendering mode to FillStrokeText
text3.TextInfo.RenderingMode= Aspose.Pdf.Generator.RenderingMode.FillStrokeText;
// Create 4th text paragraph
Aspose.Pdf.Generator.Text text4 = new Aspose.Pdf.Generator.Text(sec1,"InvisibleText mode");
// Set rendering mode to InvisibleText
text4.TextInfo.RenderingMode= Aspose.Pdf.Generator.RenderingMode.InvisibleText;
// Add 1st, 2nd, 3rd and 4th text paragraphs to the section
sec1.Paragraphs.Add(text1);
sec1.Paragraphs.Add(text2);
sec1.Paragraphs.Add(text3);
sec1.Paragraphs.Add(text4);
// Save the Pdf
pdf1.Save(dataDir + "SetRenderingMode_out.pdf");
// For complete examples and data files, please go to https://github.com/aspose-pdf/Aspose.Pdf-for-.NET
// The path to the documents directory.
string dataDir = RunExamples.GetDataDir_AsposePdfGenerator_Text();
// Instantiate Pdf instance by calling its empty constructor
Aspose.Pdf.Generator.Pdf pdf1 = new Aspose.Pdf.Generator.Pdf();
// Create a section in the Pdf object
Aspose.Pdf.Generator.Section sec1 = pdf1.Sections.Add();
// Create a text paragraph
Aspose.Pdf.Generator.Text text1 = new Aspose.Pdf.Generator.Text(sec1,"Hello Aspose.Pdf");
// Set the BackgroundColor of the text paragraph to Red
text1.TextInfo.BackgroundColor=new Aspose.Pdf.Generator.Color("Red");
// Add the text paragraph to the section
sec1.Paragraphs.Add(text1);
// Save the Pdf
pdf1.Save(dataDir + "SetTextBackgroundColor_out.pdf");
// For complete examples and data files, please go to https://github.com/aspose-pdf/Aspose.Pdf-for-.NET
// The path to the documents directory.
string dataDir = RunExamples.GetDataDir_AsposePdfGenerator_Text();
// Create directory if it is not already present.
bool IsExists = System.IO.Directory.Exists(dataDir);
if (!IsExists)
System.IO.Directory.CreateDirectory(dataDir);
// Instantiate Pdf object by calling its empty constructor
Aspose.Pdf.Generator.Pdf pdf1 = new Aspose.Pdf.Generator.Pdf();
// Create a section in the Pdf object
Aspose.Pdf.Generator.Section sec1 = pdf1.Sections.Add();
// Create a new text paragraph with an initial text segment "Aspose"
Aspose.Pdf.Generator.Text text1 = new Aspose.Pdf.Generator.Text(sec1,"Aspose");
// Add the text paragraph to the section
sec1.Paragraphs.Add(text1);
// Create a new text segment into the text paragraph
Aspose.Pdf.Generator.Segment seg2 = text1.Segments.Add("TM");
// Set the vertical alignment of text segment "seg2" to Topline by setting
// IsBaseline property ot seg2.TextInfo to true
seg2.TextInfo.IsBaseline=false;
// Set the font size information for the segment
seg2.TextInfo.FontSize = 5;
// Save the Pdf
pdf1.Save(dataDir + "SetVerticalAlignment_out.pdf");
// For complete examples and data files, please go to https://github.com/aspose-pdf/Aspose.Pdf-for-.NET
// The path to the documents directory.
string dataDir = RunExamples.GetDataDir_AsposePdfGenerator_Text();
// Instantiate a pdf document
Aspose.Pdf.Generator.Pdf pdf1 = new Aspose.Pdf.Generator.Pdf();
// Create a section in the pdf document
Aspose.Pdf.Generator.Section sec1 = pdf1.Sections.Add();
// Create a string variable with html text containing Sub & Sup tags
string string1 = "<FONT face=\"Times New Roman\" size=18>HARBIN<sup>[1234]</sup> : An unexpected stoppage of water<sub>[abcd]</sub> supply sparked <sup> rumours of a contaminated river</sup> and led to a run on city <sub>supermarkets storing bottled water</sub> yesterday.</FONT>";
// Create text paragraph containing HTML text
Aspose.Pdf.Generator.Text text1 = new Aspose.Pdf.Generator.Text(string1);
text1.IsHtmlTagSupported = true;
// Add the text paragraph containing HTML text to the section
sec1.Paragraphs.Add(text1);
// Save the document
pdf1.Save(dataDir + "SuperSubscript_out.pdf");
// For complete examples and data files, please go to https://github.com/aspose-pdf/Aspose.Pdf-for-.NET
// The path to the documents directory.
string dataDir = RunExamples.GetDataDir_AsposePdfGenerator_Text();
// Instantiate Pdf instance by calling it empty constructor
Aspose.Pdf.Generator.Pdf pdf1 = new Aspose.Pdf.Generator.Pdf();
// Create a section in the Pdf object
Aspose.Pdf.Generator.Section sec1 = pdf1.Sections.Add();
// Create a text paragraph inheriting text format settings from the section
Aspose.Pdf.Generator.Text text1 = new Aspose.Pdf.Generator.Text(sec1);
// Add the text paragraph to the section
sec1.Paragraphs.Add(text1);
// Create 1st text segment
Aspose.Pdf.Generator.Segment s1 = new Aspose.Pdf.Generator.Segment(((char)183).ToString());
// Set the font name to the TextInfo.FontName property of segment
s1.TextInfo.FontName = "Symbol";
// Add 1st text segment to the text paragraph
text1.Segments.Add(s1);
// Create 2nd text segment
Aspose.Pdf.Generator.Segment s2 = new Aspose.Pdf.Generator.Segment(" the first item");
// Add 2nd text segment to the text paragraph
text1.Segments.Add(s2);
dataDir = dataDir + "SymbolFont_out.pdf";
// Create the result PDF Document
pdf1.Save(dataDir);
// For complete examples and data files, please go to https://github.com/aspose-pdf/Aspose.Pdf-for-.NET
// The path to the documents directory.
string dataDir = RunExamples.GetDataDir_AsposePdfGenerator_Text();
// Instantiate Pdf pbject by calling its empty constructor
Aspose.Pdf.Generator.Pdf pdf1 = new Aspose.Pdf.Generator.Pdf();
// Create a new section in the Pdf object
Aspose.Pdf.Generator.Section sec1 = pdf1.Sections.Add();
// Set the left margin of the section
sec1.PageInfo.Margin.Left = 110;
// Set the right margin of the section
sec1.PageInfo.Margin.Right = 120;
// Create a new text paragraph and pass the text to its constructor as argument
Aspose.Pdf.Generator.Text t2 = new Aspose.Pdf.Generator.Text("A bool value that indicates" +
"whether the TrueType font is bold. " +
"This attribute is valid for TrueType fonts only.");
// Set the font size of the text in a text segment
t2.Segments[0].TextInfo.FontSize = 16;
// Set the left margin of the text paragraph
t2.Margin.Left = 60;
// Set the first line indentation of the text paragraph to a negative value for
// Producing the effect of left hanging text paragraph
t2.FirstLineIndent = -6;
// Add this left hanging text paragraph to the section
sec1.Paragraphs.Add(t2);
dataDir = dataDir + "LeftHangingTextParagraph_out.pdf";
// Save the pdf file
pdf1.Save(dataDir);
// For complete examples and data files, please go to https://github.com/aspose-pdf/Aspose.Pdf-for-.NET
// The path to the documents directory.
string dataDir = RunExamples.GetDataDir_AsposePdfGenerator_Text();
// Instantiate Pdf instance by calling its empty constructor
Aspose.Pdf.Generator.Pdf pdf1 = new Aspose.Pdf.Generator.Pdf();
// Create a section in the Pdf object
Aspose.Pdf.Generator.Section sec1 = pdf1.Sections.Add();
// Create 1st text paragraph
Aspose.Pdf.Generator.Text text1 = new Aspose.Pdf.Generator.Text(sec1, "Text underline");
// Set IsUnderline property of Text.TextInfo to true
text1.TextInfo.IsUnderline = true;
// Create 2nd text paragraph
Aspose.Pdf.Generator.Text text2 = new Aspose.Pdf.Generator.Text(sec1, "Text overline");
// Set IsOverline property of Text.TextInfo to true
text2.TextInfo.IsOverline = true;
// Create 3rd text paragraph
Aspose.Pdf.Generator.Text text3 = new Aspose.Pdf.Generator.Text(sec1, "Text strike out");
// Set IsStrikeOut property of Text.TextInfo to true
text3.TextInfo.IsStrikeOut = true;
// Add 1st, 2nd and 3rd text paragraphs to the section
sec1.Paragraphs.Add(text1);
sec1.Paragraphs.Add(text2);
sec1.Paragraphs.Add(text3);
// Save the Pdf
pdf1.Save(dataDir + "UnderlineOverlineStrikeOut_out.pdf");
// For complete examples and data files, please go to https://github.com/aspose-pdf/Aspose.Pdf-for-.NET
// The path to the documents directory.
string dataDir = RunExamples.GetDataDir_AsposePdfGenerator_UtilityFeatures();
// Instantiate the Pdf instance
Aspose.Pdf.Generator.Pdf pdf1 = new Aspose.Pdf.Generator.Pdf();
// Set the value that PDF document will be Bookmarked
pdf1.IsBookmarked = true;
// Specify bookmark level
pdf1.BookmarkLevel = 1;
// Create Section object and add it to PDF
Aspose.Pdf.Generator.Section sec1 = pdf1.Sections.Add();
Aspose.Pdf.Generator.Heading heading1 = new Aspose.Pdf.Generator.Heading(pdf1, sec1, 1);
Aspose.Pdf.Generator.Segment segment1 = new Aspose.Pdf.Generator.Segment(heading1);
heading1.Segments.Add(segment1);
heading1.IsAutoSequence = true;
segment1.Content = "this is heading of level 1";
sec1.Paragraphs.Add(heading1);
Aspose.Pdf.Generator.Heading heading2 = new Aspose.Pdf.Generator.Heading(pdf1, sec1, 2);
Aspose.Pdf.Generator.Segment segment2 = new Aspose.Pdf.Generator.Segment(heading2);
heading2.Segments.Add(segment2);
heading2.IsAutoSequence = true;
segment2.Content = "this is heading of level 2";
sec1.Paragraphs.Add(heading2);
Aspose.Pdf.Generator.Heading heading3 = new Aspose.Pdf.Generator.Heading(pdf1, sec1, 1);
Aspose.Pdf.Generator.Segment segment3 = new Aspose.Pdf.Generator.Segment(heading3);
heading3.Segments.Add(segment3);
heading3.IsAutoSequence = false;
heading3.LabelWidth = 60;
heading3.UserLabel = "bullet1";
segment3.Content = "this is bullet style 1";
sec1.Paragraphs.Add(heading3);
dataDir = dataDir + "AddBookmark_out.pdf";
pdf1.Save(dataDir);
// For complete examples and data files, please go to https://github.com/aspose-pdf/Aspose.Pdf-for-.NET
// The path to the documents directory.
string dataDir = RunExamples.GetDataDir_AsposePdfGenerator_UtilityFeatures();
// Instantiate Pdf instance by calling its empty constructor
Aspose.Pdf.Generator.Pdf pdf1 = new Aspose.Pdf.Generator.Pdf();
// Create a list section
Aspose.Pdf.Generator.ListSection tocSection = new Aspose.Pdf.Generator.ListSection("Table Of Contents");
// Set its list type as table of of contents
tocSection.ListType = Aspose.Pdf.Generator.ListType.TableOfContents;
// Add the list section to the sections collection of the Pdf document
pdf1.Sections.Add(tocSection);
dataDir = dataDir + "AddingList_out.pdf";
// Save the Pdf
pdf1.Save(dataDir);
// For complete examples and data files, please go to https://github.com/aspose-pdf/Aspose.Pdf-for-.NET
// Set the length of list levels to 3 and set their left margins and text formats
tocSection.ListFormatArray.Length = 3;
tocSection.ListFormatArray[0].LeftMargin = 0;
tocSection.ListFormatArray[0].TextInfo.FontSize = 16;
tocSection.ListFormatArray[0].TextInfo.IsTrueTypeFontBold = true;
tocSection.ListFormatArray[1].LeftMargin = 16;
tocSection.ListFormatArray[1].TextInfo.FontSize = 14;
tocSection.ListFormatArray[2].LeftMargin = 32;
tocSection.ListFormatArray[2].TextInfo.FontSize = 12;
// For complete examples and data files, please go to https://github.com/aspose-pdf/Aspose.Pdf-for-.NET
// Define the format of the four levels list by setting the left margins and
// Text format settings of each level
tocSection.ListFormatArray.Length = 4;
tocSection.ListFormatArray[0].LeftMargin = 0;
tocSection.ListFormatArray[0].TextInfo.IsTrueTypeFontBold = true;
tocSection.ListFormatArray[0].TextInfo.IsTrueTypeFontItalic = true;
tocSection.ListFormatArray[1].LeftMargin = 10;
tocSection.ListFormatArray[1].TextInfo.IsUnderline = true;
tocSection.ListFormatArray[1].TextInfo.FontSize = 10;
tocSection.ListFormatArray[2].LeftMargin = 20;
tocSection.ListFormatArray[2].TextInfo.IsTrueTypeFontBold = true;
tocSection.ListFormatArray[3].LeftMargin = 30;
tocSection.ListFormatArray[3].TextInfo.IsTrueTypeFontBold = true;
// For complete examples and data files, please go to https://github.com/aspose-pdf/Aspose.Pdf-for-.NET
// The path to the documents directory.
string dataDir = RunExamples.GetDataDir_AsposePdfGenerator_UtilityFeatures();
// Create a PDF instance
Aspose.Pdf.Generator.Pdf pdf = new Aspose.Pdf.Generator.Pdf();
// Create a list section
Aspose.Pdf.Generator.ListSection tocSection = new Aspose.Pdf.Generator.ListSection("Table Of Contents");
// Set its list type as table of contents
tocSection.ListType = ListType.TableOfContents;
// Add the list section to the sections collection of the Pdf document
pdf.Sections.Add(tocSection);
// Define the format of the four levels list by setting the left margins and
// Text format settings of each level
tocSection.ListFormatArray.Length = 4;
tocSection.ListFormatArray[0].LeftMargin = 0;
tocSection.ListFormatArray[0].TextInfo.IsTrueTypeFontBold = true;
tocSection.ListFormatArray[0].TextInfo.IsTrueTypeFontItalic = true;
tocSection.ListFormatArray[1].LeftMargin = 10;
tocSection.ListFormatArray[1].TextInfo.IsUnderline = true;
tocSection.ListFormatArray[1].TextInfo.FontSize = 10;
tocSection.ListFormatArray[2].LeftMargin = 20;
tocSection.ListFormatArray[2].TextInfo.IsTrueTypeFontBold = true;
tocSection.ListFormatArray[3].LeftMargin = 30;
tocSection.ListFormatArray[3].TextInfo.IsTrueTypeFontBold = true;
// Create a section in the Pdf document
Aspose.Pdf.Generator.Section sec1 = pdf.Sections.Add();
// Add four headings in the section
for (int Level = 1; Level < 5; Level++)
{
Aspose.Pdf.Generator.Heading heading1 = new Aspose.Pdf.Generator.Heading(pdf, sec1, Level);
Segment segment1 = new Segment(heading1);
heading1.Segments.Add(segment1);
heading1.IsAutoSequence = true;
segment1.Content = "this is heading of level ";
segment1.Content += Level.ToString();
// Add the heading into Table Of Contents.
heading1.IsInList = true;
// Heading2.TOC = tocSection;
sec1.Paragraphs.Add(heading1);
}
// Create a list section
ListSection tocSection2 = new ListSection("Second Table Of Contents");
// Set its list type as table of of contents
tocSection2.ListType = ListType.TableOfContents;
// Add the list section to the sections collection of the Pdf document
pdf.Sections.Add(tocSection2);
// Define the format of the four levels list by setting the left margins and
// Text format settings of each level
tocSection2.ListFormatArray.Length = 4;
tocSection2.ListFormatArray[0].LeftMargin = 0;
tocSection2.ListFormatArray[0].TextInfo.IsTrueTypeFontBold = true;
tocSection2.ListFormatArray[0].TextInfo.IsTrueTypeFontItalic = true;
tocSection2.ListFormatArray[1].LeftMargin = 10;
tocSection2.ListFormatArray[1].TextInfo.IsUnderline = true;
tocSection2.ListFormatArray[1].TextInfo.FontSize = 10;
tocSection2.ListFormatArray[2].LeftMargin = 20;
tocSection2.ListFormatArray[2].TextInfo.IsTrueTypeFontBold = true;
tocSection2.ListFormatArray[3].LeftMargin = 30;
tocSection2.ListFormatArray[3].TextInfo.IsTrueTypeFontBold = true;
// Create a section in the Pdf document
Aspose.Pdf.Generator.Section sec2 = pdf.Sections.Add();
// Add four headings in the section
for (int Level = 1; Level < 5; Level++)
{
Aspose.Pdf.Generator.Heading heading2 = new Aspose.Pdf.Generator.Heading(pdf, sec1, Level);
Segment segment2 = new Segment(heading2);
heading2.Segments.Add(segment2);
heading2.IsAutoSequence = true;
segment2.Content = "this is heading of level ";
segment2.Content += Level.ToString();
// Add the heading into Table Of Contents.
heading2.IsInList = true;
// Add the heading elements to second ListSection
heading2.TOC = tocSection2;
// Add the heading obejct to paragraphs colelction of section2
sec2.Paragraphs.Add(heading2);
}
dataDir = dataDir + "Multiple_TOC_out.pdf";
// Save the resultant PDF document
pdf.Save(dataDir);
// For complete examples and data files, please go to https://github.com/aspose-pdf/Aspose.Pdf-for-.NET
// The path to the documents directory.
string dataDir = RunExamples.GetDataDir_AsposePdfGenerator_UtilityFeatures();
// Instantiate Pdf instance by calling its empty constructor
Aspose.Pdf.Generator.Pdf pdf1 = new Aspose.Pdf.Generator.Pdf();
// Create a list section
Aspose.Pdf.Generator.ListSection tocSection = new Aspose.Pdf.Generator.ListSection("Table Of Contents");
// Set its list type as table of of contents
tocSection.ListType = Aspose.Pdf.Generator.ListType.TableOfContents;
// Add the list section to the sections collection of the Pdf document
pdf1.Sections.Add(tocSection);
// Create a list section
Aspose.Pdf.Generator.ListSection lotSection = new Aspose.Pdf.Generator.ListSection("List of Tables");
// Set its list type as list of tables
lotSection.ListType = Aspose.Pdf.Generator.ListType.ListOfTables;
// Add the list section to the sections collection of the Pdf document
pdf1.Sections.Add(lotSection);
// Create a list section
Aspose.Pdf.Generator.ListSection lofSection = new Aspose.Pdf.Generator.ListSection("List of Figures");
// Set its list type as list of figures
lofSection.ListType = Aspose.Pdf.Generator.ListType.ListOfFigures;
// Add the list section to the sections collection of the Pdf document
pdf1.Sections.Add(lofSection);
dataDir = dataDir + "AddThreeList_out.pdf";
// Save the Pdf
pdf1.Save(dataDir);
// For complete examples and data files, please go to https://github.com/aspose-pdf/Aspose.Pdf-for-.NET
// The path to the documents directory.
string dataDir = RunExamples.GetDataDir_AsposePdfGenerator_UtilityFeatures();
// Create a file stream to create the PDF document
FileStream fs = new FileStream( dataDir + "SingleSeg-d_out.pdf", FileMode.Create);
// Instantiate the Pdf instance and pass the file stream object to its constructor
Aspose.Pdf.Generator.Pdf pdf = new Aspose.Pdf.Generator.Pdf(fs);
// Add a section to the PDF document
Aspose.Pdf.Generator.Section sec1 = pdf.Sections.Add();
// Add 1000 text paragraphs to the section
for (int i = 0; i < 1000; i++)
{
Aspose.Pdf.Generator.Text t = new Aspose.Pdf.Generator.Text("hello world hello world hello " + i.ToString());
sec1.AddParagraph(t);
}
// Close the Pdf. This method is used only for direct file mode
pdf.Close();
// For complete examples and data files, please go to https://github.com/aspose-pdf/Aspose.Pdf-for-.NET
// The path to the documents directory.
string dataDir = RunExamples.GetDataDir_AsposePdfGenerator_UtilityFeatures();
// Create a file stream to create the PDF document
FileStream fs = new FileStream( dataDir + "CreatePdfUsingXML_out", FileMode.Create);
// Instantiate the Pdf instance and pass the file stream object to its constructor
Aspose.Pdf.Generator.Pdf pdf = new Aspose.Pdf.Generator.Pdf(fs);
// Bind the XML file to the Pdf and leave the XSL file parameter as Nothing
pdf.BindXML( dataDir + "log.xml", null);
// Close the Pdf. This method is used only for direct file mode
pdf.Close();
// For complete examples and data files, please go to https://github.com/aspose-pdf/Aspose.Pdf-for-.NET
// The path to the documents directory.
string dataDir = RunExamples.GetDataDir_AsposePdfGenerator_UtilityFeatures();
// Instantiate the Pdf object
Aspose.Pdf.Generator.Pdf pdf1 = new Aspose.Pdf.Generator.Pdf();
// Add a section to the Pdf object
Aspose.Pdf.Generator.Section sec1 = pdf1.Sections.Add();
Aspose.Pdf.Generator.Text text1 = new Aspose.Pdf.Generator.Text(sec1, "This is text in section1.");
text1.Left = 30;
text1.Top = 100;
sec1.Paragraphs.Add(text1);
Aspose.Pdf.Generator.Section sec2 = pdf1.Sections.Add();
Aspose.Pdf.Generator.Text text2 = new Aspose.Pdf.Generator.Text(sec2, "This is text in section2.");
text2.Left = 30;
text2.Top = 100;
sec2.Paragraphs.Add(text2);
// Setting image watermark
Aspose.Pdf.Generator.Image image1 = new Aspose.Pdf.Generator.Image();
image1.ImageInfo.File = dataDir + "aspose-logo.jpg";
image1.ImageInfo.ImageFileType = Aspose.Pdf.Generator.ImageFileType.Jpeg;
image1.ImageScale = 0.1f;
Aspose.Pdf.Generator.FloatingBox watermark1 = new Aspose.Pdf.Generator.FloatingBox(108, 80);
watermark1.BoxHorizontalPositioning = Aspose.Pdf.Generator.BoxHorizontalPositioningType.Page;
watermark1.BoxHorizontalAlignment = Aspose.Pdf.Generator.BoxHorizontalAlignmentType.Center;
watermark1.BoxVerticalPositioning = Aspose.Pdf.Generator.BoxVerticalPositioningType.Page;
watermark1.BoxVerticalAlignment = Aspose.Pdf.Generator.BoxVerticalAlignmentType.Center;
watermark1.Paragraphs.Add(image1);
// Graph watermark
Aspose.Pdf.Generator.Graph graph1 = new Aspose.Pdf.Generator.Graph(100, 400);
float[] posArr = new float[] { 0, 0, 200, 80, 300, 40, 350, 90 };
Aspose.Pdf.Generator.Curve curve1 = new Aspose.Pdf.Generator.Curve(graph1, posArr);
graph1.Shapes.Add(curve1);
Aspose.Pdf.Generator.FloatingBox watermark2 = new Aspose.Pdf.Generator.FloatingBox(108, 80);
watermark2.Paragraphs.Add(graph1);
// Text watermark
Aspose.Pdf.Generator.Text text3 = new Aspose.Pdf.Generator.Text("Text Watermark");
Aspose.Pdf.Generator.FloatingBox watermark3 = new Aspose.Pdf.Generator.FloatingBox(108, 80);
watermark3.Left = 50;
watermark3.Top = 500;
watermark3.Paragraphs.Add(text3);
pdf1.Watermarks.Add(watermark1);
pdf1.Watermarks.Add(watermark2);
pdf1.Watermarks.Add(watermark3);
dataDir = dataDir + "CustomizingWatermark_out.pdf";
// Save the Pdf
pdf1.Save(dataDir);
// For complete examples and data files, please go to https://github.com/aspose-pdf/Aspose.Pdf-for-.NET
// The path to the documents directory.
string dataDir = RunExamples.GetDataDir_AsposePdfGenerator_UtilityFeatures();
// Instantiate a Pdf object
Aspose.Pdf.Generator.Pdf pdf1 = new Aspose.Pdf.Generator.Pdf();
// Add a section to the Pdf
Aspose.Pdf.Generator.Section sec1 = pdf1.Sections.Add();
// Set the number of columns in the section to 3
sec1.ColumnInfo.ColumnCount = 3;
dataDir = dataDir + "ManipulatingColumns_out.pdf";
// Save the Pdf
pdf1.Save(dataDir);
// For complete examples and data files, please go to https://github.com/aspose-pdf/Aspose.Pdf-for-.NET
// The path to the documents directory.
string dataDir = RunExamples.GetDataDir_AsposePdfGenerator_UtilityFeatures();
// Instantiate a Pdf object
Aspose.Pdf.Generator.Pdf pdf1 = new Aspose.Pdf.Generator.Pdf();
// Add a section to the Pdf
Aspose.Pdf.Generator.Section sec1 = pdf1.Sections.Add();
// Add two columns in the section
sec1.ColumnInfo.ColumnCount = 2;
// Set the spacing between the columns
sec1.ColumnInfo.ColumnSpacing = "15";
// Set the widths of the columns
sec1.ColumnInfo.ColumnWidths = "250 150";
dataDir = dataDir + "MultipleColumnsWithDefaultSpacing_out.pdf";
// Save the Pdf
pdf1.Save(dataDir);
// For complete examples and data files, please go to https://github.com/aspose-pdf/Aspose.Pdf-for-.NET
// The path to the documents directory.
string dataDir = RunExamples.GetDataDir_AsposePdfGenerator_UtilityFeatures();
// Instantiate the Pdf object
Aspose.Pdf.Generator.Pdf pdf1 = new Aspose.Pdf.Generator.Pdf();
// Add a section to the Pdf object
Aspose.Pdf.Generator.Section sec1 = pdf1.Sections.Add();
// Create a text paragraph
Aspose.Pdf.Generator.Text text1 = new Aspose.Pdf.Generator.Text("This is a text paragraph.");
// Set the id of the paragraph to "text1" so that it can referenced uniquely
text1.ID = "text1";
// Add the paragraph to the section
sec1.Paragraphs.Add(text1);
// Create a graph with specified left and top position settings. Set its
// Poition relative to the page. Add a rectangle to its shapes collection and
// Then add the graph to the paragraph collection of the section
Aspose.Pdf.Generator.Graph graph1 = new Aspose.Pdf.Generator.Graph(200, 50);
graph1.Left = 200;
graph1.Top = 10;
graph1.PositioningType = Aspose.Pdf.Generator.PositioningType.PageRelative;
graph1.Shapes.Add(new Aspose.Pdf.Generator.Rectangle(0, 0, 200, 50));
sec1.Paragraphs.Add(graph1);
// Create an attachment as note annotation and add it to the section as a
// Pragraph. Set the content and heading for the note. Set its position relative
// To the paragraph. Assign a unique id to this note annotation for the
// Reference purposes and then customize its left and top position
Aspose.Pdf.Generator.Attachment noteAttachment = new Aspose.Pdf.Generator.Attachment();
sec1.Paragraphs.Add(noteAttachment);
noteAttachment.AttachmentType = Aspose.Pdf.Generator.AttachmentType.Note;
noteAttachment.NoteContent = "This is a test for note";
noteAttachment.NoteHeading = "this is a Note";
noteAttachment.PositioningType = Aspose.Pdf.Generator.PositioningType.ParagraphRelative;
noteAttachment.ReferenceParagraphID = "text1";
noteAttachment.Left = 200;
noteAttachment.Top = 0;
dataDir = dataDir + "ParagraphsCustomPositioning_out.pdf";
// Save the Pdf
pdf1.Save(dataDir);
// For complete examples and data files, please go to https://github.com/aspose-pdf/Aspose.Pdf-for-.NET
// The path to the documents directory.
string dataDir = RunExamples.GetDataDir_AsposePdfGenerator_UtilityFeatures();
// Instantiate a Pdf instance
Aspose.Pdf.Generator.Pdf pdf1 = new Aspose.Pdf.Generator.Pdf();
// Add a section in the Pdf document
Aspose.Pdf.Generator.Section sec1 = pdf1.Sections.Add();
// Create a form field
Aspose.Pdf.Generator.FormField combo = new Aspose.Pdf.Generator.FormField();
// Set the type of form field to Combo
combo.FormFieldType = Aspose.Pdf.Generator.FormFieldType.Combo;
// Set the field name
combo.FieldName = "ACombo";
// Add few options to the combo
combo.ChoiceOptions = new string[] { "Red", "Green", "Blue" };
// Set the default selected value of the combo field
combo.FieldValue = "Red";
// Set the width of the field
combo.FormWidth = 80;
// Set the height of the field
combo.FormHeight = 20;
// Add the combo form field to the paragraphs collection of the section
sec1.Paragraphs.Add(combo);
dataDir = dataDir + "ManipulatingFormFields_out.pdf";
// Save the Pdf
pdf1.Save(dataDir);
// For complete examples and data files, please go to https://github.com/aspose-pdf/Aspose.Pdf-for-.NET
// The path to the documents directory.
string dataDir = RunExamples.GetDataDir_AsposePdfGenerator_UtilityFeatures();
// Instantiate the Pdf document and add a section to it
Aspose.Pdf.Generator.Pdf pdf1 = new Aspose.Pdf.Generator.Pdf();
Aspose.Pdf.Generator.Section sec1 = pdf1.Sections.Add();
// Create a table, set its column widths and add it to paragraphs collection
// Of the section
Aspose.Pdf.Generator.Table tab1 = new Aspose.Pdf.Generator.Table();
tab1.ColumnWidths = "120 120 120";
sec1.Paragraphs.Add(tab1);
// Add a row to the table
Aspose.Pdf.Generator.Row r1 = tab1.Rows.Add();
// Add 1st cell to the row, set its padding and set the ID of the first paragraph
// In the cell to "text1"
Aspose.Pdf.Generator.Cell c1 = r1.Cells.Add("item1");
c1.Padding.Left = 30;
c1.Paragraphs[0].ID = "text1";
// Add 2nd cell to the row, set its padding and set the ID of the first paragraph
// In the cell to "text2"
Aspose.Pdf.Generator.Cell c2 = r1.Cells.Add("item2");
c2.Padding.Left = 30;
c2.Paragraphs[0].ID = "text2";
// Add 3rd cell to the row, set its padding and set the ID of the first paragraph
// In the cell to "text3"
Aspose.Pdf.Generator.Cell c3 = r1.Cells.Add("item3");
c3.Padding.Left = 30;
c3.Paragraphs[0].ID = "text3";
// Create a form field of RadioButton type. Set its field name and button color.
// Then set the index of the radio button value to be checked
Aspose.Pdf.Generator.FormField radio = new Aspose.Pdf.Generator.FormField();
radio.FormFieldType = Aspose.Pdf.Generator.FormFieldType.RadioButton;
radio.FieldName = "ARadio";
radio.ButtonColor = System.Drawing.Color.FromName("Red");
radio.RadioButtonCheckedIndex = 0;
// Create 1st radio button instance and add it to above created radio form field.
// Set its width and height. The position of the radio button is set to be
// Relative to the paragraph. Link this radio button with the paragraph with ID
// Equal to "text1".
Aspose.Pdf.Generator.RadioButton bt1 = radio.RadioButtons.Add();
bt1.ButtonHeight = 12;
bt1.ButtonWidth = 12;
bt1.PositioningType = Aspose.Pdf.Generator.PositioningType.ParagraphRelative;
bt1.ReferenceParagraphID = "text1";
bt1.Left = -20;
bt1.Top = 0;
// Create 2nd radio button instance and add it to above created radio form field.
// Set its width and height. The position of the radio button is set to be
// Relative to the paragraph. Link this radio button with the paragraph with ID
// Equal to "text2".
Aspose.Pdf.Generator.RadioButton bt2 = radio.RadioButtons.Add();
bt2.ButtonHeight = 12;
bt2.ButtonWidth = 12;
bt2.PositioningType = Aspose.Pdf.Generator.PositioningType.ParagraphRelative;
bt2.ReferenceParagraphID = "text2";
bt2.Left = -20;
bt2.Top = 0;
// Create 3rd radio button instance and add it to above created radio form field.
// Set its width and height. The position of the radio button is set to be
// Relative to the paragraph. Link this radio button with the paragraph with ID
// Equal to "text3".
Aspose.Pdf.Generator.RadioButton bt3 = radio.RadioButtons.Add();
bt3.ButtonHeight = 12;
bt3.ButtonWidth = 12;
bt3.PositioningType = Aspose.Pdf.Generator.PositioningType.ParagraphRelative;
bt3.ReferenceParagraphID = "text3";
bt3.Left = -20;
bt3.Top = 0;
// Add the radio form field to the paragraphs collection of the section
sec1.Paragraphs.Add(radio);
dataDir = dataDir + "RadioButtonWithCustomPosition_out.pdf";
// Save the Pdf
pdf1.Save(dataDir);
// For complete examples and data files, please go to https://github.com/aspose-pdf/Aspose.Pdf-for-.NET
// The path to the documents directory.
string dataDir = RunExamples.GetDataDir_AsposePdfGenerator_UtilityFeatures();
// Instantiate Pdf instance by calling its empty constructor
Aspose.Pdf.Generator.Pdf pdf1 = new Aspose.Pdf.Generator.Pdf();
// Create a section in the Pdf document
Aspose.Pdf.Generator.Section sec1 = pdf1.Sections.Add();
// Add four headings in the section
for (int Level = 1; Level != 5; Level++)
{
Aspose.Pdf.Generator.Heading heading2 = new Aspose.Pdf.Generator.Heading(pdf1, sec1, Level);
Aspose.Pdf.Generator.Segment segment2 = new Aspose.Pdf.Generator.Segment(heading2);
heading2.Segments.Add(segment2);
heading2.IsAutoSequence = true;
segment2.Content = "this is heading of level ";
segment2.Content += Level.ToString();
// Add the heading into Table Of Contents.
heading2.IsInList = true;
sec1.Paragraphs.Add(heading2);
}
// Create a graph and add a curve shape to its shapes collection
Aspose.Pdf.Generator.Graph graph1 = new Aspose.Pdf.Generator.Graph(sec1, 100, 400);
sec1.Paragraphs.Add(graph1);
float[] posArr = new float[] { 0, 0, 200, 80, 300, 40, 350, 90 };
Aspose.Pdf.Generator.Curve curve1 = new Aspose.Pdf.Generator.Curve(graph1, posArr);
graph1.Shapes.Add(curve1);
// Add the Graph to the List of Figures
graph1.IsInList = true;
dataDir = dataDir + "SpecifyListItem_out.pdf";
// Save the Pdf
pdf1.Save(dataDir);
// For complete examples and data files, please go to https://github.com/aspose-pdf/Aspose.Pdf-for-.NET
// The path to the documents directory.
string dataDir = RunExamples.GetDataDir_AsposePdfGenerator_WorkingDocuments();
// Instantiate a PDF Object
Aspose.Pdf.Generator.Pdf pdf = new Aspose.Pdf.Generator.Pdf();
// Add a section into the pdf document
Aspose.Pdf.Generator.Section section1 = pdf.Sections.Add();
// Create a sample text paragraph
Aspose.Pdf.Generator.Text text1 = new Aspose.Pdf.Generator.Text("This is a test for XMP Metadata");
// Add text paragraph to paragraphs collection of section object
section1.Paragraphs.Add(text1);
// Create XmpMetaData object
pdf.XmpMetadata = new Aspose.Pdf.Generator.XmpMetadata();
// Core properties
pdf.XmpMetadata.AddCreationDate(System.DateTime.Now.ToString());
// User properties
pdf.XmpMetadata.AddUserProperty("xmlns:dc=\"http:// Purl.org/dc/elements/1.1/\"", "dc:contributor", "Aspose");
dataDir = dataDir + "AddingXMPMetaData_out.pdf";
// Save Pdf Document
pdf.Save(dataDir);
// For complete examples and data files, please go to https://github.com/aspose-pdf/Aspose.Pdf-for-.NET
// The path to the documents directory.
string dataDir = RunExamples.GetDataDir_AsposePdfGenerator_WorkingDocuments();
// Instantiate a PDF Object
Aspose.Pdf.Generator.Pdf pdf = new Aspose.Pdf.Generator.Pdf();
// Instantiate a Aspose PDF JavaScript Object
pdf.JavaScripts = new Aspose.Pdf.Generator.JavaScripts();
// Call the Add method and pass JavaScript statement as an argument, to show Print Dialog
pdf.JavaScripts.Add("this.print(true);");
// Call the Add method and JavaScript statement as an argument, to show alert
pdf.JavaScripts.Add("app.alert(\"hello world\");");
dataDir = dataDir + "AddJavaScript_out.pdf";
// Save Pdf Document
pdf.Save(dataDir);
// For complete examples and data files, please go to https://github.com/aspose-pdf/Aspose.Pdf-for-.NET
// The path to the documents directory.
string dataDir = RunExamples.GetDataDir_AsposePdfGenerator_WorkingDocuments();
// Instantiate Pdf instance
Aspose.Pdf.Generator.Pdf pdf1 = new Aspose.Pdf.Generator.Pdf();
// Set OpenType property of Pdf instance to any pre-defined value
pdf1.OpenType = Aspose.Pdf.Generator.OpenType.Thumbnails;
dataDir = dataDir + "SetAppearance_out.pdf";
pdf1.Save(dataDir);
// For complete examples and data files, please go to https://github.com/aspose-pdf/Aspose.Pdf-for-.NET
// The path to the documents directory.
string dataDir = RunExamples.GetDataDir_AsposePdfGenerator_WorkingDocuments();
// Instantiate Pdf instance by calling its empty constructor
Aspose.Pdf.Generator.Pdf pdf1 = new Aspose.Pdf.Generator.Pdf();
// Set the properties of Pdf instance
pdf1.Author = "Naeem Akram";
pdf1.Creator = "Aspose.Pdf";
pdf1.Keywords = "Hello World";
pdf1.Subject = "Example";
pdf1.Title = "Example";
dataDir = dataDir + "DocInfo_out.pdf";
pdf1.Save(dataDir);
// For complete examples and data files, please go to https://github.com/aspose-pdf/Aspose.Pdf-for-.NET
// The path to the documents directory.
string dataDir = RunExamples.GetDataDir_AsposePdfGenerator_WorkingDocuments();
// Instantiate Pdf instance
Aspose.Pdf.Generator.Pdf pdf1 = new Aspose.Pdf.Generator.Pdf();
// You may set OpenType poperty to full screen
pdf1.OpenType = Aspose.Pdf.Generator.OpenType.FullScreen;
// Set PageTransitionType poperty of Pdf instance to a pre-defined desired value
pdf1.PageTransitionType = Aspose.Pdf.Generator.PageTransitionType.Dissolve;
dataDir = dataDir + "PageTransition_out.pdf";
pdf1.Save(dataDir);
// For complete examples and data files, please go to https://github.com/aspose-pdf/Aspose.Pdf-for-.NET
// The path to the documents directory.
string dataDir = RunExamples.GetDataDir_AsposePdfGenerator_WorkingDocuments();
// Instantiate Pdf instance
Aspose.Pdf.Generator.Pdf pdf1 = new Aspose.Pdf.Generator.Pdf();
// Set the DestinationType property of Pdf instance to any pre-defined value
pdf1.DestinationType = Aspose.Pdf.Generator.DestinationType.FitPage;
dataDir = dataDir + "ZoomFactor_out.pdf";
pdf1.Save(dataDir);
' For complete examples and data files, please go to https://github.com/aspose-pdf/Aspose.Pdf-for-.NET
' The path to the documents directory.
Dim dataDir As String = RunExamples.GetDataDir_AsposePdfGenerator_AdvanceFeatures()
' Instantiate Pdf instance by calling its empty constructor
Dim pdf1 As New Aspose.Pdf.Generator.Pdf()
' Add a section in the Pdf
Dim sec1 As Aspose.Pdf.Generator.Section = pdf1.Sections.Add()
' Set the page border of the section using BorderInfo object
sec1.PageInfo.PageBorder = New Aspose.Pdf.Generator.BorderInfo(CInt(Aspose.Pdf.Generator.BorderSide.All), 0.2F)
' Set the left margin of page border of the section
sec1.PageInfo.PageBorderMargin.Left = 20
' Add a text paragraph to the paragraphs collection of the section
sec1.Paragraphs.Add(New Aspose.Pdf.Generator.Text("Hello World"))
dataDir = dataDir & Convert.ToString("AddPageBorder_out_.pdf")
' Save the Pdf
pdf1.Save(dataDir)
' For complete examples and data files, please go to https://github.com/aspose-pdf/Aspose.Pdf-for-.NET
' The implementation of createDataTable method that is being called in the program
Public Shared Function creatDataTable() As DataTable
' Creating a DataTable object
Dim dt As New DataTable("Sample")
' Adding columns to the DataTable
dt.Columns.Add("Beginning of lease", GetType(Int32))
dt.Columns.Add("End of lease", GetType(Int32))
dt.Columns.Add("Landlord' S end-of-lease assessment", GetType(String))
dt.Columns.Add("Comments", GetType(String))
' Adding rows to the DataTable
Dim dr As DataRow = dt.NewRow()
dr(0) = 12
dr(1) = 11
dr(2) = "$32.38"
dr(3) = "M"
dt.Rows.Add(dr)
dr = dt.NewRow()
dr(0) = 22
dr(1) = 22
dr(2) = "$148.45"
dr(3) = "G"
dt.Rows.Add(dr)
dr = dt.NewRow()
dr(0) = 41
dr(1) = 41
dr(2) = "$11.42"
dr(3) = "S,R"
dt.Rows.Add(dr)
dr = dt.NewRow()
dr(0) = 47
dr(1) = 40
dr(2) = "$48.52"
dr(3) = "D"
dt.Rows.Add(dr)
dr = dt.NewRow()
dr(0) = 28
dr(1) = 20
dr(2) = "$78.43"
dr(3) = "R"
dt.Rows.Add(dr)
' Returning the instance of DataTable object
Return dt
End Function
' For complete examples and data files, please go to https://github.com/aspose-pdf/Aspose.Pdf-for-.NET
' The path to the documents directory.
Dim dataDir As String = RunExamples.GetDataDir_AsposePdfGenerator_AdvanceFeatures()
' Creating a new Pdf object
Dim pdf As New Aspose.Pdf.Generator.Pdf()
' Binding the content from the named XML file
pdf.BindXML(dataDir & Convert.ToString("Sample.xml"), Nothing)
' In a real scenario, data is usually input from Database. So, we can get data
' From a database. In this case, we are using a method that will provide us an
' Instance of DataTable. The implementation of this method is also given below.
Dim getDT As DataTable = creatDataTable()
' Accessing a table through its ID
Dim contenTable As Aspose.Pdf.Generator.Table = DirectCast(pdf.GetObjectByID("Content"), Aspose.Pdf.Generator.Table)
' Importing data from a DataTable and filling the table in PDF document
contenTable.ImportDataTable(getDT, False, 1, 1, 5, 4)
' Saving the results
pdf.Save(dataDir & Convert.ToString("Sample_out_.pdf"))
' For complete examples and data files, please go to https://github.com/aspose-pdf/Aspose.Pdf-for-.NET
' The path to the documents directory.
Dim dataDir As String = RunExamples.GetDataDir_AsposePdfGenerator_AdvanceFeatures()
Dim fs1 As New FileStream(dataDir & Convert.ToString("XSLFOToPDF.xml"), FileMode.Open)
Dim fs2 As New FileStream(dataDir & Convert.ToString("XSLFOToPDF.xsl"), FileMode.Open)
' Instantiate the Pdf instance
Dim pdf1 As New Aspose.Pdf.Generator.Pdf()
' Bind the XML and XSLT file
pdf1.BindXML(fs1, fs2)
' Save the resultant PDF
pdf1.Save(dataDir & Convert.ToString("XMlXSLTMERGE_out_.pdf"))
fs1.Close()
fs2.Close()
' For complete examples and data files, please go to https://github.com/aspose-pdf/Aspose.Pdf-for-.NET
' The path to the documents directory.
Dim dataDir As String = RunExamples.GetDataDir_AsposePdfGenerator_AdvanceFeatures()
' Instantiate Pdf instance by calling its empty constructor
Dim pdf1 As New Aspose.Pdf.Generator.Pdf()
Dim stream As New MemoryStream()
Dim Response As New HttpResponse(Nothing)
pdf1.Save(stream)
Response.Clear()
Response.ClearHeaders()
Response.ClearContent()
Response.Charset = "UTF-8"
Response.AddHeader("Content-Length", stream.Length.ToString())
Response.AddHeader("content-disposition", [String].Format("attachment;filename={0}", dataDir & Convert.ToString("SendingPdfToBrowser.pdf")))
Response.ContentType = "application/pdf"
Response.BinaryWrite(stream.ToArray())
Response.Flush()
Response.[End]()
' For complete examples and data files, please go to https://github.com/aspose-pdf/Aspose.Pdf-for-.NET
' The path to the documents directory.
Dim dataDir As String = RunExamples.GetDataDir_AsposePdfGenerator_AdvanceFeatures()
' Instantiate Pdf instance by calling its empty constructor
Dim pdf1 As New Aspose.Pdf.Generator.Pdf()
' Add a section in the Pdf
Dim sec1 As Aspose.Pdf.Generator.Section = pdf1.Sections.Add()
' Create a table object and add it to the paragraphs collection of the section
Dim tab1 As New Aspose.Pdf.Generator.Table()
sec1.Paragraphs.Add(tab1)
' Set the column widths and default cell border of the table
tab1.ColumnWidths = "60 100 100"
tab1.DefaultCellBorder = New Aspose.Pdf.Generator.BorderInfo(CInt(Aspose.Pdf.Generator.BorderSide.All), 1.0F)
' Prepare an array of string values to be added to table
Dim darr As String() = New String() {"Owner/Marketing Assistant", "dhasf hh ddt", "dhaosdha djsd dsads", "dsd dajd", "hdsah jj jj jdj", "ddfa jjj jhdusa"}
' Import the contents of the array created in above step
tab1.ImportArray(darr, 0, 0, True)
' Call GetMinColumnWidth and pass the column number whose minimum width is needed
Dim width As Single = tab1.GetMinColumnWidth(pdf1, 0)
' Call SetColumnWidth and pass the column number with minimum width
tab1.SetColumnWidth(0, width)
dataDir = dataDir & Convert.ToString("TableMinimumColumnWidth_out_.pdf")
' Save the Pdf
pdf1.Save(dataDir)
' For complete examples and data files, please go to https://github.com/aspose-pdf/Aspose.Pdf-for-.NET
' The path to the documents directory.
Dim dataDir As String = RunExamples.GetDataDir_AsposePdfGenerator_AdvanceFeatures()
' Create a Pdf instance and bind the XML template file to Pdf instance
Dim pdf1 As New Aspose.Pdf.Generator.Pdf()
pdf1.BindXML(dataDir & Convert.ToString("Template.xml"), Nothing)
' Get the section and then table from the obtained section of the Pdf that
' Is built from the XML template
Dim sec1 As Aspose.Pdf.Generator.Section = pdf1.Sections("Section1")
Dim table1 As Aspose.Pdf.Generator.Table = TryCast(sec1.Paragraphs("Table1"), Aspose.Pdf.Generator.Table)
' Clone a new table
Dim table2 As Aspose.Pdf.Generator.Table = TryCast(table1.CompleteClone(), Aspose.Pdf.Generator.Table)
' Change the ID of table2 to "Table2" to make it different from table1
table2.ID = "Table2"
' Add table2 into the section
sec1.Paragraphs.Add(table2)
' Now there are 2 segments with ID "Item",
' We change the IDs to make sure they are different
Dim item As Aspose.Pdf.Generator.Segment = TryCast(sec1.GetObjectByID("Item"), Aspose.Pdf.Generator.Segment)
item.ID = "Item1"
item = TryCast(sec1.GetObjectByID("Item"), Aspose.Pdf.Generator.Segment)
item.ID = "Item2"
' Change the content
item.Content = "item 2"
' Now clone section1
Dim sec2 As Aspose.Pdf.Generator.Section = TryCast(sec1.CompleteClone(), Aspose.Pdf.Generator.Section)
' Add a cloned section to the Pdf and change the contents of the text segments
' In the section2 of the Pdf object
pdf1.Sections.Add(sec2)
item = TryCast(sec2.GetObjectByID("Item1"), Aspose.Pdf.Generator.Segment)
item.Content = "item1 sec2"
item = TryCast(sec2.GetObjectByID("Item2"), Aspose.Pdf.Generator.Segment)
item.Content = "item2 sec2"
' Save the Pdf
pdf1.Save(dataDir & Convert.ToString("XmlTemp_out_.pdf"))
' For complete examples and data files, please go to https://github.com/aspose-pdf/Aspose.Pdf-for-.NET
' The path to the documents directory.
Dim dataDir As String = RunExamples.GetDataDir_AsposePdfGenerator_AdvanceFeatures()
Dim xmlDoc As New XmlDocument()
Dim ms As New MemoryStream()
Dim xsl As New XslCompiledTransform()
xsl.Load(dataDir & Convert.ToString("test.xsl"))
xsl.Transform(xmlDoc, Nothing, ms)
ms.Position = 0
xmlDoc.Load(ms)
ms.Close()
' Instantiate the Pdf instance
Dim pdf1 As New Aspose.Pdf.Generator.Pdf()
' Bind the XML file
pdf1.BindXML(xmlDoc, Nothing)
' Save the resultant PDF
' For complete examples and data files, please go to https://github.com/aspose-pdf/Aspose.Pdf-for-.NET
' The path to the documents directory.
Dim dataDir As String = RunExamples.GetDataDir_AsposePdfGenerator_Attachments()
' Instantiate Pdf document object
Dim pdf1 As New Aspose.Pdf.Generator.Pdf()
' Create a section in the Pdf
Dim sec1 As Aspose.Pdf.Generator.Section = pdf1.Sections.Add()
' Instantiate attachment instance by calling its empty constructor
Dim fileAttachment As New Aspose.Pdf.Generator.Attachment()
' Add attachment in the paragraphs collection of the section
sec1.Paragraphs.Add(fileAttachment)
' Set attachment type to File using AttachmentType enumeration
fileAttachment.AttachmentType = Aspose.Pdf.Generator.AttachmentType.File
' Set the path of the attachment file. This could be any file like doc, tif etc
fileAttachment.AttachedFileName = dataDir & Convert.ToString("input.pdf")
' Set the type of the file to be attached
fileAttachment.AttachedFileType = "pdf"
' Set the file icon type to Graph
fileAttachment.FileIconType = Aspose.Pdf.Generator.FileIconType.Graph
' Set the color of the icon to Brown
fileAttachment.IconColor = New Aspose.Pdf.Generator.Color("Brown")
dataDir = dataDir & Convert.ToString("AttachAnyFile_out_.pdf")
' Save the Pdf
pdf1.Save(dataDir)
' For complete examples and data files, please go to https://github.com/aspose-pdf/Aspose.Pdf-for-.NET
' The path to the documents directory.
Dim dataDir As String = RunExamples.GetDataDir_AsposePdfGenerator_Attachments()
' Instantiate Pdf document object
Dim pdf1 As New Aspose.Pdf.Generator.Pdf()
' Create a section in the Pdf
Dim sec1 As Aspose.Pdf.Generator.Section = pdf1.Sections.Add()
' Instantiate attachment instance
Dim noteAttachment As New Aspose.Pdf.Generator.Attachment()
' Add the attachment in the paragraphs collection of the section
sec1.Paragraphs.Add(noteAttachment)
' Set the attachment type to note to make it a note annotation
noteAttachment.AttachmentType = Aspose.Pdf.Generator.AttachmentType.Note
' Set the content of the note annotation
noteAttachment.NoteContent = "This is a note."
' Set the title or heading of the note
noteAttachment.NoteHeading = "The title"
' Set the note to be opened when PDF document is opened
noteAttachment.IsNoteOpen = True
dataDir = dataDir & Convert.ToString("AttachNoteAnnotation_out_.pdf")
' Save the Pdf
pdf1.Save(dataDir)
' For complete examples and data files, please go to https://github.com/aspose-pdf/Aspose.Pdf-for-.NET
' The path to the documents directory.
Dim dataDir As String = RunExamples.GetDataDir_AsposePdfGenerator_Attachments()
' Instantiate Pdf document object
Dim pdf1 As New Aspose.Pdf.Generator.Pdf()
' Create a section in the Pdf
Dim sec1 As Aspose.Pdf.Generator.Section = pdf1.Sections.Add()
' Instantiate attachment instance by calling its empty constructor
Dim noteAttachment As New Aspose.Pdf.Generator.Attachment()
' Add the attachment in the paragraphs collection of the section
sec1.Paragraphs.Add(noteAttachment)
' Set the attachment type to Note
noteAttachment.AttachmentType = Aspose.Pdf.Generator.AttachmentType.Note
' Store some content for the note to display
noteAttachment.NoteContent = "This is a test for note popup window positioning."
' Set the heading or title of the note
noteAttachment.NoteHeading = "Test"
' Set the note to be opened when PDF document is opened
noteAttachment.IsNoteOpen = True
' Set the positioning type of the note' S popup window to Absolute
noteAttachment.NoteWindowPositioningType = Aspose.Pdf.Generator.NoteWindowPositioningType.Absolute
' Set the position of the note' S popup window
noteAttachment.NoteWindowPosition = New Aspose.Pdf.Generator.RectangleArea(100, 100, 160, 100)
dataDir = dataDir & Convert.ToString("CustomizeNotePosition_out_.pdf")
' Save the Pdf
pdf1.Save(dataDir)
' For complete examples and data files, please go to https://github.com/aspose-pdf/Aspose.Pdf-for-.NET
' The path to the documents directory.
Dim dataDir As String = RunExamples.GetDataDir_AsposePdfGenerator_Conversion()
' Instantiate an object PDF class
Dim pdf As New Aspose.Pdf.Generator.Pdf()
' Add the section to PDF document sections collection
Dim section As Aspose.Pdf.Generator.Section = pdf.Sections.Add()
' Read the contents of HTML file into StreamReader object
Dim r As StreamReader = File.OpenText(dataDir & Convert.ToString("resultant.html"))
' Create text paragraphs containing HTML text
Dim text2 As New Aspose.Pdf.Generator.Text(section, r.ReadToEnd())
' Enable the property to display HTML contents within their own formatting
text2.IsHtmlTagSupported = True
text2.IfHtmlTagSupportedOverwriteHtmlFontNames = True
text2.IfHtmlTagSupportedOverwriteHtmlFontSizes = True
' Add the text paragraphs containing HTML text to the section
section.Paragraphs.Add(text2)
' Specify the URL which serves as images database
pdf.HtmlInfo.ImgUrl = dataDir
' Following properties are added from Aspose.Pdf for .NET 8.4.0
pdf.HtmlInfo.BadHtmlHandlingStrategy = BadHtmlHandlingStrategy.TreatAsPlainText
pdf.HtmlInfo.ShowUnknownHtmlTagsAsText = True
' Save the Pdf document
pdf.Save(dataDir & Convert.ToString("HTML2pdf_out_.pdf"))
' For complete examples and data files, please go to https://github.com/aspose-pdf/Aspose.Pdf-for-.NET
text2.IfHtmlTagSupportedOverwriteHtmlFontNames = True
text2.IfHtmlTagSupportedOverwriteHtmlFontSizes = True
' For complete examples and data files, please go to https://github.com/aspose-pdf/Aspose.Pdf-for-.NET
' Following properties are added from Aspose.Pdf for .NET 8.4.0
pdf.HtmlInfo.BadHtmlHandlingStrategy = BadHtmlHandlingStrategy.TreatAsPlainText
pdf.HtmlInfo.ShowUnknownHtmlTagsAsText = True
' For complete examples and data files, please go to https://github.com/aspose-pdf/Aspose.Pdf-for-.NET
' The path to the documents directory.
Dim dataDir As String = RunExamples.GetDataDir_AsposePdfGenerator_Conversion()
' Instantiate Pdf object
Dim pdf As New Aspose.Pdf.Generator.Pdf()
' Specify the Character encoding for HTML file
pdf.HtmlInfo.CharSet = "UTF-8"
pdf.HtmlInfo.CharsetApplyingLevelOfForce = HtmlInfo.CharsetApplyingForceLevel.EnforceUseAlways
' Load the HTML file to Stream object
Using htmlAsStream As Stream = System.IO.File.OpenRead(dataDir & Convert.ToString("resultant.html"))
' Bind the source HTML
pdf.BindHTML(htmlAsStream, "")
End Using
' Save the PDF file
pdf.Save(dataDir & Convert.ToString("EnforceUseAlways_out_.pdf"))
' For complete examples and data files, please go to https://github.com/aspose-pdf/Aspose.Pdf-for-.NET
' The path to the documents directory.
Dim dataDir As String = RunExamples.GetDataDir_AsposePdfGenerator_Conversion()
' Instantiate Pdf object
Dim pdf As New Aspose.Pdf.Generator.Pdf()
' Specify the Character encoding for HTML file
pdf.HtmlInfo.CharSet = "UTF-8"
pdf.HtmlInfo.CharsetApplyingLevelOfForce = HtmlInfo.CharsetApplyingForceLevel.UseWhenImpossibleDetectFromContent
' Load the HTML file to Stream object
Using htmlAsStream As Stream = System.IO.File.OpenRead(dataDir & Convert.ToString("resultant.html"))
' Bind the source HTML
pdf.BindHTML(htmlAsStream, "")
End Using
' Save the PDF file
pdf.Save(dataDir & Convert.ToString("HTMLToPDFUsingStream_out_.pdf"))
' For complete examples and data files, please go to https://github.com/aspose-pdf/Aspose.Pdf-for-.NET
' The path to the documents directory.
Dim dataDir As String = RunExamples.GetDataDir_AsposePdfGenerator_Conversion()
' Instantiate Pdf object
Dim pdf As New Aspose.Pdf.Generator.Pdf()
' Bind the source PCL file
pdf.BindPCL(dataDir & Convert.ToString("hidetext.pcl"))
' Save the resultant PDF document
pdf.Save(dataDir & Convert.ToString("PCLToPDF_out_.pdf"))
' For complete examples and data files, please go to https://github.com/aspose-pdf/Aspose.Pdf-for-.NET
' The path to the documents directory.
Dim dataDir As String = RunExamples.GetDataDir_AsposePdfGenerator_Conversion()
' Instantiate Pdf object
Dim pdf As New Aspose.Pdf.Generator.Pdf()
' Bind the source SVG file
pdf.BindSvg(dataDir & Convert.ToString("SVGToPDF.svg"))
' Save the resultant PDF document
pdf.Save(dataDir & Convert.ToString("SVGToPDF_out_.pdf"))
' For complete examples and data files, please go to https://github.com/aspose-pdf/Aspose.Pdf-for-.NET
' The path to the documents directory.
Dim dataDir As String = RunExamples.GetDataDir_AsposePdfGenerator_Conversion()
' The address of the web URL which you need to convert into PDF format
Dim WebUrl As String = "http://en.wikipedia.org/wiki/Main_Page"
' Create a Web Request object to connect to remote URL
Dim request As HttpWebRequest = DirectCast(WebRequest.Create(WebUrl), HttpWebRequest)
' Set the Web Request timeout
request.Timeout = 10000
' 10 secs
' Retrieve request info headers
Dim localWebResponse As HttpWebResponse = DirectCast(request.GetResponse(), HttpWebResponse)
' Windows default Code Page (Include System.Text namespace in project)
Dim encoding__1 As Encoding = Encoding.GetEncoding(1252)
' Read the contents of into StreamReader object
Dim localResponseStream As New StreamReader(localWebResponse.GetResponseStream(), encoding__1)
' Instantiate an object PDF class
Dim pdf As New Aspose.Pdf.Generator.Pdf()
' Add the section to PDF document sections collection
Dim section As Aspose.Pdf.Generator.Section = pdf.Sections.Add()
' Create text paragraphs containing HTML text
Dim text2 As New Aspose.Pdf.Generator.Text(section, localResponseStream.ReadToEnd())
' Enable the property to display HTML contents within their own formatting
text2.IsHtmlTagSupported = True
' Add the text object containing HTML contents to PD Sections
section.Paragraphs.Add(text2)
' Specify the URL which serves as images database
' Pdf.HtmlInfo.ImgUrl = "http://en.wikipedia.org/";
' Save the pdf document
pdf.Save(dataDir & Convert.ToString("WebToPDF_out_.pdf"))
localWebResponse.Close()
localResponseStream.Close()
' For complete examples and data files, please go to https://github.com/aspose-pdf/Aspose.Pdf-for-.NET
' The path to the documents directory.
Dim dataDir As String = RunExamples.GetDataDir_AsposePdfGenerator_Conversion()
' Set up your product license.
' If you just want to evaluate Aspose.Pdf, you can annotate these two lines.
' License license = new License();
' License.SetLicense(dataDir + "Aspose.Total.lic");
' Create a Converter object..
Dim app As Aspose.Pdf.Generator.Pdf
Dim pdf As System.IO.Stream
Dim name As String = "XSLFOToPDF"
Dim fo As String = (dataDir & name) + ".fo"
Dim xml As String = (dataDir & name) + ".xml"
Dim xsl As String = (dataDir & name) + ".xsl"
' Create the XmlDocument.
Dim doc_fo As New XmlDocument()
doc_fo.Load(New StreamReader(fo))
Dim doc_xml As New XPathDocument(xml)
Dim doc_xsl As New XmlDocument()
doc_xsl.Load(New StreamReader(xsl))
' 1. fo:string2string
app = New Aspose.Pdf.Generator.Pdf()
app.BindFO(fo)
app.Save((dataDir & name) + "_fo_sring2string.pdf")
' 2. fo:string2stream
app = New Aspose.Pdf.Generator.Pdf()
app.BindFO(fo)
pdf = New System.IO.FileStream(name & Convert.ToString("_fo_string2stream.pdf"), System.IO.FileMode.Create)
app.Save(pdf)
' 3. fo:stream2string
app = New Aspose.Pdf.Generator.Pdf()
app.BindFO(doc_fo, doc_xsl)
app.Save((dataDir & name) + "_fo_stream2string.pdf")
' 4. fo:stream2stream
app = New Aspose.Pdf.Generator.Pdf()
app.BindFO(doc_fo, doc_xsl)
pdf = New System.IO.FileStream(name & Convert.ToString("_fo_stream2stream.pdf"), System.IO.FileMode.Create)
app.Save(pdf)
' 5. fo:doc2string
app = New Aspose.Pdf.Generator.Pdf()
app.BindFO(doc_fo)
app.Save((dataDir & name) + "_fo_doc2string.pdf")
' 6. fo:doc2stream
app = New Aspose.Pdf.Generator.Pdf()
app.BindFO(doc_fo)
pdf = New System.IO.FileStream(name & Convert.ToString("_fo_doc2stream.pdf"), System.IO.FileMode.Create)
app.Save(pdf)
' 7. xml:string2string
app = New Aspose.Pdf.Generator.Pdf()
app.BindFO(xml)
app.Save((dataDir & name) + "_xml_string2string.pdf")
' 8. xml:string2stream
app = New Aspose.Pdf.Generator.Pdf()
app.BindFO(xml)
', xsl);
pdf = New System.IO.FileStream(name & Convert.ToString("_xml_string2stream.pdf"), System.IO.FileMode.Create)
app.Save(pdf)
' 9. xml:doc2string
app = New Aspose.Pdf.Generator.Pdf()
app.BindFO(xml)
app.Save((dataDir & name) + "_xml_doc2string.pdf")
' 10. xml:doc2stream
app = New Aspose.Pdf.Generator.Pdf()
app.BindFO(xml)
pdf = New System.IO.FileStream(name & Convert.ToString("_xml_doc2stream.pdf"), System.IO.FileMode.Create)
app.Save(pdf)
' 0. An example of how to set the metadata of your generated pdf document
' If you do not want to set these tedious metadata of pdf, you can set the
' Second parameter of Save method to be "null" simply, as shown in above.
' At first create a IDictionary to contain your metadata.
Dim metadata As System.Collections.IDictionary = New System.Collections.Hashtable()
' Then set the various items.
' If you don' T set them, Aspose.Pdf.Fo will set default value.
' A. title of your pdf doc:
metadata.Add("Title", "New Title")
' B. author of your pdf doc:
metadata.Add("Author", "New Author")
' C. subject of your pdf doc:
metadata.Add("Subject", "New Subject")
' D. keywords of your pdf doc:
metadata.Add("Keywords", "New Key Words")
' E. creator of your pdf doc:
metadata.Add("Creator", "New Creator")
' F. producer of your pdf doc:
metadata.Add("Producer", "New Producer")
' Make this IDictionary be the parameter of Save method, and start converting.
app = New Aspose.Pdf.Generator.Pdf()
' App.FoMetaData = metadata;
app.BindFO(fo)
app.Save(dataDir & Convert.ToString("Test_out_.pdf"))
' For complete examples and data files, please go to https://github.com/aspose-pdf/Aspose.Pdf-for-.NET
' The path to the documents directory.
Dim dataDir As String = RunExamples.GetDataDir_AsposePdfGenerator_Conversion()
' Create pdf document
Dim pdf As New Aspose.Pdf.Generator.Pdf()
' Bind FO document with Pdf object
pdf.BindFO(dataDir & Convert.ToString("XSLFOToPDF.fo"))
' Save the PDF document
pdf.Save(dataDir & Convert.ToString("XSLFOToPDFUsingBind_out_.pdf"))
' For complete examples and data files, please go to https://github.com/aspose-pdf/Aspose.Pdf-for-.NET
' The path to the documents directory.
Dim dataDir As String = RunExamples.GetDataDir_AsposePdfGenerator_General()
' Instantiate Pdf instance by calling its empty constructor
Dim pdf1 As New APG.Pdf()
' Create section object and add it to sections collection of PDF
Dim sec1 As APG.Section = pdf1.Sections.Add()
' Create FloatingBox with 108 as width and 80 as height
Dim box1 As New APG.FloatingBox(108, 80)
' Add FloatingBox to paragraphs collection of section object
sec1.Paragraphs.Add(box1)
box1.BoxHorizontalPositioning = APG.BoxHorizontalPositioningType.Margin
box1.BoxHorizontalAlignment = APG.BoxHorizontalAlignmentType.Right
box1.BoxVerticalPositioning = APG.BoxVerticalPositioningType.Page
box1.BoxVerticalAlignment = APG.BoxVerticalAlignmentType.Center
' Add sample text string to paragraphs collection of FloatingBox object
box1.Paragraphs.Add(New APG.Text("Hello."))
dataDir = dataDir & Convert.ToString("FloatingBox_out_.pdf")
' Save the resultant PDF
' For complete examples and data files, please go to https://github.com/aspose-pdf/Aspose.Pdf-for-.NET
box1.BoxHorizontalPositioning = APG.BoxHorizontalPositioningType.Margin
box1.BoxHorizontalAlignment = APG.BoxHorizontalAlignmentType.Right
box1.BoxVerticalPositioning = APG.BoxVerticalPositioningType.Page
box1.BoxVerticalAlignment = APG.BoxVerticalAlignmentType.Center
' For complete examples and data files, please go to https://github.com/aspose-pdf/Aspose.Pdf-for-.NET
' The path to the documents directory.
Dim dataDir As String = RunExamples.GetDataDir_AsposePdfGenerator_General()
' Create pdf document
Dim pdf1 As New AP.Generator.Pdf()
' Instantiate License class and call its SetLicense method to use the license
Dim license As New AP.License()
license.SetLicense("Aspose.Pdf.lic")
' Add a section into the pdf document
Dim sec1 As AP.Generator.Section = pdf1.Sections.Add()
' Add a text paragraph into the section
sec1.Paragraphs.Add(New AP.Generator.Text("Hello World"))
dataDir = dataDir & Convert.ToString("HelloWorldUsingAPI_out_.pdf")
' Save the document
pdf1.Save(dataDir)
' For complete examples and data files, please go to https://github.com/aspose-pdf/Aspose.Pdf-for-.NET
' The path to the documents directory.
Dim dataDir As String = RunExamples.GetDataDir_AsposePdfGenerator_General()
' Create pdf document
Dim pdf1 As New AP.Generator.Pdf()
' Instantiate License class and call its SetLicense method to use the license
Dim license As New AP.License()
license.SetLicense("Aspose.Pdf.lic")
' Bind XML into the document
pdf1.BindXML(dataDir & Convert.ToString("HelloWorld.XML"), Nothing)
dataDir = dataDir & Convert.ToString("HelloWorldUsingXML_out_.pdf")
' Save the document
pdf1.Save(dataDir)
' For complete examples and data files, please go to https://github.com/aspose-pdf/Aspose.Pdf-for-.NET
' The path to the documents directory.
Dim dataDir As String = RunExamples.GetDataDir_AsposePdfGenerator_General()
' Create pdf document
Dim pdf1 As New AP.Generator.Pdf()
' Instantiate License class and call its SetLicense method to use the license
Dim license As New AP.License()
license.SetLicense("Aspose.Pdf.lic")
' Bind XML into the document
pdf1.BindXML(dataDir & Convert.ToString("HelloWorldUsingAPI.XML"), Nothing)
' Get the first Section from the PDF document
Dim sec1 As AP.Generator.Section = pdf1.Sections(0)
' Get the Text paragraph (whose ID is Text1) from the section
Dim text1 As AP.Generator.Text = TryCast(sec1.Paragraphs("Text1"), AP.Generator.Text)
' Add a text Segment to the text paragraph
text1.Segments.Add("Hello World")
dataDir = dataDir & Convert.ToString("HelloWorldUsingXMLAndAPI_out_.pdf")
' Save the document
pdf1.Save(dataDir)
' For complete examples and data files, please go to https://github.com/aspose-pdf/Aspose.Pdf-for-.NET
' The path to the documents directory.
Dim dataDir As String = RunExamples.GetDataDir_AsposePdfGenerator_General()
' Create pdf document
Dim pdf1 As New AP.Generator.Pdf()
' Instantiate License class and call its SetLicense method to use the license
Dim license As New AP.License()
license.SetLicense("Aspose.Pdf.lic")
' Bind XML and XSLT files to the document
pdf1.BindXML(dataDir & Convert.ToString("HelloWorldUsingXSLT.XML"), dataDir & Convert.ToString("HelloWorld.xslt"))
dataDir = dataDir & Convert.ToString("HelloWorldUsingXSLT_out_.pdf")
' Save the document
pdf1.Save(dataDir)
' For complete examples and data files, please go to https://github.com/aspose-pdf/Aspose.Pdf-for-.NET
' Specify the Horizontal Positioning type for FloatingBox as Margin
box1.BoxHorizontalPositioning = AP.Generator.BoxHorizontalPositioningType.Margin
' Set the left margin information as 200
box1.Left = 200
' Specify the Vertical Positioning type for FloatingBox object
box1.BoxVerticalPositioning = AP.Generator.BoxVerticalPositioningType.Page
' Set the Top margin information as 300
box1.Top = 300
' For complete examples and data files, please go to https://github.com/aspose-pdf/Aspose.Pdf-for-.NET
' The path to the documents directory.
Dim dataDir As String = RunExamples.GetDataDir_AsposePdfGenerator_General()
' Instantiate Pdf instance by calling its empty constructor
Dim pdf1 As New AP.Generator.Pdf()
' Create section object and add it to sections collection of PDF
Dim sec1 As AP.Generator.Section = pdf1.Sections.Add()
' Create FloatingBox with 108 as width and 80 as height
Dim box1 As New AP.Generator.FloatingBox(108, 80)
' Add FloatingBox to paragraphs collection of section object
sec1.Paragraphs.Add(box1)
' Specify the Horizontal Positioning type for FloatingBox as Margin
box1.BoxHorizontalPositioning = AP.Generator.BoxHorizontalPositioningType.Margin
' Set the left margin information as 200
box1.Left = 200
' Specify the Vertical Positioning type for FloatingBox object
box1.BoxVerticalPositioning = AP.Generator.BoxVerticalPositioningType.Page
' Set the Top margin information as 300
box1.Top = 300
' Add sample text string to paragraphs collection of FloatingBox object
box1.Paragraphs.Add(New AP.Generator.Text("Hello."))
dataDir = dataDir & Convert.ToString("PositionFloatingBox_out_.pdf")
' Save the resultant PDF
pdf1.Save(dataDir)
' For complete examples and data files, please go to https://github.com/aspose-pdf/Aspose.Pdf-for-.NET
' The path to the documents directory.
Dim dataDir As String = RunExamples.GetDataDir_AsposePdfGenerator_Graphs()
' Instantiate a Pdf document object
Dim pdf1 As New Aspose.Pdf.Generator.Pdf()
' Add a section to the Pdf document
Dim sec1 As Aspose.Pdf.Generator.Section = pdf1.Sections.Add()
' Create a graph object in the section with Width=100 and Height=400
Dim graph1 As New Aspose.Pdf.Generator.Graph(sec1, 100, 400)
' Add the graph object to the paragraphs collection of the section
sec1.Paragraphs.Add(graph1)
' Create an array containing the (X,Y) values of 4 control points
' Required to position a curve
Dim posArr As Single() = New Single() {0, 0, 200, 80, 300, 40, _
350, 90}
' Create a curve in the graph with the coordinates given as an array to
' The constructor of curve class
Dim curve1 As New Aspose.Pdf.Generator.Curve(graph1, posArr)
' Add the curve shape into the shapes collection of the graph
graph1.Shapes.Add(curve1)
dataDir = dataDir & Convert.ToString("GraphCoordinate_out_.pdf")
' Save the Pdf
pdf1.Save(dataDir)
' For complete examples and data files, please go to https://github.com/aspose-pdf/Aspose.Pdf-for-.NET
' The path to the documents directory.
Dim dataDir As String = RunExamples.GetDataDir_AsposePdfGenerator_Graphs()
' Instantiate Pdf document by calling its empty constructor
Dim pdf1 As New Aspose.Pdf.Generator.Pdf()
' Create a section in the Pdf document
Dim sec1 As Aspose.Pdf.Generator.Section = pdf1.Sections.Add()
' Create a graph in the section with Width=100 and Height=400
Dim graph1 As New Aspose.Pdf.Generator.Graph(sec1, 100, 400)
' Add the graph object to paragraphs collection of the section
sec1.Paragraphs.Add(graph1)
' Create a circle shape in the graph with X=200, Y=50 and Radius=30
Dim circle1 As New Aspose.Pdf.Generator.Circle(graph1, 200, 50, 30)
' Add the circle in the shapes collection of the graph
graph1.Shapes.Add(circle1)
' Set fill color of the circle using GraphInfo property of circle object
circle1.GraphInfo.FillColor = New Aspose.Pdf.Generator.Color("Green")
' Enable the circle to be filled with the color specified above line
circle1.GraphInfo.IsFilled = True
dataDir = dataDir & Convert.ToString("GraphFormat_out_.pdf")
' Save the Pdf
pdf1.Save(dataDir)
' For complete examples and data files, please go to https://github.com/aspose-pdf/Aspose.Pdf-for-.NET
' The path to the documents directory.
Dim dataDir As String = RunExamples.GetDataDir_AsposePdfGenerator_Graphs()
' Instantiate Pdf instance by calling its empty constructor
Dim pdf1 As New Aspose.Pdf.Generator.Pdf()
' Create a section in the Pdf document
Dim sec1 As Aspose.Pdf.Generator.Section = pdf1.Sections.Add()
' Create 1st graph in the section with width=100 and height=400
Dim graph1 As New Aspose.Pdf.Generator.Graph(sec1, 100, 400)
' Add 1st graph into the paragraphs collection of the section
sec1.Paragraphs.Add(graph1)
' Create a rectangle shape with specified coordinates
Dim rect1 As New Aspose.Pdf.Generator.Rectangle(graph1, 85, 100, 100, 50)
' Add the rectangle into the shapes collection of the 1st graph
graph1.Shapes.Add(rect1)
' Create 2nd graph in the section with width=100 and height=400
Dim graph2 As New Aspose.Pdf.Generator.Graph(sec1, 100, 400)
' Add 2nd graph into the paragraphs collection of the section
sec1.Paragraphs.Add(graph2)
' Create a rectangle shape with specified coordinates
Dim rect2 As New Aspose.Pdf.Generator.Rectangle(graph2, 85, 100, 100, 50)
' Add the rectangle into the shapes collection of the 2nd graph
graph2.Shapes.Add(rect2)
' Rotate the 2nd graph to 30 degree using RotationAngle property
graph2.GraphInfo.RotationAngle = 30
' Create 3rd graph in the section with width=100 and height=400
Dim graph3 As New Aspose.Pdf.Generator.Graph(sec1, 100, 400)
' Add 3rd graph into the paragraphs collection of the section
sec1.Paragraphs.Add(graph3)
' Create a rectangle shape with specified coordinates
Dim rect3 As New Aspose.Pdf.Generator.Rectangle(graph3, 85, 100, 100, 50)
' Add the rectangle into the shapes collection of the 3rd graph
graph3.Shapes.Add(rect3)
' Adjust the horizontal size of the 3rd graph using ScalingRateX property
graph3.GraphInfo.ScalingRateX = 1.5F
dataDir = dataDir & Convert.ToString("RotationAndScaling_out_.pdf")
' Save the Pdf
pdf1.Save(dataDir)
' For complete examples and data files, please go to https://github.com/aspose-pdf/Aspose.Pdf-for-.NET
' The path to the documents directory.
Dim dataDir As String = RunExamples.GetDataDir_AsposePdfGenerator_Headings()
' Instntiate the Pdf object by calling its empty constructor
Dim pdf1 As New Aspose.Pdf.Generator.Pdf()
' Create the section in the Pdf object
Dim sec1 As Aspose.Pdf.Generator.Section = pdf1.Sections.Add()
'
' * Create 1st heading in the Pdf object' S section with level=1. Then create
' * a text segment and add it in the heading. Set its numbering style to "Arab"
' * using HeadingType enumeration. And don' T forget to set IsAutoSequence=true.
' * If IsAutoSeguence property is set to true then the heading' S sequence is
' * controlled automatically by Aspose.Pdf. After setting all properties, add
' * heading into the paragraphs collection of the section
'
Dim heading1 As New Aspose.Pdf.Generator.Heading(pdf1, sec1, 1)
Dim segment1 As New Aspose.Pdf.Generator.Segment(heading1)
heading1.Segments.Add(segment1)
segment1.Content = "Arab"
heading1.HeadingType = Aspose.Pdf.Generator.HeadingType.Arab
heading1.IsAutoSequence = True
sec1.Paragraphs.Add(heading1)
'
' * Create 2nd heading in the Pdf object' S section with level=1. Then create
' * a text segment and add it in the heading. Set its numbering style to "RomanUpper"
' * using HeadingType enumeration. And don' T forget to set IsAutoSequence=true.
' * If IsAutoSeguence property is set to true then the heading' S sequence is
' * controlled automatically by Aspose.Pdf for .NET. After setting all properties, add
' * heading into the paragraphs collection of the section
'
Dim heading2 As New Aspose.Pdf.Generator.Heading(pdf1, sec1, 1)
Dim segment2 As New Aspose.Pdf.Generator.Segment(heading2)
heading2.Segments.Add(segment2)
segment2.Content = "RomanUpper"
heading2.HeadingType = Aspose.Pdf.Generator.HeadingType.RomanUpper
heading2.IsAutoSequence = True
sec1.Paragraphs.Add(heading2)
'
' * Create 3rd heading in the Pdf object' S section with level=1. Then create
' * a text segment and add it in the heading. Set its numbering style to "RomanLower"
' * using HeadingType enumeration. And don' T forget to set IsAutoSequence=true.
' * If IsAutoSeguence property is set to true then the heading' S sequence is
' * controlled automatically by Aspose.Pdf for .NET. After setting all properties, add
' * heading into the paragraphs collection of the section
'
Dim heading3 As New Aspose.Pdf.Generator.Heading(pdf1, sec1, 1)
Dim segment3 As New Aspose.Pdf.Generator.Segment(heading3)
heading3.Segments.Add(segment3)
segment3.Content = "RomanLower"
heading3.HeadingType = Aspose.Pdf.Generator.HeadingType.RomanLower
heading3.IsAutoSequence = True
sec1.Paragraphs.Add(heading3)
'
' * Create 4th heading in the Pdf object' S section with level=1. Then create a
' * text segment and add it in the heading. Set its numbering style to "EnglishUpper"
' * using HeadingType enumeration. And don' T forget to set IsAutoSequence=true.
' * If IsAutoSeguence property is set to true then the heading' S sequence is
' * controlled automatically by Aspose.Pdf for .NET. After setting all properties, add
' * heading into the paragraphs collection of the section
'
Dim heading4 As New Aspose.Pdf.Generator.Heading(pdf1, sec1, 1)
Dim segment4 As New Aspose.Pdf.Generator.Segment(heading4)
heading4.Segments.Add(segment4)
segment4.Content = "EnglishUpper"
heading4.HeadingType = Aspose.Pdf.Generator.HeadingType.EnglishUpper
heading4.IsAutoSequence = True
sec1.Paragraphs.Add(heading4)
'
' * Create 5th heading in the Pdf object' S section with level=1. Then create a
' * text segment and add it in the heading. Set its numbering style to "EnglishLower"
' * using HeadingType enumeration. And don' T forget to set IsAutoSequence=true.
' * If IsAutoSeguence property is set to true then the heading' S sequence is
' * controlled automatically by Aspose.Pdf for .NET. After setting all properties, add
' * heading into the paragraphs collection of the section
'
Dim heading5 As New Aspose.Pdf.Generator.Heading(pdf1, sec1, 1)
Dim segment5 As New Aspose.Pdf.Generator.Segment(heading5)
heading5.Segments.Add(segment5)
segment5.Content = "EnglishLower"
heading5.HeadingType = Aspose.Pdf.Generator.HeadingType.EnglishLower
heading5.IsAutoSequence = True
sec1.Paragraphs.Add(heading5)
pdf1.Save(dataDir & Convert.ToString("headings_out_.pdf"))
' For complete examples and data files, please go to https://github.com/aspose-pdf/Aspose.Pdf-for-.NET
' The path to the documents directory.
Dim dataDir As String = RunExamples.GetDataDir_AsposePdfGenerator_Headings()
' Instntiate the Pdf object by calling its empty constructor
Dim pdf1 As New Aspose.Pdf.Generator.Pdf()
' Create the section in the Pdf object
Dim sec1 As Aspose.Pdf.Generator.Section = pdf1.Sections.Add()
'
' * Create 1st heading in the Pdf object' S section with level=1. Then create
' * a text segment and add it in the heading. Set its StartNumber=6 to start
' * the numbering from 6 and onwards. And don' T forget to set IsAutoSequence=true.
' * If IsAutoSeguence property is set to true then the heading' S sequence is
' * controlled automatically by Aspose.Pdf for .NET. After setting all properties, add
' * heading into the paragraphs collection of the section
'
Dim heading1 As New Aspose.Pdf.Generator.Heading(pdf1, sec1, 1)
Dim segment1 As New Aspose.Pdf.Generator.Segment(heading1)
heading1.Segments.Add(segment1)
segment1.Content = "Level 1"
heading1.IsAutoSequence = True
heading1.StartNumber = 6
sec1.Paragraphs.Add(heading1)
'
' * Create 2nd heading in the Pdf object' S section with level=2. Then create
' * a text segment and add it in the heading. And don' T forget to set
' * IsAutoSequence=true.If IsAutoSeguence property is set to true then the
' * heading' S sequence is controlled automatically by Aspose.Pdf for .NET. After setting
' * all properties, add heading into the paragraphs collection of the section
'
Dim heading2 As New Aspose.Pdf.Generator.Heading(pdf1, sec1, 2)
Dim segment2 As New Aspose.Pdf.Generator.Segment(heading2)
heading2.Segments.Add(segment2)
segment2.Content = "Level 2"
heading2.IsAutoSequence = True
sec1.Paragraphs.Add(heading2)
'
' * Create 3rd heading in the Pdf object' S section with level=3. Then create
' * a text segment and add it in the heading. And don' T forget to set
' * IsAutoSequence=true.If IsAutoSeguence property is set to true then the
' * heading' S sequence is controlled automatically by Aspose.Pdf for .NET. After setting
' * all properties, add heading into the paragraphs collection of the section
'
Dim heading3 As New Aspose.Pdf.Generator.Heading(pdf1, sec1, 3)
Dim segment3 As New Aspose.Pdf.Generator.Segment(heading3)
heading3.Segments.Add(segment3)
segment3.Content = "Level 3"
heading3.IsAutoSequence = True
sec1.Paragraphs.Add(heading3)
pdf1.Save(dataDir & Convert.ToString("SpecifyHeadingLevel_out_.pdf"))
' For complete examples and data files, please go to https://github.com/aspose-pdf/Aspose.Pdf-for-.NET
' The path to the documents directory.
Dim dataDir As String = RunExamples.GetDataDir_AsposePdfGenerator_Headings()
' Instntiate the Pdf object by calling its empty constructor
Dim pdf1 As New Aspose.Pdf.Generator.Pdf()
' Create the section in the Pdf object
Dim sec1 As Aspose.Pdf.Generator.Section = pdf1.Sections.Add()
'
' * Create 1st heading in the Pdf object' S section with level=1. Then create
' * a text segment and add it in the heading. Set its UserLabel="Bullet1" to
' * use system defined bullet. After setting all properties, add heading into
' * the paragraphs collection of the section
'
Dim heading1 As New Aspose.Pdf.Generator.Heading(pdf1, sec1, 1)
Dim segment1 As New Aspose.Pdf.Generator.Segment(heading1)
heading1.Segments.Add(segment1)
segment1.Content = "Bullet1"
heading1.UserLabel = "Bullet1"
sec1.Paragraphs.Add(heading1)
'
' * Create 2nd heading in the Pdf object' S section with level=2. Then create
' * a text segment and add it in the heading. Set its UserLabel="Bullet2" to
' * use system defined bullet. After setting all properties, add heading into
' * the paragraphs collection of the section
'
Dim heading2 As New Aspose.Pdf.Generator.Heading(pdf1, sec1, 2)
Dim segment2 As New Aspose.Pdf.Generator.Segment(heading2)
heading2.Segments.Add(segment2)
segment2.Content = "Bullet2"
heading2.UserLabel = "Bullet2"
sec1.Paragraphs.Add(heading2)
'
' * Create 3rd heading in the Pdf object' S section with level=3. Then create
' * a text segment and add it in the heading. Set its UserLabel="Bullet3" to
' * use system defined bullet. After setting all properties, add heading into
' * the paragraphs collection of the section
'
Dim heading3 As New Aspose.Pdf.Generator.Heading(pdf1, sec1, 3)
Dim segment3 As New Aspose.Pdf.Generator.Segment(heading3)
heading3.Segments.Add(segment3)
segment3.Content = "Bullet3"
heading3.UserLabel = "Bullet3"
sec1.Paragraphs.Add(heading3)
pdf1.Save(dataDir & Convert.ToString("SystemBullets_out_.pdf"))
' For complete examples and data files, please go to https://github.com/aspose-pdf/Aspose.Pdf-for-.NET
' The path to the documents directory.
Dim dataDir As String = RunExamples.GetDataDir_AsposePdfGenerator_Headings()
' Instntiate the Pdf object by calling its empty constructor
Dim pdf1 As New Aspose.Pdf.Generator.Pdf()
' Create the section in the Pdf object
Dim sec1 As Aspose.Pdf.Generator.Section = pdf1.Sections.Add()
'
' * Create 1st heading in the Pdf object' S section with level=1. Then create a text
' * segment and add it in the heading. Set its UserLabel="98" to use a user defined
' * bullet. You must set BulletFontName to "Symbol" or "ZapfDingbats". After setting
' * all properties, add heading into the paragraphs collection of the section
'
Dim heading1 As New Aspose.Pdf.Generator.Heading(pdf1, sec1, 1)
Dim segment1 As New Aspose.Pdf.Generator.Segment(heading1)
heading1.Segments.Add(segment1)
segment1.Content = "Symbol"
heading1.BulletFontName = "Symbol"
heading1.UserLabel = "98"
sec1.Paragraphs.Add(heading1)
'
' * Create 2nd heading in the Pdf object' S section with level=2. Then create a text
' * segment and add it in the heading. Set its UserLabel="99" to use a user defined
' * bullet. You must set BulletFontName to "Symbol" or "ZapfDingbats". After setting
' * all properties, add heading into the paragraphs collection of the section
'
Dim heading2 As New Aspose.Pdf.Generator.Heading(pdf1, sec1, 2)
Dim segment2 As New Aspose.Pdf.Generator.Segment(heading2)
heading2.Segments.Add(segment2)
segment2.Content = "Symbol"
heading2.BulletFontName = "Symbol"
heading2.UserLabel = "99"
sec1.Paragraphs.Add(heading2)
'
' * Create 3rd heading in the Pdf object' S section with level=3. Then create a text
' * segment and add it in the heading. Set its UserLabel="100" to use a user defined
' * bullet. You must set BulletFontName to "Symbol" or "ZapfDingbats". After setting
' * all properties, add heading into the paragraphs collection of the section
'
Dim heading3 As New Aspose.Pdf.Generator.Heading(pdf1, sec1, 3)
Dim segment3 As New Aspose.Pdf.Generator.Segment(heading3)
heading3.Segments.Add(segment3)
segment3.Content = "Symbol"
heading3.BulletFontName = "Symbol"
heading3.UserLabel = "100"
sec1.Paragraphs.Add(heading3)
pdf1.Save(dataDir & Convert.ToString("UserDefinedBullets_out_.pdf"))
' For complete examples and data files, please go to https://github.com/aspose-pdf/Aspose.Pdf-for-.NET
' The path to the documents directory.
Dim dataDir As String = RunExamples.GetDataDir_AsposePdfGenerator_Images()
Dim faxImageFile As String = ""
If faxImageFile <> "" Then
' Instantiate a Pdf object by calling its empty constructor
Dim pdf1 As New Aspose.Pdf.Generator.Pdf()
' Create a section in the Pdf object
Dim sec1 As Aspose.Pdf.Generator.Section = pdf1.Sections.Add()
' Instantiate an image object
Dim img1 As New Aspose.Pdf.Generator.Image(sec1)
' Add image object into the Paragraphs collection of the section
sec1.Paragraphs.Add(img1)
' Set the path of image file
img1.ImageInfo.File = faxImageFile
' Set the file type of the image
img1.ImageInfo.ImageFileType = Aspose.Pdf.Generator.ImageFileType.Ccitt
' Set the image width
img1.ImageInfo.CcittImageWidth = 2560
' Set the image height
img1.ImageInfo.CcittImageHeight = 1779
' Set the sub-format of the ccitt image
img1.ImageInfo.CcittSubFormat = Aspose.Pdf.Generator.CcittSubFormat.Group31D
' Set the desired scaling of the image
img1.ImageScale = 0.1F
' For complete examples and data files, please go to https://github.com/aspose-pdf/Aspose.Pdf-for-.NET
' The path to the documents directory.
Dim dataDir As String = RunExamples.GetDataDir_AsposePdfGenerator_Images()
' Instantiate a Pdf object by calling its empty constructor
Dim pdf1 As New Aspose.Pdf.Generator.Pdf()
' Create a section in the Pdf object
Dim sec1 As Aspose.Pdf.Generator.Section = pdf1.Sections.Add()
' Create an image object in the section
Dim image1 As New Aspose.Pdf.Generator.Image(sec1)
' Add image object into the Paragraphs collection of the section
sec1.Paragraphs.Add(image1)
' Set the path of image file
image1.ImageInfo.File = dataDir & Convert.ToString("aspose-logo.jpg")
' Set the type of image using ImageFileType enumeration
image1.ImageInfo.ImageFileType = Aspose.Pdf.Generator.ImageFileType.Jpeg
' Set image title
image1.ImageInfo.Title = "JPEG image"
' Save the Pdf
pdf1.Save(dataDir & Convert.ToString("ImageFromLocalDisk_out_.pdf"))
' For complete examples and data files, please go to https://github.com/aspose-pdf/Aspose.Pdf-for-.NET
' The path to the documents directory.
Dim dataDir As String = RunExamples.GetDataDir_AsposePdfGenerator_General()
' Set the license for Aspose.Pdf
Dim license As New Aspose.Pdf.License()
license.SetLicense("Aspose.Custom.lic")
' Create a memory stream object
Dim mstream As New System.IO.MemoryStream()
' Instantiate a Pdf object
Dim pdf1 As New Aspose.Pdf.Generator.Pdf()
' Create a new section in the Pdf document
Dim sec1 As New Aspose.Pdf.Generator.Section(pdf1)
' Add the section in the sections collection of the Pdf document
pdf1.Sections.Add(sec1)
' Create an image object
Dim image1 As New Aspose.Pdf.Generator.Image(sec1)
' Add the image into paragraphs collection of the section
sec1.Paragraphs.Add(image1)
image1.ImageInfo.ImageFileType = Aspose.Pdf.Generator.ImageFileType.Bmp
' Set the ImageStream to a MemoryStream object
image1.ImageInfo.ImageStream = mstream
' Set desired the image scale
image1.ImageScale = 0.5F
' Save the Pdf
' For complete examples and data files, please go to https://github.com/aspose-pdf/Aspose.Pdf-for-.NET
' The path to the documents directory.
Dim dataDir As String = RunExamples.GetDataDir_AsposePdfGenerator_Images()
' Instantiate a Pdf object by calling its empty constructor
Dim pdf1 As New Aspose.Pdf.Generator.Pdf()
' Create a section in the Pdf object
Dim sec1 As Aspose.Pdf.Generator.Section = pdf1.Sections.Add()
' Create an image object in the section
Dim image1 As New Aspose.Pdf.Generator.Image(sec1)
' Add image object into the Paragraphs collection of the section
sec1.Paragraphs.Add(image1)
' Set the path of image file
image1.ImageInfo.File = "http://www.aspose.com/Images/Apple.jpg"
' Set the type of image using ImageFileType enumeration
image1.ImageInfo.ImageFileType = Aspose.Pdf.Generator.ImageFileType.Jpeg
' Set image title
image1.ImageInfo.Title = "JPEG image"
' Save the Pdf
pdf1.Save(dataDir & Convert.ToString("ImageFromLocalDisk_out_.pdf"))
' For complete examples and data files, please go to https://github.com/aspose-pdf/Aspose.Pdf-for-.NET
' The path to the documents directory.
Dim dataDir As String = RunExamples.GetDataDir_AsposePdfGenerator_Paragraphs()
' Instantiate Pdf object by calling its empty constructor and add a new section to the Pdf object
Dim pdf1 As New AP.Generator.Pdf()
Dim sec1 As AP.Generator.Section = pdf1.Sections.Add()
' Create a text paragraph with the reference of a section, sec1 and add the text paragraph in the section
Dim text3 As New AP.Generator.Text(sec1, "product 1 info ...")
sec1.Paragraphs.Add(text3)
' Set the text paragraph to be the first paragraph among the other ones
text3.IsFirstParagraph = True
' Assign and ID to the text paragraph
text3.ID = "product1"
dataDir = dataDir & Convert.ToString("AssignID_out_.pdf")
' Save the resultant PDF
pdf1.Save(dataDir)
' For complete examples and data files, please go to https://github.com/aspose-pdf/Aspose.Pdf-for-.NET
' The path to the documents directory.
Dim dataDir As String = RunExamples.GetDataDir_AsposePdfGenerator_Paragraphs()
' Instantiate Pdf instance by calling its empty constructor
Dim pdf1 As New AP.Generator.Pdf()
' Create a section in the Pdf document and add a text paragraph in the section
Dim sec1 As AP.Generator.Section = pdf1.Sections.Add() '
sec1.Paragraphs.Add(New AP.Generator.Text("page 1"))
' Create another text paragraph that has to be rendered
Dim t2 As New AP.Generator.Text("page2")
' Set the IsFirstParagraph property of the text paragraph to true to render it to a new page
t2.IsFirstParagraph = True
' Add the text paragraph to be rendered to the section
sec1.Paragraphs.Add(t2)
dataDir = dataDir & Convert.ToString("RenderParagraph_out_.pdf")
' Save the Pdf document
pdf1.Save(dataDir)
' For complete examples and data files, please go to https://github.com/aspose-pdf/Aspose.Pdf-for-.NET
' The path to the documents directory.
Dim dataDir As String = RunExamples.GetDataDir_AsposePdfGenerator_Paragraphs()
' Instantiate Pdf object by calling its empty constructor and add a new section to the Pdf object
Dim pdf1 As New AP.Generator.Pdf()
Dim sec1 As AP.Generator.Section = pdf1.Sections.Add()
' Instantiate a graph object, associate it with a section and pass the height & width of the graph
Dim g1 As New AP.Generator.Graph(sec1, 100, 100)
' Add a graph object to the paragraphs collection of the section
sec1.Paragraphs.Add(g1)
' Add a circle object to the shapes collection of graph object
g1.Shapes.Add(New AP.Generator.Circle(g1, 50, 50, 30))
' Instantiate another Graph object, associate it with a section and pass the height & width of the graph
Dim g2 As New AP.Generator.Graph(sec1, 100, 100)
' Set left and top margin values
g2.Margin.Left = 150
g2.Margin.Top = -100
' Add the paragraph object "g2" to paragraphs collection of the section
sec1.Paragraphs.Add(g2)
' Add a rectangle to the graph object (g2) in its shapes collection
g2.Shapes.Add(New AP.Generator.Rectangle(g2, 20, 20, 60, 60))
dataDir = dataDir & Convert.ToString("SetMargins_out_.pdf")
' Save the resultant PDF
pdf1.Save(dataDir)
' For complete examples and data files, please go to https://github.com/aspose-pdf/Aspose.Pdf-for-.NET
' The path to the documents directory.
Dim dataDir As String = RunExamples.GetDataDir_AsposePdfGenerator_Sections()
' Instantiate a PDF Object
Dim pdf1 As New AP.Generator.Pdf()
' Create a Section object by calling Add method of Sections collection of Pdf class
Dim sec1 As AP.Generator.Section = pdf1.Sections.Add()
' Instantiate First HeaderFooter object and pass the Section reference in which
' The header or footer is to be added
Dim hf1 As New AP.Generator.HeaderFooter(sec1)
' Set the header of odd pages of the PDF document
sec1.OddHeader = hf1
' Set the header of even pages of the PDF document
sec1.EvenHeader = hf1
' Enable this header for first page only
hf1.IsFirstPageOnly = True
' Add Distance From Edge Property to 80 unit Points
hf1.DistanceFromEdge = 80
' Set the First HeaderFooter, top and bottom property respectively
hf1.Margin.Bottom = 50
hf1.Margin.Top = 100
' Instantiate a Text paragraph that will store the content to show as header
Dim text As New AP.Generator.Text(hf1, "header for first page")
' Add the text object to the Paragraphs collection of HeaderFooter object to
' Display header on the pages of PDF document
hf1.Paragraphs.Add(text)
'
' *Second Header "hf2" for odd subsequent pages only
'
' Instantiate Second HeaderFooter object and pass the Section reference in which
' The header or footer is to be added
Dim hf2 As New AP.Generator.HeaderFooter(sec1)
' Set the additional header of odd pages of the PDF document
sec1.AdditionalOddHeader = hf2
' Enable this header for subsequent page only
hf2.IsSubsequentPagesOnly = True
' Add Distance From Edge Property of header to 150 unit Points
hf2.DistanceFromEdge = 150
hf2.Margin.Bottom = 70
' Instantiate a Text paragraph that will store the content to show as header
text = New AP.Generator.Text(hf2, "odd header for subsequent pages")
' Add the text object to the Paragraphs collection of HeaderFooter object to
' Display header on the pages of PDF document
hf2.Paragraphs.Add(text)
'
' *Third Header "hf3" for even subsequent pages only
'
' Instantiate Third HeaderFooter object and pass the Section reference in which
' The header or footer is to be added
Dim hf3 As New AP.Generator.HeaderFooter(sec1)
' Set the additional header of even pages of the PDF document
sec1.AdditionalEvenHeader = hf3
' Enable this header for subsequent page only
hf3.IsSubsequentPagesOnly = True
' Add the Distance from Edge for the third Header
hf3.DistanceFromEdge = 180
hf3.Margin.Top = 90
' Instantiate a Text paragraph that will store the content to show as header
text = New AP.Generator.Text(hf3, "even header for subsequent pages")
' Add the text object to the Paragraphs collection of HeaderFooter object to
' Display header on the pages of PDF document
hf3.Paragraphs.Add(text)
dataDir = dataDir & Convert.ToString("AdvancedHeaderAndFooter_out_.pdf")
' Save Pdf Document
pdf1.Save(dataDir)
' For complete examples and data files, please go to https://github.com/aspose-pdf/Aspose.Pdf-for-.NET
' Instantiate HeaderFooter object and pass the Section reference in which
' The header or footer is to be added
Dim hf1 As New AP.Generator.HeaderFooter(section1)
' Set the header of odd pages of the PDF document
section1.OddHeader = hf1
' Set the header of even pages of the PDF document
section1.EvenHeader = hf1
' Instantiate a Text paragraph that will store the content to show as header
Dim text As New AP.Generator.Text(hf1, "header")
' Add the text object to the Paragraphs collection of HeaderFooter object to
' Display header on the pages of PDF document
hf1.Paragraphs.Add(text)
' For complete examples and data files, please go to https://github.com/aspose-pdf/Aspose.Pdf-for-.NET
' The path to the documents directory.
Dim dataDir As String = RunExamples.GetDataDir_AsposePdfGenerator_Sections()
' Instantiate a PDF Object
Dim pdf As New AP.Generator.Pdf()
' Add a section into the pdf document
Dim section1 As AP.Generator.Section = pdf.Sections.Add()
' Assign the image file path to BackgroundImageFile property of section
section1.BackgroundImageFile = dataDir & Convert.ToString("aspose-logo.jpg")
' Set the image type using ImageFileType enumeration
section1.BackgroundImageType = AP.Generator.ImageFileType.Jpeg
dataDir = dataDir & Convert.ToString("SetPageBackgroundImage_out_.pdf")
' Save Pdf Document
pdf.Save(dataDir)
' For complete examples and data files, please go to https://github.com/aspose-pdf/Aspose.Pdf-for-.NET
' Instantiate the MarginInfo instance
Dim marginInfo As New AP.Generator.MarginInfo()
' Set the margin Top. This value is in points but other units like
' Inches and centi meters can also be used as 12inch or 12cm
marginInfo.Top = 72
' Set the margin Bottom. This value is in points but other units like
' Inches and centi meters can also be used as 12inch or 12cm
marginInfo.Bottom = 72
' Set the margin Left. This value is in points but other units like
' Inches and centi meters can also be used as 12inch or 12cm
marginInfo.Left = 90
' Set the margin Right. This value is in points but other units like
' Inches and centi meters can also be used as 12inch or 12cm
marginInfo.Right = 90
' Assign the marginInfo instance to Margin property of sec1.PageInfo
section1.PageInfo.Margin = marginInfo
' For complete examples and data files, please go to https://github.com/aspose-pdf/Aspose.Pdf-for-.NET
section1.PageInfo.PageWidth = 576
section1.PageInfo.PageHeight = 707.5F
' For complete examples and data files, please go to https://github.com/aspose-pdf/Aspose.Pdf-for-.NET
section1.PageInfo.PageWidth = AP.Generator.PageSize.A3Width
section1.PageInfo.PageHeight = AP.Generator.PageSize.A3Height
' For complete examples and data files, please go to https://github.com/aspose-pdf/Aspose.Pdf-for-.NET
' The path to the documents directory.
Dim dataDir As String = RunExamples.GetDataDir_AsposePdfGenerator_SecurityFeatures()
' Instantiate Pdf instance by calling its empty constructor
Dim pdf1 As New Aspose.Pdf.Generator.Pdf()
' Assign a security instance to Pdf object
pdf1.Security = New Aspose.Pdf.Generator.Security()
' Restrict annotation modification
pdf1.Security.IsAnnotationsModifyingAllowed = False
' Restrict contents modification
pdf1.Security.IsContentsModifyingAllowed = False
' Restrict copying the data
pdf1.Security.IsCopyingAllowed = False
' Allow to print the document
pdf1.Security.IsPrintingAllowed = True
' Restrict form filling
pdf1.Security.IsFormFillingAllowed = False
' Add a section in the Pdf
Dim sec1 As Aspose.Pdf.Generator.Section = pdf1.Sections.Add()
' Create a text paragraph
Dim text1 As New Aspose.Pdf.Generator.Text(sec1, "this is text content")
' Set the top maring of text paragraph to 30
text1.Margin.Top = 30
' Add the text paragraph to the section
sec1.Paragraphs.Add(text1)
dataDir = dataDir & Convert.ToString("AllowDisallowPrivileges_out_.pdf")
' Save the Pdf
pdf1.Save(dataDir)
' For complete examples and data files, please go to https://github.com/aspose-pdf/Aspose.Pdf-for-.NET
' The path to the documents directory.
Dim dataDir As String = RunExamples.GetDataDir_AsposePdfGenerator_SecurityFeatures()
' Instantiate Pdf instance by calling its empty constructor
Dim pdf1 As New Aspose.Pdf.Generator.Pdf()
' Assign a security instance to Pdf object
pdf1.Security = New Aspose.Pdf.Generator.Security()
' Set encryption level to 128 bits
pdf1.Security.Is128BitsEncrypted = True
' Add a section in the Pdf
Dim sec1 As Aspose.Pdf.Generator.Section = pdf1.Sections.Add()
' Create a text paragraph
Dim text1 As New Aspose.Pdf.Generator.Text(sec1, "this is text content")
' Set the top maring of text paragraph to 30
text1.Margin.Top = 30
' Add the text paragraph to the section
sec1.Paragraphs.Add(text1)
dataDir = dataDir & Convert.ToString("SetEncryption_out_.pdf")
' Save the Pdf
pdf1.Save(dataDir)
' For complete examples and data files, please go to https://github.com/aspose-pdf/Aspose.Pdf-for-.NET
' The path to the documents directory.
Dim dataDir As String = RunExamples.GetDataDir_AsposePdfGenerator_SecurityFeatures()
' Instantiate Pdf instance by calling its empty constructor
Dim pdf1 As New Aspose.Pdf.Generator.Pdf()
' Assign a security instance to Pdf object
pdf1.Security = New Aspose.Pdf.Generator.Security()
' Set the master password for the PDF document
pdf1.Security.MasterPassword = "master"
' Set the user password for the PDF document
pdf1.Security.UserPassword = "user"
' Add a section in the Pdf
Dim sec1 As Aspose.Pdf.Generator.Section = pdf1.Sections.Add()
' Create a text paragraph
Dim text1 As New Aspose.Pdf.Generator.Text(sec1, "this is text content")
' Set the top maring of text paragraph to 30
text1.Margin.Top = 30
' Add the text paragraph to the section
sec1.Paragraphs.Add(text1)
dataDir = dataDir & Convert.ToString("SetPassword_out_.pdf")
' Save the Pdf
pdf1.Save(dataDir)
' For complete examples and data files, please go to https://github.com/aspose-pdf/Aspose.Pdf-for-.NET
' The path to the documents directory.
Dim dataDir As String = RunExamples.GetDataDir_AsposePdfGenerator_Tables()
' Instntiate the Pdf object by calling its empty constructor
Dim pdf1 As New Aspose.Pdf.Generator.Pdf()
' Create the section in the Pdf object
Dim sec1 As Aspose.Pdf.Generator.Section = pdf1.Sections.Add()
' Create Table instance
Dim tab1 As New Aspose.Pdf.Generator.Table()
' Add the table object in the paragraphs collection of the section
sec1.Paragraphs.Add(tab1)
' Set the column widths of the table
tab1.ColumnWidths = "50 50 50"
' Set default text color for the text contents of each cell in the table to blue
tab1.DefaultCellTextInfo.Color = New Aspose.Pdf.Generator.Color("Blue")
' Set default left side padding of the cell
tab1.DefaultCellPadding.Left = 5
' Set default border of the cell using BorderInfo object
tab1.DefaultCellBorder = New Aspose.Pdf.Generator.BorderInfo(CInt(Aspose.Pdf.Generator.BorderSide.All), 0.1F)
' After setting default cell format information for the table, you can add rows
' And columns in the table
Dim row1 As Aspose.Pdf.Generator.Row = tab1.Rows.Add()
row1.Cells.Add("col1")
row1.Cells.Add("col2")
row1.Cells.Add("col3")
' Save the Pdf
pdf1.Save(dataDir & Convert.ToString("CellInformation_out_.pdf"))
' For complete examples and data files, please go to https://github.com/aspose-pdf/Aspose.Pdf-for-.NET
' The path to the documents directory.
Dim dataDir As String = RunExamples.GetDataDir_AsposePdfGenerator_Tables()
' Instantiate a Pdf object by calling its empty constructor
Dim pdf1 As New Aspose.Pdf.Generator.Pdf()
' Call BindXML method to read information from RepeatExample.xml document. Second
' Parameter is for Xsl file. In our case, we don' T need it so leave it as null.
pdf1.BindXML(dataDir & Convert.ToString("RepeatExample.xml"), Nothing)
' Obtain the first section from the Pdf
Dim sec1 As Aspose.Pdf.Generator.Section = pdf1.Sections(0)
' Obtain a table named "table1" from the Pdf
Dim table1 As Aspose.Pdf.Generator.Table = TryCast(sec1.Paragraphs("table1"), Aspose.Pdf.Generator.Table)
' Declare a table instance
Dim curTable As Aspose.Pdf.Generator.Table
' Create an array of string containing three values, "item1", "item2" and "item3"
Dim items As String() = New String() {"item1", "item2", "item3"}
' Run a for loop for 5 times
For i As Integer = 0 To 4
' Copy the table structure of "table1" by calling its Clone method
curTable = TryCast(table1.Clone(), Aspose.Pdf.Generator.Table)
' Set the top margin of the cloned table to 10
curTable.Margin.Top = 10
' Copy a row (with structure and data) of "table1" by calling its
' CompleteClone method. And then add that row to the cloned table
curTable.Rows.Add(TryCast(table1.Rows(0).CompleteClone(), Aspose.Pdf.Generator.Row))
' Import an array of string "items" into the table
curTable.ImportArray(items, 1, 0, False)
' Add the cloned table to the paragraphs collection of the section
sec1.Paragraphs.Add(curTable)
Next
' Save the Pdf
pdf1.Save(dataDir & Convert.ToString("CompleteClone_out_.pdf"))
' For complete examples and data files, please go to https://github.com/aspose-pdf/Aspose.Pdf-for-.NET
' The path to the documents directory.
Dim dataDir As String = RunExamples.GetDataDir_AsposePdfGenerator_Tables()
Dim dt As New DataTable("Employee")
dt.Columns.Add("Employee_ID", GetType(Int32))
dt.Columns.Add("Employee_Name", GetType(String))
dt.Columns.Add("Gender", GetType(String))
' Add 2 rows into the DataTable object programmatically
Dim dr As DataRow = dt.NewRow()
dr(0) = 1
dr(1) = "John Smith"
dr(2) = "Male"
dt.Rows.Add(dr)
dr = dt.NewRow()
dr(0) = 2
dr(1) = "Mary Miller"
dr(2) = "Female"
dt.Rows.Add(dr)
' Instantiate a Pdf instance
Dim pdf1 As New Aspose.Pdf.Generator.Pdf()
' Create a section in the Pdf instance
Dim sec1 As Aspose.Pdf.Generator.Section = pdf1.Sections.Add()
' Create a Table object
Dim tab1 As New Aspose.Pdf.Generator.Table()
' Add the Table object in the paragraphs collection of the section
sec1.Paragraphs.Add(tab1)
' Set column widths of the table
tab1.ColumnWidths = "40 100 100 100"
' Set default cell border of the table using BorderInfo object
tab1.DefaultCellBorder = New Aspose.Pdf.Generator.BorderInfo(CInt(Aspose.Pdf.Generator.BorderSide.All), 0.1F)
' Import data into the Table object from the DataTable created above
tab1.ImportDataTable(dt, True, 0, 1, 3, 3)
' Get 1st row from the table
Dim row1 As Aspose.Pdf.Generator.Row = tab1.Rows(0)
' Iterate through all cells in the row and set their background color to blue
For Each curCell As Aspose.Pdf.Generator.Cell In row1.Cells
curCell.BackgroundColor = New Aspose.Pdf.Generator.Color("Blue")
Next
' Save the Pdf
pdf1.Save(dataDir & Convert.ToString("IntegrateWithDatabase_out_.pdf"))
' For complete examples and data files, please go to https://github.com/aspose-pdf/Aspose.Pdf-for-.NET
' The path to the documents directory.
Dim dataDir As String = RunExamples.GetDataDir_AsposePdfGenerator_Tables()
' Instantiate Pdf document object
Dim pdf1 As New Aspose.Pdf.Generator.Pdf()
' Create a section in the Pdf
Dim sec1 As Aspose.Pdf.Generator.Section = pdf1.Sections.Add()
' Create a table
Dim tab1 As New Aspose.Pdf.Generator.Table()
' Add the table into the paragraphs collection of section
sec1.Paragraphs.Add(tab1)
' Set the column widths of the table
tab1.ColumnWidths = "100 200"
' Set the default cell border using BorderInfo instance
tab1.DefaultCellBorder = New Aspose.Pdf.Generator.BorderInfo(CInt(Aspose.Pdf.Generator.BorderSide.All))
' Add a row into the table
Dim row1 As Aspose.Pdf.Generator.Row = tab1.Rows.Add()
' Add 1st cell in the row
row1.Cells.Add("left cell")
' Add 2nd cell in the row
Dim cell2 As Aspose.Pdf.Generator.Cell = row1.Cells.Add()
' Create a table to be nested with the reference of 2nd cell in the row
Dim tab2 As New Aspose.Pdf.Generator.Table(cell2)
' Add the nested table into the paragraphs collection of the 2nd cell
cell2.Paragraphs.Add(tab2)
' Set the column widths of the nested table
tab2.ColumnWidths = "100 100"
' Create 1st row in the nested table
Dim row21 As Aspose.Pdf.Generator.Row = tab2.Rows.Add()
' Create 1st cell in the 1st row of the nested table
Dim cell21 As Aspose.Pdf.Generator.Cell = row21.Cells.Add("top cell")
' Set the column span of the 1st cell (in the 1st row of the nested table) to 2
cell21.ColumnsSpan = 2
' Create 2nd row in the nested table
Dim row22 As Aspose.Pdf.Generator.Row = tab2.Rows.Add()
' Create 1st cell in the 2nd row of the nested table
row22.Cells.Add("left bottom cell")
' Create 2nd cell in the 2nd row of the nested table
row22.Cells.Add("right bottom cell")
' Save the Pdf
pdf1.Save(dataDir & Convert.ToString("NestedTables_out_.pdf"))
' For complete examples and data files, please go to https://github.com/aspose-pdf/Aspose.Pdf-for-.NET
' The path to the documents directory.
Dim dataDir As String = RunExamples.GetDataDir_AsposePdfGenerator_Tables()
' Instantiate the Pdf object by calling its empty constructor
Dim pdf1 As New Aspose.Pdf.Generator.Pdf()
' Create the section in the Pdf object
Dim sec1 As Aspose.Pdf.Generator.Section = pdf1.Sections.Add()
' Instantiate a table object
Dim tab1 As New Aspose.Pdf.Generator.Table()
' Add the table in paragraphs collection of the desired section
sec1.Paragraphs.Add(tab1)
' Set with column widths of the table
tab1.ColumnWidths = "110 120 50"
' Set default cell border using BorderInfo object
tab1.DefaultCellBorder = New Aspose.Pdf.Generator.BorderInfo(CInt(Aspose.Pdf.Generator.BorderSide.All), 0.1F)
' Set table border using another customized BorderInfo object
tab1.Border = New Aspose.Pdf.Generator.BorderInfo(CInt(Aspose.Pdf.Generator.BorderSide.All), 1.0F)
' Create MarginInfo object and set its left, bottom, right and top margins
Dim margin As New Aspose.Pdf.Generator.MarginInfo()
margin.Top = 5.0F
margin.Left = 5.0F
margin.Right = 5.0F
margin.Bottom = 5.0F
' Set the default cell padding to the MarginInfo object
tab1.DefaultCellPadding = margin
' Create rows in the table and then cells in the rows
Dim row1 As Aspose.Pdf.Generator.Row = tab1.Rows.Add()
row1.DefaultCellTextInfo.FontName = "Arial Unicode MS"
row1.Cells.Add("Arabic Sample مَرْحَبا بكِ كُلَّ الْتَرْحيبْ")
row1.Cells(0).DefaultCellTextInfo.IsRightToLeft = True
' Row1.Cells[0].DefaultCellTextInfo.FontName = "Arial Unicode MS";
row1.Cells.Add("Persian alphabet الفبای فارسی")
row1.Cells(1).DefaultCellTextInfo.IsRightToLeft = True
' Row1.Cells[1].DefaultCellTextInfo.FontName = "Arial Unicode MS";
row1.Cells.Add("English Text")
' Include the subset of Font supporting Non-English text in PDF file
pdf1.SetUnicode()
' Save the Pdf
pdf1.Save(dataDir & Convert.ToString("Arabic_Farsi_Text_in_TableCell_out_.pdf"))
' For complete examples and data files, please go to https://github.com/aspose-pdf/Aspose.Pdf-for-.NET
Dim binfo As New Aspose.Pdf.Generator.BorderInfo(CInt(BorderSide.All), 1.0F, New Aspose.Pdf.Generator.Color("Red"))
' For complete examples and data files, please go to https://github.com/aspose-pdf/Aspose.Pdf-for-.NET
' The path to the documents directory.
Dim dataDir As String = RunExamples.GetDataDir_AsposePdfGenerator_Tables()
' Instantiate Pdf object
Dim pdf1 As New Aspose.Pdf.Generator.Pdf()
' Create the section in the Pdf object
Dim sec1 As Aspose.Pdf.Generator.Section = pdf1.Sections.Add()
' Instantiate a table object
Dim tab1 As New Aspose.Pdf.Generator.Table()
' Add the table in paragraphs collection of the desired section
sec1.Paragraphs.Add(tab1)
' Set with column widths of the table
tab1.ColumnWidths = "100"
' Set fixed table row height
tab1.FixedHeight = 30
' Create a blank BorderInfo object
Dim bInfo As New Aspose.Pdf.Generator.BorderInfo()
' Create a GraphInfo object without any argument to its constructor
Dim gInfo As New Aspose.Pdf.Generator.GraphInfo()
' Set the corner radius for GraphInfo
gInfo.CornerRadius = 15.0F
' Specify the line color information
gInfo.Color = New Aspose.Pdf.Generator.Color("Red")
' Set the rounded corner table border
bInfo.Round = gInfo
' Specify the Corner style for table border as Round
tab1.CornerStyle = Aspose.Pdf.Generator.BorderCornerStyle.Round
' Set the table border information
tab1.Border = bInfo
' Create rows in the table and then cells in the rows
Dim row1 As Aspose.Pdf.Generator.Row = tab1.Rows.Add()
' Add sample string to paragraphs collection of table cell
row1.Cells.Add("Hello World...")
' Set the vertical alignment of text as center aligned
row1.Cells(0).DefaultCellTextInfo.Alignment = Aspose.Pdf.Generator.AlignmentType.Center
' Set the horizontal alignment of text as center aligned
row1.Cells(0).VerticalAlignment = Aspose.Pdf.Generator.VerticalAlignmentType.Center
' Save the Pdf
pdf1.Save(dataDir & Convert.ToString("Rounded_Corner-Table_out_.pdf"))
' For complete examples and data files, please go to https://github.com/aspose-pdf/Aspose.Pdf-for-.NET
' The path to the documents directory.
Dim dataDir As String = RunExamples.GetDataDir_AsposePdfGenerator_Tables()
' Instantiate Pdf document object
Dim pdf1 As New Aspose.Pdf.Generator.Pdf()
' Create a section in the Pdf
Dim sec1 As Aspose.Pdf.Generator.Section = pdf1.Sections.Add()
' Create a table
Dim tab1 As New Aspose.Pdf.Generator.Table()
' Add table in the paragraphs collection of the section
sec1.Paragraphs.Add(tab1)
' Set the column widths of the table
tab1.ColumnWidths = "60 100 100"
' Create a TextInfo instance
Dim tinfo As New Aspose.Pdf.Generator.TextInfo()
' Set the font name to "Courier" for the TextInfo object
tinfo.FontName = "Courier"
' Set default table border using the BorderInfo object
tab1.DefaultCellBorder = New Aspose.Pdf.Generator.BorderInfo(CInt(Aspose.Pdf.Generator.BorderSide.All), 0.1F)
' Apply the text format settings in TextInfo object to table cells
tab1.DefaultCellTextInfo = tinfo
' Create an array of double values
Dim darr As Double() = New [Double]() {1.5, 3.1415926, 100000, 20, 4000, 30.4512, _
45.67, 890, 23.45}
' Import the values in array to table
tab1.ImportArray(darr, 0, 0, False)
' Set background color for the first row
Dim tinfo1 As Aspose.Pdf.Generator.TextInfo = TryCast(tinfo.Clone(), Aspose.Pdf.Generator.TextInfo)
tinfo1.BackgroundColor = New Aspose.Pdf.Generator.Color("#0000ff")
tab1.Rows(0).DefaultCellTextInfo = tinfo1
' Align text in the last column to right hand side
Dim tinfo2 As Aspose.Pdf.Generator.TextInfo = TryCast(tinfo.Clone(), Aspose.Pdf.Generator.TextInfo)
tinfo2.Alignment = Aspose.Pdf.Generator.AlignmentType.Right
tab1.SetColumnTextInfo(2, tinfo2)
' We have to reset text format settings of the upper right cell
tinfo1.Alignment = Aspose.Pdf.Generator.AlignmentType.Right
tab1.Rows(0).Cells(2).DefaultCellTextInfo = tinfo1
' Save the Pdf
pdf1.Save(dataDir & Convert.ToString("RowAndColumnFormat_out_.pdf"))
' For complete examples and data files, please go to https://github.com/aspose-pdf/Aspose.Pdf-for-.NET
' The path to the documents directory.
Dim dataDir As String = RunExamples.GetDataDir_AsposePdfGenerator_Tables()
' Instntiate the Pdf object by calling its empty constructor
Dim pdf1 As New Aspose.Pdf.Generator.Pdf()
' Create the section in the Pdf object
Dim sec1 As Aspose.Pdf.Generator.Section = pdf1.Sections.Add()
' Instantiate a table object
Dim tab1 As New Aspose.Pdf.Generator.Table()
' Add the table in paragraphs collection of the desired section
sec1.Paragraphs.Add(tab1)
' Set with column widths of the table
tab1.ColumnWidths = "50 50 50"
' Set default cell border using BorderInfo object
tab1.DefaultCellBorder = New Aspose.Pdf.Generator.BorderInfo(CInt(Aspose.Pdf.Generator.BorderSide.All), 0.1F)
' Set table border using another customized BorderInfo object
tab1.Border = New Aspose.Pdf.Generator.BorderInfo(CInt(Aspose.Pdf.Generator.BorderSide.All), 1.0F)
' Create MarginInfo object and set its left, bottom, right and top margins
Dim margin As New Aspose.Pdf.Generator.MarginInfo()
margin.Top = 5.0F
margin.Left = 5.0F
margin.Right = 5.0F
margin.Bottom = 5.0F
' Set the default cell padding to the MarginInfo object
tab1.DefaultCellPadding = margin
' Create rows in the table and then cells in the rows
Dim row1 As Aspose.Pdf.Generator.Row = tab1.Rows.Add()
row1.Cells.Add("col1")
row1.Cells.Add("col2")
row1.Cells.Add("col3")
Dim row2 As Aspose.Pdf.Generator.Row = tab1.Rows.Add()
row2.Cells.Add("item1")
row2.Cells.Add("item2")
row2.Cells.Add("item3")
' Save the Pdf
pdf1.Save(dataDir & Convert.ToString("SetBorderAndPadding_out_.pdf"))
' For complete examples and data files, please go to https://github.com/aspose-pdf/Aspose.Pdf-for-.NET
row1.Cells(1).FitWidth = 2
' For complete examples and data files, please go to https://github.com/aspose-pdf/Aspose.Pdf-for-.NET
row1.Cells(1).ColumnsSpan = 2
' For complete examples and data files, please go to https://github.com/aspose-pdf/Aspose.Pdf-for-.NET
' Set with column widths of the table
tab1.ColumnWidths = "70 2cm"
' For complete examples and data files, please go to https://github.com/aspose-pdf/Aspose.Pdf-for-.NET
tab1.IsBroken = False
' For complete examples and data files, please go to https://github.com/aspose-pdf/Aspose.Pdf-for-.NET
tab1.IsFirstRowRepeated = True
' For complete examples and data files, please go to https://github.com/aspose-pdf/Aspose.Pdf-for-.NET
' The path to the documents directory.
Dim dataDir As String = RunExamples.GetDataDir_AsposePdfGenerator_TechnicalArticles()
' Instantiate a Pdf object
Dim pdfConv As New Aspose.Pdf.Generator.Pdf()
' Create a section in the pdf document
Dim sec1 As Aspose.Pdf.Generator.Section = pdfConv.Sections.Add()
' Instantiate a table object
Dim tab1 As New Aspose.Pdf.Generator.Table()
' Add the table in paragraphs collection of the desired section
sec1.Paragraphs.Add(tab1)
' Set default cell border using BorderInfo object
tab1.DefaultCellBorder = New Aspose.Pdf.Generator.BorderInfo(CInt(Aspose.Pdf.Generator.BorderSide.All), 0.1F)
' Set with column widths of the table
tab1.ColumnWidths = "100 100 120"
Dim img As New Aspose.Pdf.Generator.Image()
img.ImageInfo.File = dataDir & Convert.ToString("aspose-logo.jpg")
img.ImageInfo.ImageFileType = Aspose.Pdf.Generator.ImageFileType.Jpeg
' Create rows in the table and then cells in the rows
Dim row1 As Aspose.Pdf.Generator.Row = tab1.Rows.Add()
row1.Cells.Add("Sample text in cell")
' Add the cell which holds the image
Dim cell2 As Aspose.Pdf.Generator.Cell = row1.Cells.Add()
' Add the image to the table cell
cell2.Paragraphs.Add(img)
row1.Cells.Add("Previous cell with image")
row1.Cells(2).VerticalAlignment = Aspose.Pdf.Generator.VerticalAlignmentType.Center
' Save the Pdf file
pdfConv.Save(dataDir & Convert.ToString("AddImageInTableCell_out_.pdf"))
' For complete examples and data files, please go to https://github.com/aspose-pdf/Aspose.Pdf-for-.NET
' The path to the documents directory.
Dim dataDir As String = RunExamples.GetDataDir_AsposePdfGenerator_TechnicalArticles()
Dim xmlDoc As New XmlDocument()
xmlDoc.LoadXml(dataDir & Convert.ToString("Sample.xml"))
Dim pdf As New Aspose.Pdf.Generator.Pdf()
' Object xmlDoc contains all contents from original word document in XML format defined in Aspose.PDF XML Schema.
pdf.BindXML(xmlDoc, Nothing)
' Before saving, to add bookmarks from headings.
pdf.IsBookmarked = True
For Each sec As Aspose.Pdf.Generator.Section In pdf.Sections
For Each para As Aspose.Pdf.Generator.Paragraph In sec.Paragraphs
If TypeOf para Is Aspose.Pdf.Generator.Heading Then
Dim h As Aspose.Pdf.Generator.Heading = TryCast(para, Aspose.Pdf.Generator.Heading)
h.IsInList = True
End If
Next
Next
pdf.Save(dataDir & Convert.ToString("BindXML_out_.pdf"))
' For complete examples and data files, please go to https://github.com/aspose-pdf/Aspose.Pdf-for-.NET
' The path to the documents directory.
Dim dataDir As String = RunExamples.GetDataDir_AsposePdfGenerator_TechnicalArticles()
' Instantiate Pdf instance by calling its empty constructor
Dim pdf1 As New Aspose.Pdf.Generator.Pdf()
' Add a section into the pdf document
Dim sec As Aspose.Pdf.Generator.Section = pdf1.Sections.Add()
' Create a FileStream object to read the imag file
Dim fs As FileStream = File.OpenRead(dataDir & Convert.ToString("aspose-logo.jpg"))
' Read the image into Byte array
Dim data As Byte() = New Byte(Convert.ToInt32(fs.Length - 1)) {}
fs.Read(data, 0, data.Length)
' Create a MemoryStream object from image Byte array
Dim ms As New MemoryStream(data)
' Create an image object in the section
Dim imageht As New Aspose.Pdf.Generator.Image(sec)
' Set the type of image using ImageFileType enumeration
imageht.ImageInfo.ImageFileType = Aspose.Pdf.Generator.ImageFileType.Jpeg
' Specify the image source as MemoryStream
imageht.ImageInfo.ImageStream = ms
' Add image object into the Paragraphs collection of the section
sec.Paragraphs.Add(imageht)
' Save the Pdf
pdf1.Save(dataDir & Convert.ToString("ConvertMemoryStreamImageToPdf_out_.pdf"))
' Close the MemoryStream Object
ms.Close()
' For complete examples and data files, please go to https://github.com/aspose-pdf/Aspose.Pdf-for-.NET
' The path to the documents directory.
Dim dataDir As String = RunExamples.GetDataDir_AsposePdfGenerator_TechnicalArticles()
' Instantiate Pdf pbject by calling its empty constructor
Dim pdf1 As New Aspose.Pdf.Generator.Pdf()
' Create a new section in the Pdf object
Dim sec1 As Aspose.Pdf.Generator.Section = pdf1.Sections.Add()
' Specify the location of input text file
Dim FILE_NAME As [String] = dataDir & Convert.ToString("test.txt")
If File.Exists(FILE_NAME) Then
Dim objReader As System.IO.TextReader = New System.IO.StreamReader(FILE_NAME)
' Read the file till the end of the file has come
Do
' Create a new text paragraph & pass text to its constructor as argument
Dim t2 As New Aspose.Pdf.Generator.Text(objReader.ReadLine())
' Add the text object to paragraphs collection of section
' Read till the end of file
sec1.Paragraphs.Add(t2)
Loop While objReader.Peek() <> -1
' Close the StreamReader object
objReader.Close()
Else
Console.WriteLine("File Does Not Exist")
End If
' Save the PDF file
pdf1.Save(dataDir & Convert.ToString("ConvertLargeTextFile_out_.pdf"))
' For complete examples and data files, please go to https://github.com/aspose-pdf/Aspose.Pdf-for-.NET
' The path to the documents directory.
Dim dataDir As String = RunExamples.GetDataDir_AsposePdfGenerator_TechnicalArticles()
' Read the source text file
Dim tr As System.IO.TextReader = New StreamReader(dataDir & Convert.ToString("test.txt"))
' Instantiate Pdf pbject by calling its empty constructor
Dim pdf1 As New Aspose.Pdf.Generator.Pdf()
' Create a new section in the Pdf object
Dim sec1 As Aspose.Pdf.Generator.Section = pdf1.Sections.Add()
' Create a new text paragraph and pass the text to its constructor as argument
Dim t2 As New Aspose.Pdf.Generator.Text(tr.ReadToEnd())
sec1.Paragraphs.Add(t2)
pdf1.Save(dataDir & Convert.ToString("ConvertTextFile_out_.Pdf"))
' For complete examples and data files, please go to https://github.com/aspose-pdf/Aspose.Pdf-for-.NET
' The path to the documents directory.
Dim dataDir As String = RunExamples.GetDataDir_AsposePdfGenerator_TechnicalArticles()
' Create a PDF object
Dim pdf As New Aspose.Pdf.Generator.Pdf()
Dim sec1 As Aspose.Pdf.Generator.Section = pdf.Sections.Add()
' Create a text object
Dim t1 As New Aspose.Pdf.Generator.Text(sec1)
' Add the text object to Paragraphs collection of section
sec1.Paragraphs.Add(t1)
Dim seg1 As New Aspose.Pdf.Generator.Segment(t1)
' Add the contents for Segment1
seg1.Content = "paragraph 3 segment 1"
' Specify the Font fore color for segement1
seg1.TextInfo.Color = New Aspose.Pdf.Generator.Color("red")
' Specify the font size information for segment1
seg1.TextInfo.FontSize = 12
' Specify the value for Opacity of text. Default is 1.0. Use it for multilayer effect
t1.Opacity = 0.0F
' Add the segment to segments collection of Text1
t1.Segments.Add(seg1)
' Jpg image cover the underlayer text
Dim image1 As New Aspose.Pdf.Generator.Image(sec1)
image1.ImageInfo.File = dataDir & Convert.ToString("aspose-logo.jpg")
image1.ImageInfo.ImageFileType = Aspose.Pdf.Generator.ImageFileType.Jpeg
' Create a Floating Box object that will hold image file
Dim box1 As New Aspose.Pdf.Generator.FloatingBox(117, 21)
' Add Floating box to paragraphs collection of Section1
sec1.Paragraphs.Add(box1)
' Specify the left margin of FloatingBox1
box1.Left = -4
' Specify the Top margin of FloatingBox1
box1.Top = -4
' Add the image file to paragraphs collection of FloatingBox
box1.Paragraphs.Add(image1)
' Save the reusltant PDF document
pdf.Save(dataDir & Convert.ToString("CreateMultiLayerPdf_out_.pdf"))
' For complete examples and data files, please go to https://github.com/aspose-pdf/Aspose.Pdf-for-.NET
' The path to the documents directory.
Dim dataDir As String = RunExamples.GetDataDir_AsposePdfGenerator_TechnicalArticles()
' Create a PDF object
Dim pdf As New Aspose.Pdf.Generator.Pdf()
Dim sec1 As Aspose.Pdf.Generator.Section = pdf.Sections.Add()
' Create a text object
Dim t1 As New Aspose.Pdf.Generator.Text(sec1)
' Create a Floating Box object that will hold image file
Dim TextFloatingBox1 As New Aspose.Pdf.Generator.FloatingBox(117, 21)
' Specify the ZIndex value for TextFloatingBox
TextFloatingBox1.ZIndex = 1
TextFloatingBox1.Left = -4
TextFloatingBox1.Top = -4
' Add Floating box to paragraphs collection of Section1
sec1.Paragraphs.Add(TextFloatingBox1)
' Add the text object to Paragraphs collection of FloatingBox
TextFloatingBox1.Paragraphs.Add(t1)
Dim seg1 As New Aspose.Pdf.Generator.Segment(t1)
' Add the contents for Segment1
seg1.Content = "paragraph 3 segment 1"
' Specify the Font fore color for segement1
seg1.TextInfo.Color = New Aspose.Pdf.Generator.Color("red")
' Specify the font size information for segment1
seg1.TextInfo.FontSize = 12
' Specify the value for Opacity of text. Default is 1.0. Use it for multilayer effect
t1.Opacity = 0.0F
' Add the segment to segments collection of Text1
t1.Segments.Add(seg1)
' JPeg image cover the underlayer text
Dim image1 As New Aspose.Pdf.Generator.Image(sec1)
image1.ImageInfo.File = dataDir & Convert.ToString("aspose-logo.jpg")
image1.ImageInfo.ImageFileType = Aspose.Pdf.Generator.ImageFileType.Jpeg
' Create a Floating Box object that will hold image file
Dim ImageFloatingBox As New Aspose.Pdf.Generator.FloatingBox(117, 21)
' Add Floating box to paragraphs collection of Section1
sec1.Paragraphs.Add(ImageFloatingBox)
' Specify the left margin of FloatingBox1
ImageFloatingBox.Left = -4
' Specify the Top margin of FloatingBox1
ImageFloatingBox.Top = -4
' Specify the ZIndex of ImageFloatingBox
ImageFloatingBox.ZIndex = 2
' Add the image file to paragraphs collection of FloatingBox
ImageFloatingBox.Paragraphs.Add(image1)
' Save the reusltant PDF document
pdf.Save(dataDir & Convert.ToString("Multilayer-2ndApproach_out_.pdf"))
' For complete examples and data files, please go to https://github.com/aspose-pdf/Aspose.Pdf-for-.NET
' The path to the documents directory.
Dim dataDir As String = RunExamples.GetDataDir_AsposePdfGenerator_TechnicalArticles()
' Create pdf document
Dim pdf1 As New Aspose.Pdf.Generator.Pdf()
' Instantiate License class and call its SetLicense method to use the license
Dim license As New Aspose.Pdf.License()
license.SetLicense("Aspose.Custom.lic")
' Set the conformance property of Pdf class to predefined value
pdf1.Conformance = Aspose.Pdf.Generator.PdfConformance.PdfA1B
' Add a section into the pdf document
Dim sec1 As Aspose.Pdf.Generator.Section = pdf1.Sections.Add()
' Save the document
' For complete examples and data files, please go to https://github.com/aspose-pdf/Aspose.Pdf-for-.NET
' Create an object of TableFormatInfo class.
Dim tfi As New Aspose.Pdf.Generator.TableFormatInfo()
' Sets a string value that indicate currency symbol of money, the default is "$".
tfi.CurrencySymbol = "$"
' Instantiate a table object
Dim tab1 As New Aspose.Pdf.Generator.Table()
' Format the table in specified columns and rows with given TableFormatInfo
tab1.FormatTableWithFormatInfo(tfi, 1, 1, 1, 1)
' For complete examples and data files, please go to https://github.com/aspose-pdf/Aspose.Pdf-for-.NET
' The path to the documents directory.
Dim dataDir As String = RunExamples.GetDataDir_AsposePdfGenerator_TechnicalArticles()
' Instantiate an object PDF class
Dim pdf As New Aspose.Pdf.Generator.Pdf()
' Add the section to PDF document sections collection
Dim section As Aspose.Pdf.Generator.Section = pdf.Sections.Add()
' Instantiate a table object
Dim table1 As New Aspose.Pdf.Generator.Table()
table1.Margin.Top = 300
' Add the table in paragraphs collection of the desired section
section.Paragraphs.Add(table1)
' Set with column widths of the table
table1.ColumnWidths = "100 100 100"
' Set default cell border using BorderInfo object
table1.DefaultCellBorder = New Aspose.Pdf.Generator.BorderInfo(CInt(Aspose.Pdf.Generator.BorderSide.All), 0.1F)
' Set table border using another customized BorderInfo object
table1.Border = New Aspose.Pdf.Generator.BorderInfo(CInt(Aspose.Pdf.Generator.BorderSide.All), 1.0F)
' Create MarginInfo object and set its left, bottom, right and top margins
Dim margin As New Aspose.Pdf.Generator.MarginInfo()
margin.Top = 5.0F
margin.Left = 5.0F
margin.Right = 5.0F
margin.Bottom = 5.0F
' Set the default cell padding to the MarginInfo object
table1.DefaultCellPadding = margin
' If you increase the counter to 17, table will break
' Because it cannot be accommodated any more over this page
For RowCounter As Integer = 0 To 16
' Create rows in the table and then cells in the rows
Dim row1 As Aspose.Pdf.Generator.Row = table1.Rows.Add()
row1.Cells.Add("col " + RowCounter.ToString() + ", 1")
row1.Cells.Add("col " + RowCounter.ToString() + ", 2")
row1.Cells.Add("col " + RowCounter.ToString() + ", 3")
Next
' Get the Page Height information
Dim PageHeight As Single = pdf.PageSetup.PageHeight
' Get the total height information of Page Top & Bottom margin, table Top margin and table height.
Dim TotalObjectsHeight As Single = section.PageInfo.Margin.Top + section.PageInfo.Margin.Bottom + table1.Margin.Top + table1.GetHeight(pdf)
' Display Page Height, Table Height, table Top margin and Page Top and Bottom margin information
Console.WriteLine("PDF document Height = " + pdf.PageSetup.PageHeight.ToString() + vbLf & "Top Margin Info = " + section.PageInfo.Margin.Top.ToString() + vbLf & "Bottom Margin Info = " + section.PageInfo.Margin.Bottom.ToString() + vbLf & vbLf & "Table-Top Margin Info = " + table1.Margin.Top.ToString() + vbLf & "Average Row Height = " + table1.Rows(0).GetHeight(pdf).ToString() + " " & vbLf & "Table height " + table1.GetHeight(pdf).ToString() + vbLf & " ----------------------------------------" + vbLf & "Total Page Height =" + PageHeight.ToString() + vbLf & "Cummulative height including Table =" + TotalObjectsHeight.ToString())
' Check if we deduct the sume of Page top margin + Page Bottom margin + Table Top margin and table height from Page height and its less
' Than 10 (an average row can be greater than 10)
If (PageHeight - TotalObjectsHeight) <= 10 Then
' If the value is less than 10, then display the message.
' Which shows that another row can not be placed and if we add new
' Row, table will break. It depends upon the row height value.
Console.WriteLine("Page Height - Objects Height < 10, so table will break")
End If
' Save the pdf document
pdf.Save(dataDir & Convert.ToString("FigureOutTableBreak_out_.pdf"))
' For complete examples and data files, please go to https://github.com/aspose-pdf/Aspose.Pdf-for-.NET
' The path to the documents directory.
Dim dataDir As String = RunExamples.GetDataDir_AsposePdfGenerator_TechnicalArticles()
' Instantiate Pdf instance by calling it empty constructor
Dim pdf1 As New Aspose.Pdf.Generator.Pdf()
' Create a section in the Pdf object
Dim sec1 As Aspose.Pdf.Generator.Section = pdf1.Sections.Add()
' Create a text paragraph inheriting text format settings from the section
Dim text1 As New Aspose.Pdf.Generator.Text(sec1)
' Add the text paragraph to the section
sec1.Paragraphs.Add(text1)
' Create a text segment
Dim s1 As New Aspose.Pdf.Generator.Segment(" This is a sample text using Custom font")
' Set the font name to the TextInfo.FontName property of segment, where ‘Almonto Snow’ is custom font name
s1.TextInfo.FontName = "Almonte Snow"
' Set the value for property to include the font description into Pdf file
s1.TextInfo.IsFontEmbedded = True
' Set the value for property to include a subset of font into Pdf file
s1.TextInfo.IsUnicode = True
' Add the text segment to the text paragraph
text1.Segments.Add(s1)
' Save the Pdf
pdf1.Save(dataDir & Convert.ToString("FontsEmbedding_out_.pdf"))
' For complete examples and data files, please go to https://github.com/aspose-pdf/Aspose.Pdf-for-.NET
' The path to the documents directory.
Dim dataDir As String = RunExamples.GetDataDir_AsposePdfGenerator_TechnicalArticles()
' Instantiate a pdf document
Dim pdf1 As New Aspose.Pdf.Generator.Pdf()
' Create a section in the pdf document
Dim sec1 As Aspose.Pdf.Generator.Section = pdf1.Sections.Add()
' Create string variables with text containing html tags
Dim s As String = "<html><body><font isUnicode=' True' Face=' Bete Noir NF' Size=18><i>Sample text </i>with Custome font Embedded </font><br><font isUnicode=' True' Face=' Courier New' Size=10><s>Sample Text </s>in <u>Courier New</u> font</font></body></html>"
' Create text paragraphs containing HTML text
Dim t1 As New Aspose.Pdf.Generator.Text(s)
' Enable the HTML tag support property
t1.IsHtmlTagSupported = True
' Add the text paragraphs containing HTML text to the section
sec1.Paragraphs.Add(t1)
' Save the pdf document
pdf1.Save(dataDir & Convert.ToString("inLineFormated_HtmlSuported_out_.pdf"))
' For complete examples and data files, please go to https://github.com/aspose-pdf/Aspose.Pdf-for-.NET
' Set the value for property to include a subset of font into Pdf file
s1.TextInfo.IsUnicode = True
' For complete examples and data files, please go to https://github.com/aspose-pdf/Aspose.Pdf-for-.NET
' The path to the documents directory.
Dim dataDir As String = RunExamples.GetDataDir_AsposePdfGenerator_TechnicalArticles()
' Create pdf document
Dim pdf1 As New Aspose.Pdf.Generator.Pdf()
' Instantiate License class and call its SetLicense method to use the license
Dim license As New Aspose.Pdf.License()
license.SetLicense("Aspose.Pdf.lic")
' Bind XML into the document
pdf1.BindXML(dataDir & Convert.ToString("Hyphen-test.xml"), Nothing)
' Enable hyphenation function. Default value is false.
pdf1.IsAutoHyphenated = True
' Set the hyphenation dictionary path.
pdf1.HyphenationDictionaryPath = dataDir & Convert.ToString("Hyphen.xml")
' Set the hyphenation area width. Default value is 12 points.
pdf1.HyphenationZoneWidth = 0
' Set the maximum number of consecutive hyphenations. Default value is zero that means no //limits.
pdf1.ConsecutiveHyphensLimits = 0
' Save the Pdf file
' For complete examples and data files, please go to https://github.com/aspose-pdf/Aspose.Pdf-for-.NET
' The path to the documents directory.
Dim dataDir As String = RunExamples.GetDataDir_AsposePdfGenerator_TechnicalArticles()
' Instantiate a Pdf object by calling its empty constructor
Dim pdf1 As New Aspose.Pdf.Generator.Pdf()
' Create a section in the Pdf object
Dim sec1 As Aspose.Pdf.Generator.Section = pdf1.Sections.Add()
'=====================================================//
' Header to show an Image
'=====================================================//
' Create Header Section of the document
Dim header As New Aspose.Pdf.Generator.HeaderFooter(sec1)
' Set the Odd header for the PDF file
sec1.OddHeader = header
' Set the Even Header for the PDF file
sec1.EvenHeader = header
' Create an image object in the section
Dim image1 As New Aspose.Pdf.Generator.Image(sec1)
' Set the path of image file
image1.ImageInfo.File = dataDir & Convert.ToString("aspose-logo.jpg")
' Set the type of image using ImageFileType enumeration
image1.ImageInfo.ImageFileType = Aspose.Pdf.Generator.ImageFileType.Jpeg
' Add image to Header section of the Pdf file
header.Paragraphs.Add(image1)
'=====================================================//
' Footer to show Page Number
'=====================================================//
' Create a Footer Section of the document
Dim footer As New Aspose.Pdf.Generator.HeaderFooter(sec1)
' Set the Odd footer of the PDF file
sec1.OddFooter = footer
' Set the Even footer of the PDF file
sec1.EvenFooter = footer
' Create a Text object
Dim txt As New Aspose.Pdf.Generator.Text("Page: ($p of $P ) ")
' Add text to Header section of the Pdf file
footer.Paragraphs.Add(txt)
' Save the Pdf file
pdf1.Save(dataDir & Convert.ToString("ImageAndPageNumberInHeaderFooter_out_.pdf"))
' For complete examples and data files, please go to https://github.com/aspose-pdf/Aspose.Pdf-for-.NET
' The path to the documents directory.
Dim dataDir As String = RunExamples.GetDataDir_AsposePdfGenerator_TechnicalArticles()
' Instantiate Pdf instance
Dim pdf As New Aspose.Pdf.Generator.Pdf()
' Add a section into the pdf document
Dim section As Aspose.Pdf.Generator.Section = pdf.Sections.Add()
' Initializes a new instance of the FloatingBox class
Dim box1 As New Aspose.Pdf.Generator.FloatingBox(140, 80)
' Indicate the horizontal positioning type of the floating box
box1.BoxHorizontalPositioning = Aspose.Pdf.Generator.BoxHorizontalPositioningType.Margin
' Float value that indicates left position of the paragraph
box1.Left = 2
' Indicate the vertical alignment type of the floating box
box1.BoxVerticalPositioning = Aspose.Pdf.Generator.BoxVerticalPositioningType.Page
' Float value that indicates top position of the paragraph
box1.Top = 10
' Add the macros to the paragraphs collection of the FloatingBox
box1.Paragraphs.Add(New Aspose.Pdf.Generator.Text("Page: ($p/ $P )"))
' Add a floatingBox to the section
section.Paragraphs.Add(box1)
' Save the document
pdf.Save(dataDir & Convert.ToString("PageNumber_using_FloatingBox_out_.pdf"))
' For complete examples and data files, please go to https://github.com/aspose-pdf/Aspose.Pdf-for-.NET
' The path to the documents directory.
Dim dataDir As String = RunExamples.GetDataDir_AsposePdfGenerator_TechnicalArticles()
' Instantiate a Pdf object by calling its empty constructor
Dim pdf1 As New Aspose.Pdf.Generator.Pdf()
' Create a section in the Pdf object
Dim sec1 As Aspose.Pdf.Generator.Section = pdf1.Sections.Add()
'=====================================================//
' Header to show an Image inline with text
'=====================================================//
' Create Header Section of the document
Dim header As New Aspose.Pdf.Generator.HeaderFooter(sec1)
' Set the Odd header for the PDF file
sec1.OddHeader = header
' Set the Even Header for the PDF file
sec1.EvenHeader = header
' Create a Text object
Dim txt1 As New Aspose.Pdf.Generator.Text()
' Add text to Header section of the Pdf file
header.Paragraphs.Add(txt1)
' Add the text string to Segment of text object
txt1.Segments.Add("Aspose.Pdf is a Robust component by")
' Specify the color & Font information using TextInfo property
txt1.TextInfo.Color = New Aspose.Pdf.Generator.Color("Blue")
txt1.TextInfo.FontName = "Helvetica"
' Create a new segment to be added to text object
Dim seg1 As Aspose.Pdf.Generator.Segment = txt1.Segments.Add()
' Create an image object in the section
Dim image1 As New Aspose.Pdf.Generator.Image(sec1)
' Set the path of image file
image1.ImageInfo.File = dataDir & Convert.ToString("aspose-logo.jpg")
' Set the type of image using ImageFileType enumeration
image1.ImageInfo.ImageFileType = Aspose.Pdf.Generator.ImageFileType.Jpeg
' Set the image width Information
image1.ImageInfo.FixWidth = 150
' Indicate seg1' S InlineParagraph is a image.
seg1.InlineParagraph = image1
' Create a new segment to be added to text object
Dim seg2 As Aspose.Pdf.Generator.Segment = txt1.Segments.Add("Pty Ltd.")
seg2.TextInfo.Color = New Aspose.Pdf.Generator.Color("Maroon")
' Save the Pdf
pdf1.Save(dataDir & Convert.ToString("ImageAndPageNumberInHeaderFooter_UsingInlineParagraph_out_.pdf"))
' For complete examples and data files, please go to https://github.com/aspose-pdf/Aspose.Pdf-for-.NET
' The path to the documents directory.
Dim dataDir As String = RunExamples.GetDataDir_AsposePdfGenerator_TechnicalArticles()
' Create a PDF object
Dim pdf As New Aspose.Pdf.Generator.Pdf()
' Create a section and add it to pdf document
Dim MainSection As Aspose.Pdf.Generator.Section = pdf.Sections.Add()
' Create an image object
Dim sample_image As New Aspose.Pdf.Generator.Image()
' Specify the image file path information
sample_image.ImageInfo.File = dataDir & Convert.ToString("barbara_gray.bmp")
' Specify the image file type
sample_image.ImageInfo.ImageFileType = Aspose.Pdf.Generator.ImageFileType.Bmp
' Specify the image width information equal to page width
sample_image.ImageInfo.FixWidth = MainSection.PageInfo.PageWidth - MainSection.PageInfo.Margin.Left - MainSection.PageInfo.Margin.Right
' Specify the image Height information equal to page Height
sample_image.ImageInfo.FixWidth = MainSection.PageInfo.PageHeight - MainSection.PageInfo.Margin.Top - MainSection.PageInfo.Margin.Bottom
' Create bitmap image object to load image information
Dim myimage As New Bitmap(dataDir & Convert.ToString("barbara_gray.bmp"))
' Check if the width of the image file is greater than Page width or not
If myimage.Width > MainSection.PageInfo.PageWidth Then
' If the Image width is greater than page width, then set the page orientation to Landscape
MainSection.IsLandscape = True
Else
' If the Image width is less than page width, then set the page orientation to Portrait
MainSection.IsLandscape = False
End If
' Add image to paragraphs collection of section
MainSection.Paragraphs.Add(sample_image)
' Save the resultant PDF
pdf.Save(dataDir & Convert.ToString("ConvertBMPImageToPdf_out_.pdf"))
' For complete examples and data files, please go to https://github.com/aspose-pdf/Aspose.Pdf-for-.NET
' The path to the documents directory.
Dim dataDir As String = RunExamples.GetDataDir_AsposePdfGenerator_TechnicalArticles()
' Instantiate a Pdf object by calling its empty constructor
Dim pdf1 As New Aspose.Pdf.Generator.Pdf()
' Create a section in the Pdf object
Dim sec1 As Aspose.Pdf.Generator.Section = pdf1.Sections.Add()
' Create an image object in the section
Dim image1 As New Aspose.Pdf.Generator.Image(sec1)
' Add image object into the Paragraphs collection of the section
sec1.Paragraphs.Add(image1)
' Set the path of image file
image1.ImageInfo.File = dataDir & Convert.ToString("aspose-logo.jpg")
' Set the type of image using ImageFileType enumeration
image1.ImageInfo.ImageFileType = Aspose.Pdf.Generator.ImageFileType.Jpeg
' Set image title
image1.ImageInfo.Title = "JPEG image"
' Save the Pdf file
pdf1.Save(dataDir & Convert.ToString("JPGImageToPdf_out_.pdf"))
' For complete examples and data files, please go to https://github.com/aspose-pdf/Aspose.Pdf-for-.NET
' The path to the documents directory.
Dim dataDir As String = RunExamples.GetDataDir_AsposePdfGenerator_TechnicalArticles()
' Get a list of tiff image files
Dim files As String() = System.IO.Directory.GetFiles(dataDir)
' Instantiate a Pdf object
Dim pdf1 As New Aspose.Pdf.Generator.Pdf()
' Navigate through the files and them in the pdf file
For Each myFile As String In files
' Load all tiff files in byte array
Dim fs As New FileStream(myFile, FileMode.Open, FileAccess.Read)
Dim tmpBytes As Byte() = New Byte(Convert.ToInt32(fs.Length - 1)) {}
fs.Read(tmpBytes, 0, Convert.ToInt32(fs.Length))
Dim mystream As New MemoryStream(tmpBytes)
Dim b As New Bitmap(mystream)
' Create a new section in the Pdf document
Dim sec1 As New Aspose.Pdf.Generator.Section(pdf1)
' Set margins so image will fit, etc.
sec1.PageInfo.Margin.Top = 5
sec1.PageInfo.Margin.Bottom = 5
sec1.PageInfo.Margin.Left = 5
sec1.PageInfo.Margin.Right = 5
sec1.PageInfo.PageWidth = (b.Width / b.HorizontalResolution) * 72
sec1.PageInfo.PageHeight = (b.Height / b.VerticalResolution) * 72
' Add the section in the sections collection of the Pdf document
pdf1.Sections.Add(sec1)
' Create an image object
Dim image1 As New Aspose.Pdf.Generator.Image(sec1)
' Add the image into paragraphs collection of the section
sec1.Paragraphs.Add(image1)
image1.ImageInfo.ImageFileType = Aspose.Pdf.Generator.ImageFileType.Tiff
' Set IsBlackWhite property to true for performance improvement
image1.ImageInfo.IsBlackWhite = True
' Set the ImageStream to a MemoryStream object
image1.ImageInfo.ImageStream = mystream
' Set desired image scale
image1.ImageScale = 0.95F
Next
' Save the Pdf
pdf1.Save(dataDir & Convert.ToString("PerformaceImprovement_out_.pdf"))
' For complete examples and data files, please go to https://github.com/aspose-pdf/Aspose.Pdf-for-.NET
' The path to the documents directory.
Dim dataDir As String = RunExamples.GetDataDir_AsposePdfGenerator_TechnicalArticles()
' Instantiate Pdf document object
Dim pdf1 As New Aspose.Pdf.Generator.Pdf()
' Create a section in the Pdf
Dim sec1 As Aspose.Pdf.Generator.Section = pdf1.Sections.Add()
' Instantiate a table object
Dim table1 As New Aspose.Pdf.Generator.Table()
' Add the table in paragraphs collection of the desired section
sec1.Paragraphs.Add(table1)
' Set with column widths of the table
table1.ColumnWidths = "120 270"
' Create MarginInfo object and set its left, bottom, right and top margins
Dim margin As New Aspose.Pdf.Generator.MarginInfo()
margin.Top = 5.0F
margin.Left = 5.0F
margin.Right = 5.0F
margin.Bottom = 5.0F
' Set the default cell padding to the MarginInfo object
table1.DefaultCellPadding = margin
' Create rows in the table and then cells in the rows
Dim row1 As Aspose.Pdf.Generator.Row = table1.Rows.Add()
' Create an image object
Dim logo As New Aspose.Pdf.Generator.Image()
' Specify the image file path
logo.ImageInfo.File = dataDir & Convert.ToString("aspose-logo.jpg")
' Specify the image Fixed Height
logo.ImageInfo.FixHeight = 120
' Specify the image Fixed Width
logo.ImageInfo.FixWidth = 110
row1.Cells.Add()
' Add the image to paragraphs collection of the table cell
row1.Cells(0).Paragraphs.Add(logo)
' Create string variables with text containing html tags
Dim TitleString As String = "<font face=""Arial"" size=6 color=""#101090""><b> Aspose.Pdf for .NET</b></font>"
' Create a text object to be added to the right of image
Dim TitleText As New Aspose.Pdf.Generator.Text(TitleString)
TitleText.IsHtmlTagSupported = True
row1.Cells.Add()
' Add the text paragraphs containing HTML text to the table cell
row1.Cells(1).Paragraphs.Add(TitleText)
' Set the vertical alignment of the row contents as Top
row1.VerticalAlignment = Aspose.Pdf.Generator.VerticalAlignmentType.Top
Dim BodyString1 As String = "<font face=""Arial"" size=2><br/>Aspose.Pdf for .NET is a non-graphical PDF® document reporting component that enables .NET applications to <b> create PDF documents from scratch </b> without utilizing Adobe Acrobat®. Aspose.Pdf for .NET is very affordably priced and offers a wealth of strong features including: compression, tables, graphs, images, hyperlinks, security and custom fonts. </font>"
' Add a text segment to segments collection of the text object
TitleText.Segments.Add(BodyString1)
' Create rows in the table and then cells in the rows
Dim SecondRow As Aspose.Pdf.Generator.Row = table1.Rows.Add()
SecondRow.Cells.Add()
' Set the row span value for Second row as 2
SecondRow.Cells(0).ColumnsSpan = 2
' Set the vertical alignment of the second row as Top
SecondRow.VerticalAlignment = Aspose.Pdf.Generator.VerticalAlignmentType.Top
Dim SecondRowString As String = "<font face=""Arial"" size=2>Aspose.Pdf for .NET supports the creation of PDF files through API and XML or XSL-FO templates. Aspose.Pdf for .NET is very easy to use and is provided with 14 fully featured demos written in both C# and Visual Basic.</font>"
Dim SecondRowText As New Aspose.Pdf.Generator.Text(SecondRowString)
SecondRowText.IsHtmlTagSupported = True
' Add the text paragraphs containing HTML text to the table cell
SecondRow.Cells(0).Paragraphs.Add(SecondRowText)
' Save the Pdf file
pdf1.Save(dataDir & Convert.ToString("PlacingTextAroundImage_out_.pdf"))
' For complete examples and data files, please go to https://github.com/aspose-pdf/Aspose.Pdf-for-.NET
' The path to the documents directory.
Dim dataDir As String = RunExamples.GetDataDir_AsposePdfGenerator_TechnicalArticles()
' Create an object of Pdf class
Dim pdf As New Aspose.Pdf.Generator.Pdf()
' Bind the source HTML file with Pdf object
pdf.BindHTML(File.ReadAllText(dataDir & Convert.ToString("Sample.htm")))
' Get traverse through each segment inside text paragraph
For Each seg As Aspose.Pdf.Generator.Segment In TryCast(pdf.Sections(0).Paragraphs(0), Aspose.Pdf.Generator.Text).Segments
' Verify that the segment URL value is not null
If seg.Hyperlink.Url IsNot Nothing Then
' Specify the LinkType of Segment object as none
seg.Hyperlink.LinkType = Aspose.Pdf.Generator.HyperlinkType.None
' Set the value of URL for segment object as blank
seg.Hyperlink.Url = ""
' Remove the Underline from segment
seg.TextInfo.IsUnderline = False
' Change font color to black instread of default Blue for Hyperlinks, you may also comment the following line to display in blue
seg.TextInfo.Color = New Aspose.Pdf.Generator.Color("Black")
End If
Next
' Save the resultant PDF
pdf.Save(dataDir & Convert.ToString("RemoveHyperlinksFromText_out_.pdf"))
' For complete examples and data files, please go to https://github.com/aspose-pdf/Aspose.Pdf-for-.NET
' The path to the documents directory.
Dim dataDir As String = RunExamples.GetDataDir_AsposePdfGenerator_TechnicalArticles()
' Instantiate a Pdf object by calling its empty constructor
Dim pdf As New Aspose.Pdf.Generator.Pdf()
' Retrieve names of all the Pdf files in a particular Directory
Dim fileEntries As String() = Directory.GetFiles(dataDir, "*.JPG")
Dim counter As Integer
For counter = 0 To fileEntries.Length - 2
' Create a section object
Dim section1 As Aspose.Pdf.Generator.Section = pdf.Sections.Add()
' Creat an image object
Dim image1 As New Aspose.Pdf.Generator.Image(section1)
image1.ImageInfo.File = fileEntries(counter)
image1.ImageInfo.ImageFileType = Aspose.Pdf.Generator.ImageFileType.Jpeg
' Create a BitMap object in order to get the information of image file
Dim myimage As New Bitmap(fileEntries(counter))
' Check if the width of the image file is greater than Page width or not
If myimage.Width > section1.PageInfo.PageWidth Then
' If the Image width is greater than page width, then set the page orientation to Landscape
section1.IsLandscape = True
Else
' If the Image width is less than page width, then set the page orientation to Portrait
section1.IsLandscape = False
End If
' Add the image to paragraphs collection of the PDF document
section1.Paragraphs.Add(image1)
Next
' Save the Pdf file
pdf.Save(dataDir & Convert.ToString("SetPageOrientation_out_.pdf"))
' For complete examples and data files, please go to https://github.com/aspose-pdf/Aspose.Pdf-for-.NET
' The path to the documents directory.
Dim dataDir As String = RunExamples.GetDataDir_AsposePdfGenerator_TechnicalArticles()
' Create Pdf Instance
Dim pdf As New Aspose.Pdf.Generator.Pdf()
' Create section object and add it to pdf object
Dim sec1 As Aspose.Pdf.Generator.Section = pdf.Sections.Add()
' Create a table instance
Dim mytable As New Aspose.Pdf.Generator.Table()
' Specify the default border for table object and set its color as Navy
mytable.DefaultCellBorder = New Aspose.Pdf.Generator.BorderInfo(CInt(Aspose.Pdf.Generator.BorderSide.All), 1.0F, New Aspose.Pdf.Generator.Color("Navy"))
' Specify the border information for table object
mytable.Border = New Aspose.Pdf.Generator.BorderInfo(CInt(Aspose.Pdf.Generator.BorderSide.All), 1.0F, New Aspose.Pdf.Generator.Color("Navy"))
' Define initial width information for table cells
mytable.ColumnWidths = "100 100"
' Create a row object and add it to table
Dim row1 As Aspose.Pdf.Generator.Row = mytable.Rows.Add()
' Create loop to add specify the number of columns to be added to table row
For Column_Counter As Integer = 1 To 7
' Create a cell object and add it to table row
Dim Cell As Aspose.Pdf.Generator.Cell = row1.Cells.Add("Cell (1," + Column_Counter.ToString() + ")")
Next
' Define the variable to keep record of number of columns in table
Dim TableColumn As Integer = 0
' Traverse through each table cell in row object
For Each InnerCell As Aspose.Pdf.Generator.Cell In row1.Cells
' Specify the width information for each column based on section objects margin and width values
' Set the width value as, get the total width of section and subtract left and right margin and divide
' It with total number of cells in a particular table row
mytable.SetColumnWidth(TableColumn, (sec1.PageInfo.PageWidth - sec1.PageInfo.Margin.Left - sec1.PageInfo.Margin.Right) / row1.Cells.Count)
' Increase the value of variable holding the column count information
TableColumn += 1
Next
' Add table to paragraphs collection of section
sec1.Paragraphs.Add(mytable)
' Save the resultant PDF document
pdf.Save(dataDir & Convert.ToString("SetTableColumnsWidth_out_.pdf"))
' For complete examples and data files, please go to https://github.com/aspose-pdf/Aspose.Pdf-for-.NET
' The path to the documents directory.
Dim dataDir As String = RunExamples.GetDataDir_AsposePdfGenerator_TechnicalArticles()
' Instantiate PDF instance by calling empty constructor
Dim pdfConv As New Aspose.Pdf.Generator.Pdf()
' Create a section in the pdf document
Dim sec1 As Aspose.Pdf.Generator.Section = pdfConv.Sections.Add()
' Create a Header Section of the PDF file
Dim header As New Aspose.Pdf.Generator.HeaderFooter(sec1)
' Set the Odd Header for the PDF file
sec1.OddHeader = header
' Set the top margin for the header section
header.Margin.Top = 20
' Instantiate a table object
Dim tab1 As New Aspose.Pdf.Generator.Table()
' Add the table in paragraphs collection of the desired section
header.Paragraphs.Add(tab1)
' Set default cell border using BorderInfo object
tab1.DefaultCellBorder = New Aspose.Pdf.Generator.BorderInfo(CInt(Aspose.Pdf.Generator.BorderSide.All), 0.1F)
' Set with column widths of the table
tab1.ColumnWidths = "60 300"
Dim img As New Aspose.Pdf.Generator.Image()
img.ImageInfo.File = dataDir & Convert.ToString("aspose-logo.jpg")
img.ImageInfo.ImageFileType = Aspose.Pdf.Generator.ImageFileType.Jpeg
' Create rows in the table and then cells in the rows
Dim row1 As Aspose.Pdf.Generator.Row = tab1.Rows.Add()
row1.Cells.Add("Table in Header Section")
row1.BackgroundColor = New Aspose.Pdf.Generator.Color("#CCCCCC")
row1.DefaultCellTextInfo.Color = New Aspose.Pdf.Generator.Color("#6699FF")
' Set the font face for the text in the row
row1.DefaultCellTextInfo.FontName = "Helvetica"
' Set the row span value for first row as 2
tab1.Rows(0).Cells(0).ColumnsSpan = 2
' Create rows in the table and then cells in the rows
Dim row2 As Aspose.Pdf.Generator.Row = tab1.Rows.Add()
' Set the background color for Row2
row2.BackgroundColor = New Aspose.Pdf.Generator.Color("#FFFFCC")
' Add the cell which holds the image
Dim cell2 As Aspose.Pdf.Generator.Cell = row2.Cells.Add()
' Set the image width to 60
img.ImageInfo.FixWidth = 60
Dim txt2 As New Aspose.Pdf.Generator.Text()
' Add a text segment to hold image and text together
Dim seg1 As New Aspose.Pdf.Generator.Segment()
seg1.InlineParagraph = img
txt2.Segments.Add(seg1)
' Add the image to the table cell
cell2.Paragraphs.Add(txt2)
row2.Cells.Add("Penguin is looking very lovely !")
row2.DefaultCellTextInfo.FontName = "Helvetica"
' Set the vertical allignment of the text as center alligned
row2.Cells(1).VerticalAlignment = Aspose.Pdf.Generator.VerticalAlignmentType.Center
row2.Cells(1).Alignment = Aspose.Pdf.Generator.AlignmentType.Center
' Save the Pdf file
pdfConv.Save(dataDir & Convert.ToString("TableInHeaderFooterSection_out_.pdf"))
' For complete examples and data files, please go to https://github.com/aspose-pdf/Aspose.Pdf-for-.NET
' The path to the documents directory.
Dim dataDir As String = RunExamples.GetDataDir_AsposePdfGenerator_Text()
' Instantiate a pdf document
Dim pdf As New Aspose.Pdf.Generator.Pdf()
' Create Section
Dim sec As Aspose.Pdf.Generator.Section = pdf.Sections.Add()
' Create Text Paragraph
Dim text As New Aspose.Pdf.Generator.Text()
' Create Segment
Dim segment As New Aspose.Pdf.Generator.Segment("This is the First Segment")
' Create EndNote and Assign an EndNote property of Segment to its object
Dim endnote1 As New Aspose.Pdf.Generator.EndNote("Endnotes for First Segment")
segment.EndNote = endnote1
' Add Segment in Text Paragraph
text.Segments.Add(segment)
' Add Text in Section
sec.Paragraphs.Add(text)
' Save the document
' For complete examples and data files, please go to https://github.com/aspose-pdf/Aspose.Pdf-for-.NET
' The path to the documents directory.
Dim dataDir As String = RunExamples.GetDataDir_AsposePdfGenerator_Text()
' Instantiate a pdf document
Dim pdf As New Aspose.Pdf.Generator.Pdf()
' Create Section
Dim sec As Aspose.Pdf.Generator.Section = pdf.Sections.Add()
' Create Text Paragraph
Dim text As New Aspose.Pdf.Generator.Text()
' Create Segment
Dim segment As New Aspose.Pdf.Generator.Segment("This is the First Segment")
' Create FootNote and Assign FootNote property of Segment to its object
segment.FootNote = New Aspose.Pdf.Generator.FootNote("Footnotes for First Segment")
' Add Segment in Text Paragraph
text.Segments.Add(segment)
' Add Text in Section
sec.Paragraphs.Add(text)
' Save the document
' For complete examples and data files, please go to https://github.com/aspose-pdf/Aspose.Pdf-for-.NET
' The path to the documents directory.
Dim dataDir As String = RunExamples.GetDataDir_AsposePdfGenerator_Text()
' Create directory if it is not already present.
Dim IsExists As Boolean = System.IO.Directory.Exists(dataDir)
If (Not IsExists) Then
System.IO.Directory.CreateDirectory(dataDir)
End If
' Instantiate Pdf instance by calling its empty constructor
Dim pdf1 As New Aspose.Pdf.Generator.Pdf()
' Create a new section in the Pdf object
Dim sec1 As Aspose.Pdf.Generator.Section = pdf1.Sections.Add()
' Set text color to blue in the whole section
sec1.TextInfo.Color = New Aspose.Pdf.Generator.Color("Blue")
' Add 1st paragraph (inheriting the text format settings from the section)
' To the section
sec1.Paragraphs.Add(New Aspose.Pdf.Generator.Text(sec1, "paragraph 1 "))
' Add 2nd paragraph (inheriting the text format settings from the section)
' To the section
sec1.Paragraphs.Add(New Aspose.Pdf.Generator.Text(sec1, "paragraph 2"))
' Create 3rd paragraph (inheriting the text format settings from the section)
Dim t3 As New Aspose.Pdf.Generator.Text(sec1)
' Create a segment "seg1" in the paragraph "t3"
Dim seg1 As New Aspose.Pdf.Generator.Segment(t3)
' Assign some content to the segment
seg1.Content = "paragraph 3 segment 1"
' Set the color of the segment to red
seg1.TextInfo.Color = New Aspose.Pdf.Generator.Color("Red")
' Add segment (with red text color) to the paragraph
t3.Segments.Add(seg1)
' Create a new segment "seg2" in the paragraph "t3"
Dim seg2 As New Aspose.Pdf.Generator.Segment(t3)
' Assign some content to the segment
seg2.Content = "paragraph 3 segment 2"
' Set the color of the segment to green
seg2.TextInfo.Color = New Aspose.Pdf.Generator.Color("Green")
' Add segment (with green text color) to the paragraph
t3.Segments.Add(seg2)
' Add 3rd text paragraph to the section with overridden text format settings
sec1.Paragraphs.Add(t3)
' Add 4th paragraph (inheriting the text format settings from the section)
' To the section
sec1.Paragraphs.Add(New Aspose.Pdf.Generator.Text(sec1, "paragraph 4"))
Dim info1 As Aspose.Pdf.Generator.TextInfo = TryCast(t3.TextInfo.Clone(), Aspose.Pdf.Generator.TextInfo)
' Modify the font side to 16 pt
info1.FontSize = 16
' Set TextInfo property of the text paragraph to newly cloned instance "info1"
t3.TextInfo = info1
' Save the document
pdf1.Save(dataDir & "ChangeTextFormat_out_.pdf")
' For complete examples and data files, please go to https://github.com/aspose-pdf/Aspose.Pdf-for-.NET
' The path to the documents directory.
Dim dataDir As String = RunExamples.GetDataDir_AsposePdfGenerator_Text()
' Instantiate Pdf instance by calling it empty constructor
Dim pdf As New AP.Generator.Pdf()
' Create a text object
Dim text1 As New AP.Generator.Text("This #$TAB is a example for custom TAB stop positions.")
' Assign an instance of TabStops to the TabStops property of text object
text1.TabStops = New AP.Generator.TabStops()
' Call Add method of TabStops and pass a specified position as argument
text1.TabStops.Add(150)
' Call Add method with specified position and tab leader type as Dot
text1.TabStops.Add(350, AP.Generator.TabLeaderType.Dot)
pdf.Save(dataDir & Convert.ToString("CustomTabStops_out_.pdf"))
' For complete examples and data files, please go to https://github.com/aspose-pdf/Aspose.Pdf-for-.NET
' Create a text object in a section
Dim t1 As New AP.Generator.Text(sec1, "Arial Bold MT")
' Set the font name of a segment in the text object
t1.Segments(0).TextInfo.FontName = "Arial-BoldMT"
' Set the PFM file for the text segment
t1.Segments(0).TextInfo.FontPfmFile = "_AB_____.PFM"
' Set the font encoding file for the text segment
t1.Segments(0).TextInfo.FontEncodingFile = "CP1250.txt"
' Set the font encoding name of the text segment
t1.Segments(0).TextInfo.FontEncoding = "cp1250"
' Set the font outline file for the text segment
t1.Segments(0).TextInfo.FontOutlineFile = "_AB_____.PFB"
' Set IsFontEmbedded to true
t1.Segments(0).TextInfo.IsFontEmbedded = True
' For complete examples and data files, please go to https://github.com/aspose-pdf/Aspose.Pdf-for-.NET
' Create a text object in the section
Dim t1 As New AP.Generator.Text(sec1, "Courier New Bold font")
' Set font name of a specific text segment to courier new
t1.Segments(0).TextInfo.FontName = "Courier New"
' Set the font to bold
t1.Segments(0).TextInfo.IsTrueTypeFontBold = True
' For complete examples and data files, please go to https://github.com/aspose-pdf/Aspose.Pdf-for-.NET
' Create a text object in the section
Dim t1 As New AP.Generator.Text(sec1, "Courier New Bold font")
' Set font name of a specific text segment to courier new
t1.Segments(0).TextInfo.FontName = "Courier New"
' For complete examples and data files, please go to https://github.com/aspose-pdf/Aspose.Pdf-for-.NET
' The path to the documents directory.
Dim dataDir As String = RunExamples.GetDataDir_AsposePdfGenerator_Text()
' Instantiate Pdf instance by calling it empty constructor
Dim pdf As New AP.Generator.Pdf()
' Set the property to make your application run faster. It will help load the Truetype font faster
pdf.IsTruetypeFontMapCached = True
' Create a section in the Pdf object
Dim sec1 As AP.Generator.Section = pdf.Sections.Add()
' To assign a unicode character by it' S coding
Dim t1 As New AP.Generator.Text("&H25A0")
' Specify the font face name for first segment in text object
t1.Segments(0).TextInfo.FontName = "Times New Roman"
' Specify that first segment in text is UniCode
t1.Segments(0).TextInfo.IsUnicode = True
' Add text to paragraphs collection of section object
sec1.Paragraphs.Add(t1)
' Save the PDF document
pdf.Save(dataDir & Convert.ToString("Unicode_out_.pdf"))
' For complete examples and data files, please go to https://github.com/aspose-pdf/Aspose.Pdf-for-.NET
' The path to the documents directory.
Dim dataDir As String = RunExamples.GetDataDir_AsposePdfGenerator_Text()
' Instantiate a pdf document
Dim pdf1 As New Aspose.Pdf.Generator.Pdf()
' Create a section in the pdf document
Dim sec1 As Aspose.Pdf.Generator.Section = pdf1.Sections.Add()
' Create a string variable with text containing hyperlink tag
Dim string1 As String = "<a href=""http://www.aspose.com/"">This is a test</a>"
' Create text paragraph containing HTML hyperlink tag
Dim text1 As New Aspose.Pdf.Generator.Text(string1)
text1.IsHtmlTagSupported = True
' Add the text paragraph containing HTML text to the section
sec1.Paragraphs.Add(text1)
' Save the document
' For complete examples and data files, please go to https://github.com/aspose-pdf/Aspose.Pdf-for-.NET
' The path to the documents directory.
Dim dataDir As String = RunExamples.GetDataDir_AsposePdfGenerator_Text()
' Instantiate Pdf instance by calling its empty constructor
Dim pdf1 As New AP.Generator.Pdf()
' Create a new section in the Pdf object
Dim sec1 As AP.Generator.Section = pdf1.Sections.Add()
' Set text color to blue in the whole section
sec1.TextInfo.Color = New AP.Generator.Color("Blue")
' Add 1st paragraph (inheriting the text format settings from the section)
' To the section
sec1.Paragraphs.Add(New AP.Generator.Text(sec1, "paragraph 1 "))
' Add 2nd paragraph (inheriting the text format settings from the section)
' To the section
sec1.Paragraphs.Add(New AP.Generator.Text(sec1, "paragraph 2"))
' Create 3rd paragraph (inheriting the text format settings from the section)
Dim t3 As New AP.Generator.Text(sec1)
' Create a segment "seg1" in the paragraph "t3"
Dim seg1 As New AP.Generator.Segment(t3)
' Assign some content to the segment
seg1.Content = "paragraph 3 segment 1"
' Set the color of the segment to red
seg1.TextInfo.Color = New AP.Generator.Color("Red")
' Add segment (with red text color) to the paragraph
t3.Segments.Add(seg1)
' Create a new segment "seg2" in the paragraph "t3"
Dim seg2 As New AP.Generator.Segment(t3)
' Assign some content to the segment
seg2.Content = "paragraph 3 segment 2"
' Set the color of the segment to green
seg2.TextInfo.Color = New AP.Generator.Color("Green")
' Add segment (with green text color) to the paragraph
t3.Segments.Add(seg2)
' Add 3rd text paragraph to the section with overridden text format settings
sec1.Paragraphs.Add(t3)
' Add 4th paragraph (inheriting the text format settings from the section)
' To the section
sec1.Paragraphs.Add(New AP.Generator.Text(sec1, "paragraph 4"))
dataDir = dataDir & Convert.ToString("InheritTextFormat_out_.pdf")
' Save the document
pdf1.Save(dataDir)
' For complete examples and data files, please go to https://github.com/aspose-pdf/Aspose.Pdf-for-.NET
' The path to the documents directory.
Dim dataDir As String = RunExamples.GetDataDir_AsposePdfGenerator_Text()
' Instantiate Pdf instance by calling its empty constructor
Dim pdf1 As New AP.Generator.Pdf()
' Create section object and add it to sections collection of PDF
Dim sec1 As AP.Generator.Section = pdf1.Sections.Add()
' Create a text object
Dim text1 As New AP.Generator.Text()
' Add text object to paragraphs collection of section
sec1.Paragraphs.Add(text1)
' Add sample text to segments collection of text object
text1.Segments.Add("This is a test for inline")
' Create segment 2 and add it to segements collection of text object
Dim seg2 As AP.Generator.Segment = text1.Segments.Add()
' Create a Image object to contain logo gif.
Dim img1 As New AP.Generator.Image()
' Specify the image file path
img1.ImageInfo.File = dataDir & Convert.ToString("aspose-logo.jpg")
' Indicate seg2' S InlineParagraph is a image.
seg2.InlineParagraph = img1
dataDir = dataDir & Convert.ToString("InlineImage_out_.pdf")
' Create the result PDF Document
pdf1.Save(dataDir)
' For complete examples and data files, please go to https://github.com/aspose-pdf/Aspose.Pdf-for-.NET
' The path to the documents directory.
Dim dataDir As String = RunExamples.GetDataDir_AsposePdfGenerator_Text()
' Create Pdf Instance
Dim pdf1 As New Aspose.Pdf.Generator.Pdf()
' Add A Section
Dim sec1 As Aspose.Pdf.Generator.Section = pdf1.Sections.Add()
' Add Text Paragraph
Dim text1 As New Aspose.Pdf.Generator.Text()
' Add Text Paragraph to paragraphs collection of section
sec1.Paragraphs.Add(text1)
' Add a segment with sample text to segments collection of Text Paragraph
text1.Segments.Add("This is a test for inline radiobutton: ")
' Specify Inline Radio button field name
text1.InlineRadioButtonFieldName = "inlineradio"
' Specify the checked index for inline radio button
text1.InlineRadioButtonCheckedIndex = 1
' Add segments
Dim seg1 As Aspose.Pdf.Generator.Segment = text1.Segments.Add()
' 1st Radio Button and set the Inline Paragraph property of segment equal to radioButton
Dim radio1 As New Aspose.Pdf.Generator.RadioButton()
seg1.InlineParagraph = radio1
Dim seg11 As Aspose.Pdf.Generator.Segment = text1.Segments.Add("radio1 ")
Dim seg2 As Aspose.Pdf.Generator.Segment = text1.Segments.Add()
Dim radio2 As New Aspose.Pdf.Generator.RadioButton()
radio2.ID = "radio2"
seg2.InlineParagraph = radio2
Dim seg22 As Aspose.Pdf.Generator.Segment = text1.Segments.Add("radio2 ")
Dim seg3 As Aspose.Pdf.Generator.Segment = text1.Segments.Add()
Dim radio3 As New Aspose.Pdf.Generator.RadioButton()
seg3.InlineParagraph = radio3
Dim seg33 As Aspose.Pdf.Generator.Segment = text1.Segments.Add("radio3 ")
' Save the document
' For complete examples and data files, please go to https://github.com/aspose-pdf/Aspose.Pdf-for-.NET
' Create a text object in a section
Dim t1 As New AP.Generator.Text(sec1, "Arial Bold MT")
' Set the font name of a segment in the text object
t1.Segments(0).TextInfo.FontName = "Arial-BoldMT"
' Set the PFM file for the text segment
t1.Segments(0).TextInfo.FontPfmFile = "_AB_____.PFM"
' Set the font encoding file for the text segment
t1.Segments(0).TextInfo.FontEncodingFile = "CP1250.txt"
' Set the font encoding name of the text segment
t1.Segments(0).TextInfo.FontEncoding = "cp1250"
' For complete examples and data files, please go to https://github.com/aspose-pdf/Aspose.Pdf-for-.NET
' The path to the documents directory.
Dim dataDir As String = RunExamples.GetDataDir_AsposePdfGenerator_Text()
' Instantiate Pdf instance by calling it empty constructor
Dim pdf1 As New AP.Generator.Pdf()
' Create a section in the pdf object
Dim sec1 As AP.Generator.Section = pdf1.Sections.Add()
' Create a HeaderFooter object for the section
Dim hf As New AP.Generator.HeaderFooter(sec1)
' Set the HeaderFooter object to odd and even footers
sec1.OddFooter = InlineAssignHelper(sec1.EvenFooter, hf)
' Add a text paragraph containing current page number of total number of pages
hf.Paragraphs.Add(New AP.Generator.Text(hf, "page $p of $P"))
dataDir = dataDir & Convert.ToString("ReplaceableSymbols_out_.pdf")
' Create the result PDF Document
pdf1.Save(dataDir)
' For complete examples and data files, please go to https://github.com/aspose-pdf/Aspose.Pdf-for-.NET
' The path to the documents directory.
Dim dataDir As String = RunExamples.GetDataDir_AsposePdfGenerator_Text()
' Instantiate Pdf instance by calling it empty constructor
Dim pdf1 As New AP.Generator.Pdf()
' Create a section in the Pdf object
Dim sec1 As AP.Generator.Section = pdf1.Sections.Add()
' Create a sample text paragraph
Dim text1 As New AP.Generator.Text("page 1")
' Specify the ID for text paragraph
text1.ID = "page1"
' Add text to paragraphs collection of section
sec1.Paragraphs.Add(text1)
' Add a new text paragraph with symbol to print page number information for text paragraph with ID page4
sec1.Paragraphs.Add(New AP.Generator.Text("The last page is #$REFPAGE(page4)."))
' Create a new Text paragraph with sample text
Dim text2 As New AP.Generator.Text("page 2")
' Specify the ID for text paragraph
text2.ID = "page2"
' Specify that text2 is first paragraph of section
text2.IsFirstParagraph = True
' Add text paragraph to paragraphs collection of section object
sec1.Paragraphs.Add(text2)
Dim text3 As New AP.Generator.Text("page 3")
text3.ID = "page3"
text3.IsFirstParagraph = True
sec1.Paragraphs.Add(text3)
Dim sec2 As AP.Generator.Section = pdf1.Sections.Add()
Dim text4 As New AP.Generator.Text("page 4")
text4.ID = "page4"
sec2.Paragraphs.Add(text4)
pdf1.Save(dataDir & Convert.ToString("test_out_.pdf"))
' For complete examples and data files, please go to https://github.com/aspose-pdf/Aspose.Pdf-for-.NET
' The path to the documents directory.
Dim dataDir As String = RunExamples.GetDataDir_AsposePdfGenerator_Text()
' Instantiate Pdf instance by calling it empty constructor
Dim pdf As New AP.Generator.Pdf()
' Create a section in the Pdf object
pdf.Sections.Add()
pdf.IsTruetypeFontMapCached = True
' Specify the location where to save TruetypeFontMap.xml
pdf.TruetypeFontMapPath = dataDir & Convert.ToString("")
' Create a text object and pass the string object carrying arabic text in it
Dim text1 As New AP.Generator.Text()
' Create a segment and add it to segments collection of text object
Dim seg0 As AP.Generator.Segment = text1.Segments.Add()
' Specify contents for segment
seg0.Content = "أسبوز هو بائع عنصر ال"
Dim seg1 As AP.Generator.Segment = text1.Segments.Add()
seg1.Content = ".NET"
Dim seg2 As AP.Generator.Segment = text1.Segments.Add()
seg2.Content = "البارز"
' Enable text alignment from right to left
seg0.TextInfo.IsRightToLeft = True
seg1.TextInfo.IsRightToLeft = False
' Default
seg2.TextInfo.IsRightToLeft = True
' Enable unicode character set for the text segment
seg0.TextInfo.IsUnicode = True
seg1.TextInfo.IsUnicode = True
seg2.TextInfo.IsUnicode = True
' Set Font Name
seg0.TextInfo.FontName = "Times New Roman"
seg1.TextInfo.FontName = "Times New Roman"
seg2.TextInfo.FontName = "Times New Roman"
' Set font size
seg0.TextInfo.FontSize = 14
seg1.TextInfo.FontSize = 14
seg2.TextInfo.FontSize = 14
' Align text to right hand side using AlignmentType enumeration
' Make the text right aligned(The meaning of Alignment.Left and AlignmentType.Right are //exchanged when processing RTL language).
text1.TextInfo.Alignment = AP.Generator.AlignmentType.Left
pdf.Sections(0).Paragraphs.Add(text1)
pdf.IsRtlInSegmentMode = True
' Default
pdf.Save(dataDir & Convert.ToString("RTLLanguages_out_.pdf"))
' For complete examples and data files, please go to https://github.com/aspose-pdf/Aspose.Pdf-for-.NET
' The path to the documents directory.
Dim dataDir As String = RunExamples.GetDataDir_AsposePdfGenerator_Text()
' Instantiate Pdf instance by calling its empty constructor
Dim pdf1 As New Aspose.Pdf.Generator.Pdf()
' Create a section in the Pdf object
Dim sec1 As Aspose.Pdf.Generator.Section = pdf1.Sections.Add()
' Create 1st text paragraph
Dim text1 As New Aspose.Pdf.Generator.Text(sec1, "FillText mode")
' Set rendering mode to FillText
text1.TextInfo.RenderingMode = Aspose.Pdf.Generator.RenderingMode.FillText
' Create 2nd text paragraph
Dim text2 As New Aspose.Pdf.Generator.Text(sec1, "StrokeText mode (outline)")
' Set rendering mode to StrokeText
text2.TextInfo.RenderingMode = Aspose.Pdf.Generator.RenderingMode.StrokeText
' Create 3rd text paragraph
Dim text3 As New Aspose.Pdf.Generator.Text(sec1, "FillStrokeText mode")
' Set rendering mode to FillStrokeText
text3.TextInfo.RenderingMode = Aspose.Pdf.Generator.RenderingMode.FillStrokeText
' Create 4th text paragraph
Dim text4 As New Aspose.Pdf.Generator.Text(sec1, "InvisibleText mode")
' Set rendering mode to InvisibleText
text4.TextInfo.RenderingMode = Aspose.Pdf.Generator.RenderingMode.InvisibleText
' Add 1st, 2nd, 3rd and 4th text paragraphs to the section
sec1.Paragraphs.Add(text1)
sec1.Paragraphs.Add(text2)
sec1.Paragraphs.Add(text3)
sec1.Paragraphs.Add(text4)
' Save the Pdf
pdf1.Save(dataDir & "SetRenderingMode_out_.pdf")
' For complete examples and data files, please go to https://github.com/aspose-pdf/Aspose.Pdf-for-.NET
' The path to the documents directory.
Dim dataDir As String = RunExamples.GetDataDir_AsposePdfGenerator_Text()
' Create directory if it is not already present.
Dim IsExists As Boolean = System.IO.Directory.Exists(dataDir)
If (Not IsExists) Then
System.IO.Directory.CreateDirectory(dataDir)
End If
' Instantiate Pdf instance by calling its empty constructor
Dim pdf1 As New Aspose.Pdf.Generator.Pdf()
' Create a section in the Pdf object
Dim sec1 As Aspose.Pdf.Generator.Section = pdf1.Sections.Add()
' Create a text paragraph
Dim text1 As New Aspose.Pdf.Generator.Text(sec1, "Hello Aspose.Pdf")
' Set the BackgroundColor of the text paragraph to Red
text1.TextInfo.BackgroundColor = New Aspose.Pdf.Generator.Color("Red")
' Add the text paragraph to the section
sec1.Paragraphs.Add(text1)
' Save the Pdf
pdf1.Save(dataDir & "SetTextBackgroundColor_out_.pdf")
' For complete examples and data files, please go to https://github.com/aspose-pdf/Aspose.Pdf-for-.NET
' The path to the documents directory.
Dim dataDir As String = RunExamples.GetDataDir_AsposePdfGenerator_Text()
' Create directory if it is not already present.
Dim IsExists As Boolean = System.IO.Directory.Exists(dataDir)
If (Not IsExists) Then
System.IO.Directory.CreateDirectory(dataDir)
End If
' Instantiate Pdf object by calling its empty constructor
Dim pdf1 As New Aspose.Pdf.Generator.Pdf()
' Create a section in the Pdf object
Dim sec1 As Aspose.Pdf.Generator.Section = pdf1.Sections.Add()
' Create a new text paragraph with an initial text segment "Aspose"
Dim text1 As New Aspose.Pdf.Generator.Text(sec1, "Aspose")
' Add the text paragraph to the section
sec1.Paragraphs.Add(text1)
' Create a new text segment into the text paragraph
Dim seg2 As Aspose.Pdf.Generator.Segment = text1.Segments.Add("TM")
' Set the vertical alignment of text segment "seg2" to Topline by setting
' IsBaseline property ot seg2.TextInfo to true
seg2.TextInfo.IsBaseline = False
' Set the font size information for the segment
seg2.TextInfo.FontSize = 5
' Save the Pdf
pdf1.Save(dataDir & "SetVerticalAlignment_out_.pdf")
' For complete examples and data files, please go to https://github.com/aspose-pdf/Aspose.Pdf-for-.NET
' The path to the documents directory.
Dim dataDir As String = RunExamples.GetDataDir_AsposePdfGenerator_Text()
' Instantiate a pdf document
Dim pdf1 As New Aspose.Pdf.Generator.Pdf()
' Create a section in the pdf document
Dim sec1 As Aspose.Pdf.Generator.Section = pdf1.Sections.Add()
' Create a string variable with html text containing Sub & Sup tags
Dim string1 As String = "<FONT face=""Times New Roman"" size=18>HARBIN<sup>[1234]</sup> : An unexpected stoppage of water<sub>[abcd]</sub> supply sparked <sup> rumours of a contaminated river</sup> and led to a run on city <sub>supermarkets storing bottled water</sub> yesterday.</FONT>"
' Create text paragraph containing HTML text
Dim text1 As New Aspose.Pdf.Generator.Text(string1)
text1.IsHtmlTagSupported = True
' Add the text paragraph containing HTML text to the section
sec1.Paragraphs.Add(text1)
' Save the document
' For complete examples and data files, please go to https://github.com/aspose-pdf/Aspose.Pdf-for-.NET
' The path to the documents directory.
Dim dataDir As String = RunExamples.GetDataDir_AsposePdfGenerator_Text()
' Instantiate Pdf instance by calling it empty constructor
Dim pdf1 As New AP.Generator.Pdf()
' Create a section in the Pdf object
Dim sec1 As AP.Generator.Section = pdf1.Sections.Add()
' Create a text paragraph inheriting text format settings from the section
Dim text1 As New AP.Generator.Text(sec1)
' Add the text paragraph to the section
sec1.Paragraphs.Add(text1)
' Create 1st text segment
Dim s1 As New AP.Generator.Segment("183")
' Set the font name to the TextInfo.FontName property of segment
s1.TextInfo.FontName = "Symbol"
' Add 1st text segment to the text paragraph
text1.Segments.Add(s1)
' Create 2nd text segment
Dim s2 As New AP.Generator.Segment(" the first item")
' Add 2nd text segment to the text paragraph
text1.Segments.Add(s2)
dataDir = dataDir & Convert.ToString("SymbolFont_out_.pdf")
' Create the result PDF Document
pdf1.Save(dataDir)
' For complete examples and data files, please go to https://github.com/aspose-pdf/Aspose.Pdf-for-.NET
' The path to the documents directory.
Dim dataDir As String = RunExamples.GetDataDir_AsposePdfGenerator_Text()
' Instantiate Pdf pbject by calling its empty constructor
Dim pdf1 As New AP.Generator.Pdf()
' Create a new section in the Pdf object
Dim sec1 As AP.Generator.Section = pdf1.Sections.Add()
' Set the left margin of the section
sec1.PageInfo.Margin.Left = 110
' Set the right margin of the section
sec1.PageInfo.Margin.Right = 120
' Create a new text paragraph and pass the text to its constructor as argument
Dim t2 As New AP.Generator.Text("A bool value that indicates" + "whether the TrueType font is bold. " + "This attribute is valid for TrueType fonts only.")
' Set the font size of the text in a text segment
t2.Segments(0).TextInfo.FontSize = 16
' Set the left margin of the text paragraph
t2.Margin.Left = 60
' Set the first line indentation of the text paragraph to a negative value for
' Producing the effect of left hanging text paragraph
t2.FirstLineIndent = -6
' Add this left hanging text paragraph to the section
sec1.Paragraphs.Add(t2)
dataDir = dataDir & Convert.ToString("LeftHangingTextParagraph_out_.pdf")
' Save the pdf file
pdf1.Save(dataDir)
' For complete examples and data files, please go to https://github.com/aspose-pdf/Aspose.Pdf-for-.NET
' The path to the documents directory.
Dim dataDir As String = RunExamples.GetDataDir_AsposePdfGenerator_Text()
' Instantiate Pdf instance by calling its empty constructor
Dim pdf1 As New Aspose.Pdf.Generator.Pdf()
' Create a section in the Pdf object
Dim sec1 As Aspose.Pdf.Generator.Section = pdf1.Sections.Add()
' Create 1st text paragraph
Dim text1 As New Aspose.Pdf.Generator.Text(sec1, "Text underline")
' Set IsUnderline property of Text.TextInfo to true
text1.TextInfo.IsUnderline = True
' Create 2nd text paragraph
Dim text2 As New Aspose.Pdf.Generator.Text(sec1, "Text overline")
' Set IsOverline property of Text.TextInfo to true
text2.TextInfo.IsOverline = True
' Create 3rd text paragraph
Dim text3 As New Aspose.Pdf.Generator.Text(sec1, "Text strike out")
' Set IsStrikeOut property of Text.TextInfo to true
text3.TextInfo.IsStrikeOut = True
' Add 1st, 2nd and 3rd text paragraphs to the section
sec1.Paragraphs.Add(text1)
sec1.Paragraphs.Add(text2)
sec1.Paragraphs.Add(text3)
' Save the Pdf
pdf1.Save(dataDir & "UnderlineOverlineStrike_out_.pdf")
' For complete examples and data files, please go to https://github.com/aspose-pdf/Aspose.Pdf-for-.NET
' The path to the documents directory.
Dim dataDir As String = RunExamples.GetDataDir_AsposePdfGenerator_UtilityFeatures()
' Instantiate the Pdf instance
Dim pdf1 As New Aspose.Pdf.Generator.Pdf()
' Set the value that PDF document will be Bookmarked
pdf1.IsBookmarked = True
' Create Section object and add it to PDF
Dim sec1 As Aspose.Pdf.Generator.Section = pdf1.Sections.Add()
Dim heading1 As New Aspose.Pdf.Generator.Heading(pdf1, sec1, 1)
Dim segment1 As New Aspose.Pdf.Generator.Segment(heading1)
heading1.Segments.Add(segment1)
heading1.IsAutoSequence = True
segment1.Content = "this is heading of level 1"
sec1.Paragraphs.Add(heading1)
Dim heading2 As New Aspose.Pdf.Generator.Heading(pdf1, sec1, 2)
Dim segment2 As New Aspose.Pdf.Generator.Segment(heading2)
heading2.Segments.Add(segment2)
heading2.IsAutoSequence = True
segment2.Content = "this is heading of level 2"
sec1.Paragraphs.Add(heading2)
Dim heading3 As New Aspose.Pdf.Generator.Heading(pdf1, sec1, 1)
Dim segment3 As New Aspose.Pdf.Generator.Segment(heading3)
heading3.Segments.Add(segment3)
heading3.IsAutoSequence = False
heading3.LabelWidth = 60
heading3.UserLabel = "bullet1"
segment3.Content = "this is bullet style 1"
sec1.Paragraphs.Add(heading3)
dataDir = dataDir & Convert.ToString("AddBookmark_out_.pdf")
pdf1.Save(dataDir)
' For complete examples and data files, please go to https://github.com/aspose-pdf/Aspose.Pdf-for-.NET
' The path to the documents directory.
Dim dataDir As String = RunExamples.GetDataDir_AsposePdfGenerator_UtilityFeatures()
' Instantiate Pdf instance by calling its empty constructor
Dim pdf1 As New Aspose.Pdf.Generator.Pdf()
' Create a list section
Dim tocSection As New Aspose.Pdf.Generator.ListSection("Table Of Contents")
' Set its list type as table of of contents
tocSection.ListType = Aspose.Pdf.Generator.ListType.TableOfContents
' Add the list section to the sections collection of the Pdf document
pdf1.Sections.Add(tocSection)
dataDir = dataDir & Convert.ToString("AddingList_out_.pdf")
' Save the Pdf
pdf1.Save(dataDir)
' For complete examples and data files, please go to https://github.com/aspose-pdf/Aspose.Pdf-for-.NET
' Set the length of list levels to 3 and set their left margins and text formats
tocSection.ListFormatArray.Length = 3
tocSection.ListFormatArray(0).LeftMargin = 0
tocSection.ListFormatArray(0).TextInfo.FontSize = 16
tocSection.ListFormatArray(0).TextInfo.IsTrueTypeFontBold = True
tocSection.ListFormatArray(1).LeftMargin = 16
tocSection.ListFormatArray(1).TextInfo.FontSize = 14
tocSection.ListFormatArray(2).LeftMargin = 32
tocSection.ListFormatArray(2).TextInfo.FontSize = 12
' For complete examples and data files, please go to https://github.com/aspose-pdf/Aspose.Pdf-for-.NET
' Define the format of the four levels list by setting the left margins and
' Text format settings of each level
tocSection.ListFormatArray.Length = 4
tocSection.ListFormatArray(0).LeftMargin = 0
tocSection.ListFormatArray(0).TextInfo.IsTrueTypeFontBold = True
tocSection.ListFormatArray(0).TextInfo.IsTrueTypeFontItalic = True
tocSection.ListFormatArray(1).LeftMargin = 10
tocSection.ListFormatArray(1).TextInfo.IsUnderline = True
tocSection.ListFormatArray(1).TextInfo.FontSize = 10
tocSection.ListFormatArray(2).LeftMargin = 20
tocSection.ListFormatArray(2).TextInfo.IsTrueTypeFontBold = True
tocSection.ListFormatArray(3).LeftMargin = 30
tocSection.ListFormatArray(3).TextInfo.IsTrueTypeFontBold = True
' For complete examples and data files, please go to https://github.com/aspose-pdf/Aspose.Pdf-for-.NET
' The path to the documents directory.
Dim dataDir As String = RunExamples.GetDataDir_AsposePdfGenerator_UtilityFeatures()
' Create a PDF instance
Dim pdf As New Aspose.Pdf.Generator.Pdf()
' Create a list section
Dim tocSection As New Aspose.Pdf.Generator.ListSection("Table Of Contents")
' Set its list type as table of contents
tocSection.ListType = ListType.TableOfContents
' Add the list section to the sections collection of the Pdf document
pdf.Sections.Add(tocSection)
' Define the format of the four levels list by setting the left margins and
' Text format settings of each level
tocSection.ListFormatArray.Length = 4
tocSection.ListFormatArray(0).LeftMargin = 0
tocSection.ListFormatArray(0).TextInfo.IsTrueTypeFontBold = True
tocSection.ListFormatArray(0).TextInfo.IsTrueTypeFontItalic = True
tocSection.ListFormatArray(1).LeftMargin = 10
tocSection.ListFormatArray(1).TextInfo.IsUnderline = True
tocSection.ListFormatArray(1).TextInfo.FontSize = 10
tocSection.ListFormatArray(2).LeftMargin = 20
tocSection.ListFormatArray(2).TextInfo.IsTrueTypeFontBold = True
tocSection.ListFormatArray(3).LeftMargin = 30
tocSection.ListFormatArray(3).TextInfo.IsTrueTypeFontBold = True
' Create a section in the Pdf document
Dim sec1 As Aspose.Pdf.Generator.Section = pdf.Sections.Add()
' Add four headings in the section
For Level As Integer = 1 To 4
Dim heading1 As New Aspose.Pdf.Generator.Heading(pdf, sec1, Level)
Dim segment1 As New Segment(heading1)
heading1.Segments.Add(segment1)
heading1.IsAutoSequence = True
segment1.Content = "this is heading of level "
segment1.Content += Level.ToString()
' Add the heading into Table Of Contents.
heading1.IsInList = True
' Heading2.TOC = tocSection;
sec1.Paragraphs.Add(heading1)
Next
' Create a list section
Dim tocSection2 As New ListSection("Second Table Of Contents")
' Set its list type as table of of contents
tocSection2.ListType = ListType.TableOfContents
' Add the list section to the sections collection of the Pdf document
pdf.Sections.Add(tocSection2)
' Define the format of the four levels list by setting the left margins and
' Text format settings of each level
tocSection2.ListFormatArray.Length = 4
tocSection2.ListFormatArray(0).LeftMargin = 0
tocSection2.ListFormatArray(0).TextInfo.IsTrueTypeFontBold = True
tocSection2.ListFormatArray(0).TextInfo.IsTrueTypeFontItalic = True
tocSection2.ListFormatArray(1).LeftMargin = 10
tocSection2.ListFormatArray(1).TextInfo.IsUnderline = True
tocSection2.ListFormatArray(1).TextInfo.FontSize = 10
tocSection2.ListFormatArray(2).LeftMargin = 20
tocSection2.ListFormatArray(2).TextInfo.IsTrueTypeFontBold = True
tocSection2.ListFormatArray(3).LeftMargin = 30
tocSection2.ListFormatArray(3).TextInfo.IsTrueTypeFontBold = True
' Create a section in the Pdf document
Dim sec2 As Aspose.Pdf.Generator.Section = pdf.Sections.Add()
' Add four headings in the section
For Level As Integer = 1 To 4
Dim heading2 As New Aspose.Pdf.Generator.Heading(pdf, sec1, Level)
Dim segment2 As New Segment(heading2)
heading2.Segments.Add(segment2)
heading2.IsAutoSequence = True
segment2.Content = "this is heading of level "
segment2.Content += Level.ToString()
' Add the heading into Table Of Contents.
heading2.IsInList = True
' Add the heading elements to second ListSection
heading2.TOC = tocSection2
' Add the heading obejct to paragraphs colelction of section2
sec2.Paragraphs.Add(heading2)
Next
dataDir = dataDir & Convert.ToString("Multiple_TOC_out_.pdf")
' Save the resultant PDF document
pdf.Save(dataDir)
' For complete examples and data files, please go to https://github.com/aspose-pdf/Aspose.Pdf-for-.NET
' The path to the documents directory.
Dim dataDir As String = RunExamples.GetDataDir_AsposePdfGenerator_UtilityFeatures()
' Instantiate Pdf instance by calling its empty constructor
Dim pdf1 As New Aspose.Pdf.Generator.Pdf()
' Create a list section
Dim tocSection As New Aspose.Pdf.Generator.ListSection("Table Of Contents")
' Set its list type as table of of contents
tocSection.ListType = Aspose.Pdf.Generator.ListType.TableOfContents
' Add the list section to the sections collection of the Pdf document
pdf1.Sections.Add(tocSection)
' Create a list section
Dim lotSection As New Aspose.Pdf.Generator.ListSection("List of Tables")
' Set its list type as list of tables
lotSection.ListType = Aspose.Pdf.Generator.ListType.ListOfTables
' Add the list section to the sections collection of the Pdf document
pdf1.Sections.Add(lotSection)
' Create a list section
Dim lofSection As New Aspose.Pdf.Generator.ListSection("List of Figures")
' Set its list type as list of figures
lofSection.ListType = Aspose.Pdf.Generator.ListType.ListOfFigures
' Add the list section to the sections collection of the Pdf document
pdf1.Sections.Add(lofSection)
dataDir = dataDir & Convert.ToString("AddThreeList_out_.pdf")
' Save the Pdf
pdf1.Save(dataDir)
' For complete examples and data files, please go to https://github.com/aspose-pdf/Aspose.Pdf-for-.NET
' The path to the documents directory.
Dim dataDir As String = RunExamples.GetDataDir_AsposePdfGenerator_UtilityFeatures()
' Create a file stream to create the PDF document
Dim fs As New FileStream(dataDir & Convert.ToString("SingleSeg-d_out_.pdf"), FileMode.Create)
' Instantiate the Pdf instance and pass the file stream object to its constructor
Dim pdf As New Aspose.Pdf.Generator.Pdf(fs)
' Add a section to the PDF document
Dim sec1 As Aspose.Pdf.Generator.Section = pdf.Sections.Add()
' Add 1000 text paragraphs to the section
For i As Integer = 0 To 999
Dim t As New Aspose.Pdf.Generator.Text("hello world hello world hello " + i.ToString())
sec1.AddParagraph(t)
Next
' Close the Pdf. This method is used only for direct file mode
pdf.Close()
' For complete examples and data files, please go to https://github.com/aspose-pdf/Aspose.Pdf-for-.NET
' The path to the documents directory.
Dim dataDir As String = RunExamples.GetDataDir_AsposePdfGenerator_UtilityFeatures()
' Create a file stream to create the PDF document
Dim fs As New FileStream(dataDir & Convert.ToString("CreatePdfUsingXML_out_"), FileMode.Create)
' Instantiate the Pdf instance and pass the file stream object to its constructor
Dim pdf As New Aspose.Pdf.Generator.Pdf(fs)
' Bind the XML file to the Pdf and leave the XSL file parameter as Nothing
pdf.BindXML(dataDir & Convert.ToString("log.xml"), Nothing)
' Close the Pdf. This method is used only for direct file mode
pdf.Close()
' For complete examples and data files, please go to https://github.com/aspose-pdf/Aspose.Pdf-for-.NET
' The path to the documents directory.
Dim dataDir As String = RunExamples.GetDataDir_AsposePdfGenerator_UtilityFeatures()
' Instantiate the Pdf object
Dim pdf1 As New Aspose.Pdf.Generator.Pdf()
' Add a section to the Pdf object
Dim sec1 As Aspose.Pdf.Generator.Section = pdf1.Sections.Add()
Dim text1 As New Aspose.Pdf.Generator.Text(sec1, "This is text in section1.")
text1.Left = 30
text1.Top = 100
sec1.Paragraphs.Add(text1)
Dim sec2 As Aspose.Pdf.Generator.Section = pdf1.Sections.Add()
Dim text2 As New Aspose.Pdf.Generator.Text(sec2, "This is text in section2.")
text2.Left = 30
text2.Top = 100
sec2.Paragraphs.Add(text2)
' Setting image watermark
Dim image1 As New Aspose.Pdf.Generator.Image()
image1.ImageInfo.File = dataDir & Convert.ToString("aspose-logo.jpg")
image1.ImageInfo.ImageFileType = Aspose.Pdf.Generator.ImageFileType.Jpeg
image1.ImageScale = 0.1F
Dim watermark1 As New Aspose.Pdf.Generator.FloatingBox(108, 80)
watermark1.BoxHorizontalPositioning = Aspose.Pdf.Generator.BoxHorizontalPositioningType.Page
watermark1.BoxHorizontalAlignment = Aspose.Pdf.Generator.BoxHorizontalAlignmentType.Center
watermark1.BoxVerticalPositioning = Aspose.Pdf.Generator.BoxVerticalPositioningType.Page
watermark1.BoxVerticalAlignment = Aspose.Pdf.Generator.BoxVerticalAlignmentType.Center
watermark1.Paragraphs.Add(image1)
' Graph watermark
Dim graph1 As New Aspose.Pdf.Generator.Graph(100, 400)
Dim posArr As Single() = New Single() {0, 0, 200, 80, 300, 40, _
350, 90}
Dim curve1 As New Aspose.Pdf.Generator.Curve(graph1, posArr)
graph1.Shapes.Add(curve1)
Dim watermark2 As New Aspose.Pdf.Generator.FloatingBox(108, 80)
watermark2.Paragraphs.Add(graph1)
' Text watermark
Dim text3 As New Aspose.Pdf.Generator.Text("Text Watermark")
Dim watermark3 As New Aspose.Pdf.Generator.FloatingBox(108, 80)
watermark3.Left = 50
watermark3.Top = 500
watermark3.Paragraphs.Add(text3)
pdf1.Watermarks.Add(watermark1)
pdf1.Watermarks.Add(watermark2)
pdf1.Watermarks.Add(watermark3)
dataDir = dataDir & Convert.ToString("CustomizingWatermark_out_.pdf")
' Save the Pdf
pdf1.Save(dataDir)
' For complete examples and data files, please go to https://github.com/aspose-pdf/Aspose.Pdf-for-.NET
' The path to the documents directory.
Dim dataDir As String = RunExamples.GetDataDir_AsposePdfGenerator_UtilityFeatures()
' Instantiate a Pdf object
Dim pdf1 As New Aspose.Pdf.Generator.Pdf()
' Add a section to the Pdf
Dim sec1 As Aspose.Pdf.Generator.Section = pdf1.Sections.Add()
' Set the number of columns in the section to 3
sec1.ColumnInfo.ColumnCount = 3
dataDir = dataDir & Convert.ToString("ManipulatingColumns_out_.pdf")
' Save the Pdf
pdf1.Save(dataDir)
' For complete examples and data files, please go to https://github.com/aspose-pdf/Aspose.Pdf-for-.NET
' The path to the documents directory.
Dim dataDir As String = RunExamples.GetDataDir_AsposePdfGenerator_UtilityFeatures()
' Instantiate a Pdf object
Dim pdf1 As New Aspose.Pdf.Generator.Pdf()
' Add a section to the Pdf
Dim sec1 As Aspose.Pdf.Generator.Section = pdf1.Sections.Add()
' Add two columns in the section
sec1.ColumnInfo.ColumnCount = 2
' Set the spacing between the columns
sec1.ColumnInfo.ColumnSpacing = "15"
' Set the widths of the columns
sec1.ColumnInfo.ColumnWidths = "250 150"
dataDir = dataDir & Convert.ToString("MultipleColumnsWithDefaultSpacing_out_.pdf")
' Save the Pdf
pdf1.Save(dataDir)
' For complete examples and data files, please go to https://github.com/aspose-pdf/Aspose.Pdf-for-.NET
' The path to the documents directory.
Dim dataDir As String = RunExamples.GetDataDir_AsposePdfGenerator_UtilityFeatures()
' Instantiate the Pdf object
Dim pdf1 As New Aspose.Pdf.Generator.Pdf()
' Add a section to the Pdf object
Dim sec1 As Aspose.Pdf.Generator.Section = pdf1.Sections.Add()
' Create a text paragraph
Dim text1 As New Aspose.Pdf.Generator.Text("This is a text paragraph.")
' Set the id of the paragraph to "text1" so that it can referenced uniquely
text1.ID = "text1"
' Add the paragraph to the section
sec1.Paragraphs.Add(text1)
' Create a graph with specified left and top position settings. Set its
' Poition relative to the page. Add a rectangle to its shapes collection and
' Then add the graph to the paragraph collection of the section
Dim graph1 As New Aspose.Pdf.Generator.Graph(200, 50)
graph1.Left = 200
graph1.Top = 10
graph1.PositioningType = Aspose.Pdf.Generator.PositioningType.PageRelative
graph1.Shapes.Add(New Aspose.Pdf.Generator.Rectangle(0, 0, 200, 50))
sec1.Paragraphs.Add(graph1)
' Create an attachment as note annotation and add it to the section as a
' Pragraph. Set the content and heading for the note. Set its position relative
' To the paragraph. Assign a unique id to this note annotation for the
' Reference purposes and then customize its left and top position
Dim noteAttachment As New Aspose.Pdf.Generator.Attachment()
sec1.Paragraphs.Add(noteAttachment)
noteAttachment.AttachmentType = Aspose.Pdf.Generator.AttachmentType.Note
noteAttachment.NoteContent = "This is a test for note"
noteAttachment.NoteHeading = "this is a Note"
noteAttachment.PositioningType = Aspose.Pdf.Generator.PositioningType.ParagraphRelative
noteAttachment.ReferenceParagraphID = "text1"
noteAttachment.Left = 200
noteAttachment.Top = 0
dataDir = dataDir & Convert.ToString("ParagraphsCustomPositioning_out_.pdf")
' Save the Pdf
pdf1.Save(dataDir)
' For complete examples and data files, please go to https://github.com/aspose-pdf/Aspose.Pdf-for-.NET
' The path to the documents directory.
Dim dataDir As String = RunExamples.GetDataDir_AsposePdfGenerator_UtilityFeatures()
' Instantiate a Pdf instance
Dim pdf1 As New Aspose.Pdf.Generator.Pdf()
' Add a section in the Pdf document
Dim sec1 As Aspose.Pdf.Generator.Section = pdf1.Sections.Add()
' Create a form field
Dim combo As New Aspose.Pdf.Generator.FormField()
' Set the type of form field to Combo
combo.FormFieldType = Aspose.Pdf.Generator.FormFieldType.Combo
' Set the field name
combo.FieldName = "ACombo"
' Add few options to the combo
combo.ChoiceOptions = New String() {"Red", "Green", "Blue"}
' Set the default selected value of the combo field
combo.FieldValue = "Red"
' Set the width of the field
combo.FormWidth = 80
' Set the height of the field
combo.FormHeight = 20
' Add the combo form field to the paragraphs collection of the section
sec1.Paragraphs.Add(combo)
dataDir = dataDir & Convert.ToString("ManipulatingFormFields_out_.pdf")
' Save the Pdf
pdf1.Save(dataDir)
' For complete examples and data files, please go to https://github.com/aspose-pdf/Aspose.Pdf-for-.NET
' The path to the documents directory.
Dim dataDir As String = RunExamples.GetDataDir_AsposePdfGenerator_UtilityFeatures()
' Instantiate the Pdf document and add a section to it
Dim pdf1 As New Aspose.Pdf.Generator.Pdf()
Dim sec1 As Aspose.Pdf.Generator.Section = pdf1.Sections.Add()
' Create a table, set its column widths and add it to paragraphs collection
' of the section
Dim tab1 As New Aspose.Pdf.Generator.Table()
tab1.ColumnWidths = "120 120 120"
sec1.Paragraphs.Add(tab1)
' Add a row to the table
Dim r1 As Aspose.Pdf.Generator.Row = tab1.Rows.Add()
' Add 1st cell to the row, set its padding and set the ID of the first paragraph
' In the cell to "text1"
Dim c1 As Aspose.Pdf.Generator.Cell = r1.Cells.Add("item1")
c1.Padding.Left = 30
c1.Paragraphs(0).ID = "text1"
' Add 2nd cell to the row, set its padding and set the ID of the first paragraph
' In the cell to "text2"
Dim c2 As Aspose.Pdf.Generator.Cell = r1.Cells.Add("item2")
c2.Padding.Left = 30
c2.Paragraphs(0).ID = "text2"
' Add 3rd cell to the row, set its padding and set the ID of the first paragraph
' In the cell to "text3"
Dim c3 As Aspose.Pdf.Generator.Cell = r1.Cells.Add("item3")
c3.Padding.Left = 30
c3.Paragraphs(0).ID = "text3"
' Create a form field of RadioButton type. Set its field name and button color.
' Then set the index of the radio button value to be checked
Dim radio As New Aspose.Pdf.Generator.FormField()
radio.FormFieldType = Aspose.Pdf.Generator.FormFieldType.RadioButton
radio.FieldName = "ARadio"
radio.ButtonColor = System.Drawing.Color.FromName("Red")
radio.RadioButtonCheckedIndex = 0
' Create 1st radio button instance and add it to above created radio form field.
' Set its width and height. The position of the radio button is set to be
' Relative to the paragraph. Link this radio button with the paragraph with ID
' Equal to "text1".
Dim bt1 As Aspose.Pdf.Generator.RadioButton = radio.RadioButtons.Add()
bt1.ButtonHeight = 12
bt1.ButtonWidth = 12
bt1.PositioningType = Aspose.Pdf.Generator.PositioningType.ParagraphRelative
bt1.ReferenceParagraphID = "text1"
bt1.Left = -20
bt1.Top = 0
' Create 2nd radio button instance and add it to above created radio form field.
' Set its width and height. The position of the radio button is set to be
' Relative to the paragraph. Link this radio button with the paragraph with ID
' Equal to "text2".
Dim bt2 As Aspose.Pdf.Generator.RadioButton = radio.RadioButtons.Add()
bt2.ButtonHeight = 12
bt2.ButtonWidth = 12
bt2.PositioningType = Aspose.Pdf.Generator.PositioningType.ParagraphRelative
bt2.ReferenceParagraphID = "text2"
bt2.Left = -20
bt2.Top = 0
' Create 3rd radio button instance and add it to above created radio form field.
' Set its width and height. The position of the radio button is set to be
' Relative to the paragraph. Link this radio button with the paragraph with ID
' Equal to "text3".
Dim bt3 As Aspose.Pdf.Generator.RadioButton = radio.RadioButtons.Add()
bt3.ButtonHeight = 12
bt3.ButtonWidth = 12
bt3.PositioningType = Aspose.Pdf.Generator.PositioningType.ParagraphRelative
bt3.ReferenceParagraphID = "text3"
bt3.Left = -20
bt3.Top = 0
' Add the radio form field to the paragraphs collection of the section
sec1.Paragraphs.Add(radio)
dataDir = dataDir & Convert.ToString("RadioButtonWithCustomPosition_out_.pdf")
' Save the Pdf
pdf1.Save(dataDir)
' For complete examples and data files, please go to https://github.com/aspose-pdf/Aspose.Pdf-for-.NET
' The path to the documents directory.
Dim dataDir As String = RunExamples.GetDataDir_AsposePdfGenerator_UtilityFeatures()
' Instantiate Pdf instance by calling its empty constructor
Dim pdf1 As New Aspose.Pdf.Generator.Pdf()
' Create a section in the Pdf document
Dim sec1 As Aspose.Pdf.Generator.Section = pdf1.Sections.Add()
' Add four headings in the section
Dim Level As Integer = 1
While Level <> 5
Dim heading2 As New Aspose.Pdf.Generator.Heading(pdf1, sec1, Level)
Dim segment2 As New Aspose.Pdf.Generator.Segment(heading2)
heading2.Segments.Add(segment2)
heading2.IsAutoSequence = True
segment2.Content = "this is heading of level "
segment2.Content += Level.ToString()
' Add the heading into Table Of Contents.
heading2.IsInList = True
sec1.Paragraphs.Add(heading2)
Level += 1
End While
' Create a graph and add a curve shape to its shapes collection
Dim graph1 As New Aspose.Pdf.Generator.Graph(sec1, 100, 400)
sec1.Paragraphs.Add(graph1)
Dim posArr As Single() = New Single() {0, 0, 200, 80, 300, 40, _
350, 90}
Dim curve1 As New Aspose.Pdf.Generator.Curve(graph1, posArr)
graph1.Shapes.Add(curve1)
' Add the Graph to the List of Figures
graph1.IsInList = True
dataDir = dataDir & Convert.ToString("SpecifyListItem_out_.pdf")
' Save the Pdf
pdf1.Save(dataDir)
' For complete examples and data files, please go to https://github.com/aspose-pdf/Aspose.Pdf-for-.NET
' The path to the documents directory.
Dim dataDir As String = RunExamples.GetDataDir_AsposePdfGenerator_WorkingDocuments()
' Instantiate a PDF Object
Dim pdf As New AP.Generator.Pdf()
' Add a section into the pdf document
Dim section1 As AP.Generator.Section = pdf.Sections.Add()
' Create a sample text paragraph
Dim text1 As New AP.Generator.Text("This is a test for XMP Metadata")
' Add text paragraph to paragraphs collection of section object
section1.Paragraphs.Add(text1)
' Create XmpMetaData object
pdf.XmpMetadata = New AP.Generator.XmpMetadata()
' Core properties
pdf.XmpMetadata.AddCreationDate(System.DateTime.Now.ToString())
' User properties
pdf.XmpMetadata.AddUserProperty("xmlns:dc=""http://purl.org/dc/elements/1.1/""", "dc:contributor", "Aspose")
dataDir = dataDir & Convert.ToString("AddingXMPMetaData_out_.pdf")
' Save Pdf Document
pdf.Save(dataDir)
' For complete examples and data files, please go to https://github.com/aspose-pdf/Aspose.Pdf-for-.NET
' The path to the documents directory.
Dim dataDir As String = RunExamples.GetDataDir_AsposePdfGenerator_WorkingDocuments()
' Instantiate a PDF Object
Dim pdf As New AP.Generator.Pdf()
' Instantiate a Aspose PDF JavaScript Object
pdf.JavaScripts = New AP.Generator.JavaScripts()
' Call the Add method and pass JavaScript statement as an argument, to show Print Dialog
pdf.JavaScripts.Add("this.print(true);")
' Call the Add method and JavaScript statement as an argument, to show alert
pdf.JavaScripts.Add("app.alert(""hello world"");")
dataDir = dataDir & Convert.ToString("AddJavaScript_out_.pdf")
' Save Pdf Document
pdf.Save(dataDir)
' For complete examples and data files, please go to https://github.com/aspose-pdf/Aspose.Pdf-for-.NET
' The path to the documents directory.
Dim dataDir As String = RunExamples.GetDataDir_AsposePdfGenerator_WorkingDocuments()
' Instantiate Pdf instance
Dim pdf1 As New AP.Generator.Pdf()
' Set OpenType property of Pdf instance to any pre-defined value
pdf1.OpenType = AP.Generator.OpenType.Thumbnails
dataDir = dataDir & Convert.ToString("SetAppearance_out_.pdf")
pdf1.Save(dataDir)
' For complete examples and data files, please go to https://github.com/aspose-pdf/Aspose.Pdf-for-.NET
' The path to the documents directory.
Dim dataDir As String = RunExamples.GetDataDir_AsposePdfGenerator_WorkingDocuments()
' Instantiate Pdf instance by calling its empty constructor
Dim pdf1 As New AP.Generator.Pdf()
' Set the properties of Pdf instance
pdf1.Author = "Naeem Akram"
pdf1.Creator = "Aspose.Pdf"
pdf1.Keywords = "Hello World"
pdf1.Subject = "Example"
pdf1.Title = "Example"
dataDir = dataDir & Convert.ToString("DocInfo_out_.pdf")
pdf1.Save(dataDir)
' For complete examples and data files, please go to https://github.com/aspose-pdf/Aspose.Pdf-for-.NET
' The path to the documents directory.
Dim dataDir As String = RunExamples.GetDataDir_AsposePdfGenerator_WorkingDocuments()
' Instantiate Pdf instance
Dim pdf1 As New AP.Generator.Pdf()
' You may set OpenType poperty to full screen
pdf1.OpenType = AP.Generator.OpenType.FullScreen
' Set PageTransitionType poperty of Pdf instance to a pre-defined desired value
pdf1.PageTransitionType = AP.Generator.PageTransitionType.Dissolve
dataDir = dataDir & Convert.ToString("PageTransition_out_.pdf")
pdf1.Save(dataDir)
' For complete examples and data files, please go to https://github.com/aspose-pdf/Aspose.Pdf-for-.NET
' The path to the documents directory.
Dim dataDir As String = RunExamples.GetDataDir_AsposePdfGenerator_WorkingDocuments()
' Instantiate Pdf instance
Dim pdf1 As New AP.Generator.Pdf()
' Set the DestinationType property of Pdf instance to any pre-defined value
pdf1.DestinationType = AP.Generator.DestinationType.FitPage
dataDir = dataDir & Convert.ToString("ZoomFactor_out_.pdf")
pdf1.Save(dataDir)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment