本文整理汇总了C#中iTextSharp.text.Document.AddKeywords方法的典型用法代码示例。如果您正苦于以下问题:C# Document.AddKeywords方法的具体用法?C# Document.AddKeywords怎么用?C# Document.AddKeywords使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类iTextSharp.text.Document
的用法示例。
在下文中一共展示了Document.AddKeywords方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: btnCreateReport_Click
private void btnCreateReport_Click(object sender, EventArgs e)
{
// _______________________________________________________1_______________________________________________________
// Setting pagetype, margins and encryption
iTextSharp.text.Rectangle pageType = iTextSharp.text.PageSize.A4;
float marginLeft = 72;
float marginRight = 36;
float marginTop = 60;
float marginBottom = 50;
String reportName = "Test.pdf";
Document report = new Document(pageType, marginLeft, marginRight, marginTop, marginBottom);
PdfWriter writer = PdfWriter.GetInstance(report, new FileStream(reportName, FileMode.Create));
//writer.SetEncryption(PdfWriter.STRENGTH40BITS, "Good", "Bad", PdfWriter.ALLOW_COPY);
report.Open();
// _______________________________________________________2_______________________________________________________
// Setting Document properties(Meta data)
// 1. Title
// 2. Subject
// 3. Keywords
// 4. Creator
// 5. Author
// 6. Header
report.AddTitle("Employee Details Report");
report.AddSubject("This file is generated for administrative use only");
report.AddKeywords("Civil Security Department, Employee Management System, Version 1.0.0, Report Generator");
report.AddCreator("Ozious Technologies");
report.AddAuthor("Eranga Heshan");
report.AddHeader("Owner", "Civil Security Department");
// _______________________________________________________3_______________________________________________________
// Setup the font factory
/*
int totalFonts = FontFactory.RegisterDirectory("C:\\WINDOWS\\Fonts");
StringBuilder sb = new StringBuilder();
foreach (string fontname in FontFactory.RegisteredFonts) { sb.Append(fontname + "\n"); }
report.Add(new Paragraph("All Fonts:\n" + sb.ToString()));
*/
iTextSharp.text.Font fontHeader_1 = FontFactory.GetFont("Calibri", 30, iTextSharp.text.Font.BOLD, new iTextSharp.text.BaseColor(0, 0, 0));
iTextSharp.text.Font fontHeader_2 = FontFactory.GetFont("Calibri", 15, iTextSharp.text.Font.BOLD, new iTextSharp.text.BaseColor(125, 125, 125));
// _______________________________________________________x_______________________________________________________
// Create header
PdfContentByte cb = writer.DirectContent;
cb.MoveTo(marginLeft, marginTop);
cb.LineTo(500, marginTop);
cb.Stroke();
Paragraph paraHeader_1 = new Paragraph("Civil Security Department", fontHeader_1);
paraHeader_1.Alignment = Element.ALIGN_CENTER;
paraHeader_1.SpacingAfter = 0f;
report.Add(paraHeader_1);
Paragraph paraHeader_2 = new Paragraph("Employee Detailed Report", fontHeader_2);
paraHeader_2.Alignment = Element.ALIGN_CENTER;
paraHeader_2.SpacingAfter = 10f;
report.Add(paraHeader_2);
// _______________________________________________________x_______________________________________________________
// Adding employee image
iTextSharp.text.Image img = iTextSharp.text.Image.GetInstance(imgEmployee.ImageLocation);
img.ScaleToFit(100f, 100f);
img.Border = iTextSharp.text.Rectangle.BOX;
img.BorderColor = iTextSharp.text.BaseColor.BLACK;
img.BorderWidth = 5f;
img.Alignment = iTextSharp.text.Image.TEXTWRAP | iTextSharp.text.Image.ALIGN_RIGHT | iTextSharp.text.Image.ALIGN_TOP;
img.IndentationLeft = 50f;
img.SpacingAfter = 20f;
img.SpacingBefore = 20f;
report.Add(img);
Paragraph para1 = new Paragraph("Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... ");
para1.Alignment = Element.ALIGN_JUSTIFIED;
report.Add(para1);
report.Close();
this.Close();
}
示例2: GetOrCreatePDF
/// <summary>
/// 读取或创建Pdf文档并打开写入文件流
/// </summary>
/// <param name="fileName"></param>
/// <param name="folderPath"></param>
public Document GetOrCreatePDF(string fileName, string folderPath)
{
string filePath = folderPath + fileName;
FileStream fs = null;
if (!File.Exists(filePath))
{
fs = new FileStream(filePath, FileMode.Create, FileAccess.Write, FileShare.None);
}
else
{
fs = new FileStream(filePath, FileMode.Append, FileAccess.Write, FileShare.None);
}
//获取A4纸尺寸
Rectangle rec = new Rectangle(PageSize.A4);
Document doc = new Document(rec);
//创建一个 iTextSharp.text.pdf.PdfWriter 对象: 它有助于把Document书写到特定的FileStream:
PdfWriter writer = PdfWriter.GetInstance(doc, fs);
doc.AddTitle(fileName.Remove(fileName.LastIndexOf('.')));
doc.AddSubject(fileName.Remove(fileName.LastIndexOf('.')));
doc.AddKeywords("Metadata, iTextSharp 5.4.4, Chapter 1, Tutorial");
doc.AddCreator("MCS");
doc.AddAuthor("Chingy");
doc.AddHeader("Nothing", "No Header");
//打开 Document:
doc.Open();
////关闭 Document:
//doc.Close();
return doc;
}
示例3: ReportPdf
public ReportPdf(Stream Output, Layout Layout, Template Template, Dictionary<string, string> ConfigParams)
: base(Output, Layout, Template, ConfigParams)
{
Rectangle pageSize = new Rectangle(mm2pt(Template.PageSize.Width), mm2pt(Template.PageSize.Height));
// Initialization
m_Document = new Document(pageSize, mm2pt(Template.Margin.Left), mm2pt(Template.Margin.Right), mm2pt(Template.Margin.Top), mm2pt(Template.Margin.Bottom));
m_Writer = PdfWriter.GetInstance(m_Document, Output);
m_Document.AddCreationDate();
m_Document.AddCreator("StrengthReport http://dev.progterv.info/strengthreport) and KeePass (http://keepass.info)");
m_Document.AddKeywords("report");
m_Document.AddTitle(Layout.Title+" (report)");
// Header
HeaderFooter header = new HeaderFooter(new Phrase(Layout.Title+", "+DateTime.Now.ToString(), m_Template.ReportFooter.getFont()), false);
header.Alignment = Template.ReportFooter.getAlignment();
m_Document.Header = header;
// Footer
HeaderFooter footer = new HeaderFooter(new Phrase(new Chunk("Page ", m_Template.ReportFooter.getFont())), new Phrase(new Chunk(".", m_Template.ReportFooter.getFont())));
footer.Alignment = Template.ReportFooter.getAlignment();
m_Document.Footer = footer;
// TODO: Metadata
// Open document
m_Document.Open();
// Report Heading
{
PdfPTable reportTitle = new PdfPTable(1);
PdfPCell titleCell = new PdfPCell(new Phrase(Layout.Title, m_Template.ReportHeader.getFont()));
titleCell.Border = 0;
titleCell.FixedHeight = mm2pt(m_Template.ReportHeader.Height);
titleCell.VerticalAlignment = Element.ALIGN_MIDDLE;
titleCell.HorizontalAlignment = m_Template.ReportHeader.getAlignment();
reportTitle.AddCell(titleCell);
reportTitle.WidthPercentage = 100;
m_Document.Add(reportTitle);
}
// Create main table
m_Table = new PdfPTable(Layout.GetColumnWidths());
m_Table.WidthPercentage = 100;
m_Table.HeaderRows = 1;
foreach (LayoutElement element in Layout) {
PdfPCell cell = new PdfPCell(new Phrase(element.Title, m_Template.Header.getFont()));
cell.BackgroundColor = m_Template.Header.Background.ToColor();
cell.MinimumHeight = mm2pt(m_Template.Header.Height);
cell.VerticalAlignment = Element.ALIGN_MIDDLE;
m_Table.AddCell(cell);
}
m_colorRow = new CMYKColor[] { m_Template.Row.BackgroundA.ToColor(), m_Template.Row.BackgroundB.ToColor() };
}
示例4: Form1
// From <ClickButt> -> PdfConnector PdfCreatora <- PdfCreator(naemBank,Bodytext)
// Form <Image> <- PdfConnector -- tworzyć pdf |
public Form1()
{
while (!fileBanksLists.EndOfStream)
{
InitializeComponent();
using (FileStream file = new FileStream(String.Format(path, nameBank), FileMode.Create))
{
Document document = new Document(PageSize.A7);
PdfWriter writer = PdfWriter.GetInstance(document, file);
/// Create metadate pdf file
document.AddAuthor(nameBank);
document.AddLanguage("pl");
document.AddSubject("Payment transaction");
document.AddTitle("Transaction");
document.AddKeywords("OutcomingNumber :" + OutcomingNumber);
document.AddKeywords("IncomingNumber :" + IncomingNumber);
/// Create text in pdf file
document.Open();
document.Add(new Paragraph(_przelew + "\n"));
document.Add(new Paragraph(String.Format("Bank {0}: zaprasza\n", nameBank)));
document.Add(new Paragraph(DateTime.Now.ToString()));
document.Close();
writer.Close();
file.Close();
}
}
}
示例5: CreatePdf
public void CreatePdf(Project project, Stream writeStream)
{
var document = new Document();
var writer = PdfWriter.GetInstance(document, writeStream);
// landscape
document.SetPageSize(PageSize.A4.Rotate());
document.SetMargins(36f, 36f, 36f, 36f); // 0.5 inch margins
// metadata
document.AddCreator("EstimatorX.com");
document.AddKeywords("estimation");
document.AddAuthor(project.Creator);
document.AddSubject(project.Name);
document.AddTitle(project.Name);
document.Open();
AddName(project, document);
AddDescription(project, document);
AddAssumptions(project, document);
AddFactors(project, document);
AddTasks(project, document);
AddSummary(project, document);
writer.Flush();
document.Close();
}
示例6: Build
public void Build()
{
iTextSharp.text.Document doc = null;
try
{
// Initialize the PDF document
doc = new Document();
iTextSharp.text.pdf.PdfWriter writer = iTextSharp.text.pdf.PdfWriter.GetInstance(doc,
new System.IO.FileStream(System.IO.Directory.GetCurrentDirectory() + "\\ScienceReport.pdf",
System.IO.FileMode.Create));
// Set margins and page size for the document
doc.SetMargins(50, 50, 50, 50);
// There are a huge number of possible page sizes, including such sizes as
// EXECUTIVE, POSTCARD, LEDGER, LEGAL, LETTER_LANDSCAPE, and NOTE
doc.SetPageSize(new iTextSharp.text.Rectangle(iTextSharp.text.PageSize.LETTER.Width,
iTextSharp.text.PageSize.LETTER.Height));
// Add metadata to the document. This information is visible when viewing the
// document properities within Adobe Reader.
doc.AddTitle("My Science Report");
doc.AddCreator("M. Lichtenberg");
doc.AddKeywords("paper airplanes");
// Add Xmp metadata to the document.
this.CreateXmpMetadata(writer);
// Open the document for writing content
doc.Open();
// Add pages to the document
this.AddPageWithBasicFormatting(doc);
this.AddPageWithInternalLinks(doc);
this.AddPageWithBulletList(doc);
this.AddPageWithExternalLinks(doc);
this.AddPageWithImage(doc, System.IO.Directory.GetCurrentDirectory() + "\\FinalGraph.jpg");
// Add page labels to the document
iTextSharp.text.pdf.PdfPageLabels pdfPageLabels = new iTextSharp.text.pdf.PdfPageLabels();
pdfPageLabels.AddPageLabel(1, iTextSharp.text.pdf.PdfPageLabels.EMPTY, "Basic Formatting");
pdfPageLabels.AddPageLabel(2, iTextSharp.text.pdf.PdfPageLabels.EMPTY, "Internal Links");
pdfPageLabels.AddPageLabel(3, iTextSharp.text.pdf.PdfPageLabels.EMPTY, "Bullet List");
pdfPageLabels.AddPageLabel(4, iTextSharp.text.pdf.PdfPageLabels.EMPTY, "External Links");
pdfPageLabels.AddPageLabel(5, iTextSharp.text.pdf.PdfPageLabels.EMPTY, "Image");
writer.PageLabels = pdfPageLabels;
}
catch (iTextSharp.text.DocumentException dex)
{
// Handle iTextSharp errors
}
finally
{
// Clean up
doc.Close();
doc = null;
}
}
示例7: CreateDocument
public static void CreateDocument(Stream stream, Action<Document> action)
{
using (var document = new Document(PageSize.A4))
{
var writer = PdfWriter.GetInstance(document, stream);
document.Open();
document.AddAuthor(Author);
document.AddCreator(DocumentCreator);
document.AddKeywords(DocumentKeywords);
document.AddSubject(DocumentSubject);
document.AddTitle(DocumentTitle);
action.Invoke(document);
document.Close();
}
}
示例8: CreatePdf
// ---------------------------------------------------------------------------
/**
* Creates a PDF document.
*/
public byte[] CreatePdf() {
using (MemoryStream ms = new MemoryStream()) {
// step 1
using (Document document = new Document()) {
// step 2
PdfWriter.GetInstance(document, ms);
// step 3
document.AddTitle("Hello World example");
document.AddAuthor("Bruno Lowagie");
document.AddSubject("This example shows how to add metadata");
document.AddKeywords("Metadata, iText, PDF");
document.AddCreator("My program using iText");
document.Open();
// step 4
document.Add(new Paragraph("Hello World"));
}
return ms.ToArray();
}
}
示例9: generateReport
private void generateReport()
{
try
{
String equipmentName = "";
document = new Document(PageSize.LETTER);
String FilePath = System.IO.Path.Combine(AppDomain.CurrentDomain.BaseDirectory) + "\\Resources\\" + inspectionType.Text + "_" + DateTime.Today.ToString("yyyy-MM-dd") +".pdf";
PdfWriter writer = PdfWriter.GetInstance(document, new FileStream(FilePath, FileMode.OpenOrCreate));
document.Open();
document.AddTitle("Report");
document.AddSubject("Equipment Report");
document.AddKeywords("Csharp, PDF, iText");
document.AddAuthor("");
document.AddCreator("");
iTextSharp.text.Image pdfLogo = iTextSharp.text.Image.GetInstance(AppDomain.CurrentDomain.BaseDirectory + "\\Resources\\" + "logo.JPG");
pdfLogo.Alignment = iTextSharp.text.Image.ALIGN_RIGHT;
pdfLogo.ScaleAbsolute(150, 85);
document.Add(pdfLogo);
Paragraph preface = new Paragraph("Fire-Alert" + "\n" + "Report of " + inspectionType.Text + "\n", TimesTitle);
preface.Alignment = Element.ALIGN_CENTER;
document.Add(preface);
document.Add(new Paragraph(" "));
#region Inspection table
PdfPTable inspectionTable = new PdfPTable(1);
if (inspectionType.Text.Contains("Extinguisher"))
equipmentName = "Extinguisher";
else if (inspectionType.Text.Contains("Hose"))
equipmentName = "FireHoseCabinet";
else if (inspectionType.Text.Contains("Light"))
equipmentName = "EmergencyLight";
// Load XML inspection file from resources
string url = System.IO.Path.Combine(AppDomain.CurrentDomain.BaseDirectory) + "\\Resources\\inspection.xml";
XmlDocument doc = new System.Xml.XmlDocument();
doc.Load(url);
XmlElement docElement = doc.DocumentElement;
// loop through all childNodes
XmlNode start = docElement.FirstChild; // franchisee
foreach (XmlNode c1 in start) // contracts
{
foreach (XmlNode c2 in c1.ChildNodes) // addresses
{
// Skip if not matching contract ID
if (Convert.ToInt32(c2.Attributes["id"].InnerText) == Convert.ToInt32(addressBox.SelectedValue))
{
Console.WriteLine(Convert.ToInt32(c1.Attributes["id"].InnerText));
Console.WriteLine(Convert.ToInt32(addressBox.SelectedValue));
#region Address info table
PdfPTable addrTable = new PdfPTable(4);
addrTable.HorizontalAlignment = Element.ALIGN_LEFT;
addrTable.TotalWidth = 530f;
addrTable.LockedWidth = true;
float[] addrWidths = new float[] { 50f, 100f, 50f, 100f };
addrTable.SetWidths(addrWidths);
XmlAttributeCollection billTo = c1.ParentNode.Attributes;
XmlAttributeCollection location = c2.Attributes;
string[] billToAddr = billTo["address"].InnerText.Split(',');
addCell(addrTable, "Bill To:", 1, 1, 0, BaseColor.WHITE, Times, PdfPCell.ALIGN_RIGHT);
addCell(addrTable, billTo["name"].InnerText, 1, 1, 0, BaseColor.WHITE, TimesRegular, PdfPCell.ALIGN_LEFT);
addCell(addrTable, "Location:", 1, 1, 0, BaseColor.WHITE, Times, PdfPCell.ALIGN_RIGHT);
addCell(addrTable, location["contact"].InnerText, 1, 1, 0, BaseColor.WHITE, TimesRegular, PdfPCell.ALIGN_LEFT);
addCell(addrTable, " ", 1, 1, 0, BaseColor.WHITE, Times, PdfPCell.ALIGN_RIGHT);
addCell(addrTable, billToAddr[0], 1, 1, 0, BaseColor.WHITE, TimesRegular, PdfPCell.ALIGN_LEFT);
addCell(addrTable, " ", 1, 1, 0, BaseColor.WHITE, Times, PdfPCell.ALIGN_RIGHT);
addCell(addrTable, location["address"].InnerText, 1, 1, 0, BaseColor.WHITE, TimesRegular, PdfPCell.ALIGN_LEFT);
addCell(addrTable, " ", 1, 1, 0, BaseColor.WHITE, Times, PdfPCell.ALIGN_RIGHT);
addCell(addrTable, billToAddr[2] + "," + billToAddr[1], 1, 1, 0, BaseColor.WHITE, TimesRegular, PdfPCell.ALIGN_LEFT);
addCell(addrTable, " ", 1, 1, 0, BaseColor.WHITE, Times, PdfPCell.ALIGN_RIGHT);
addCell(addrTable, location["city"].InnerText, 1, 1, 0, BaseColor.WHITE, TimesRegular, PdfPCell.ALIGN_LEFT);
addCell(addrTable, " ", 1, 1, 0, BaseColor.WHITE, Times, PdfPCell.ALIGN_RIGHT);
addCell(addrTable, billToAddr[3], 1, 1, 0, BaseColor.WHITE, TimesRegular, PdfPCell.ALIGN_LEFT);
addCell(addrTable, " ", 1, 1, 0, BaseColor.WHITE, Times, PdfPCell.ALIGN_RIGHT);
addCell(addrTable, location["postalCode"].InnerText, 1, 1, 0, BaseColor.WHITE, TimesRegular, PdfPCell.ALIGN_LEFT);
addCell(addrTable, "Tel:", 2, 1, 0, BaseColor.WHITE, Times, PdfPCell.ALIGN_RIGHT);
//.........这里部分代码省略.........
示例10: button1_Click
private void button1_Click(object sender, EventArgs e)
{
if (openFile1.SafeFileName == "" || openFile2.SafeFileName == "")
{
MessageBox.Show("No haz seleccionado ningún PDF", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
return;
}
MessageBox.Show("Se unira \"" + openFile1.SafeFileName + "\" con \"" + openFile2.SafeFileName + "\"");
saveFile.Filter = "Adobe Acrobat Document PDF (*.pdf)|*.pdf";
saveFile.FilterIndex = 1;
if (saveFile.ShowDialog() == DialogResult.OK)
{
MessageBox.Show("Se guardara en la siguiente ruta:\n" + saveFile.FileName);
FileStream myStream = new FileStream(saveFile.FileName,FileMode.OpenOrCreate);
PdfReader reader = new PdfReader(openFile1.FileName);
PdfReader reader2 = new PdfReader(openFile2.FileName);
Document document = new Document(reader.GetPageSizeWithRotation(1));
PdfCopy writer = new PdfCopy(document, myStream);
document.Open();
document.AddCreationDate();
if (txtAutor.Text != null)
{
document.AddAuthor(txtAutor.Text);
}
if (txtHeader.Text != null)
{
document.AddHeader(txtHeader.Text, "Document");
}
if (txtKeywords.Text != null)
{
document.AddKeywords(txtKeywords.Text);
}
document.AddProducer();
if (txtTitulo.Text != null)
{
document.AddTitle(txtTitulo.Text);
}
// Calculando incremento
progressBar.Refresh();
int incremento = (int)(100 / (reader.NumberOfPages + reader2.NumberOfPages));
MessageBox.Show("Incremento es: " + incremento);
for (int i = 1; i <= reader.NumberOfPages; i++)
{
writer.AddPage(writer.GetImportedPage(reader, i));
progressBar.PerformStep();
progressBar.Increment(++incremento);
}
progressBar.Increment(50);
for (int i = 1; i <= reader2.NumberOfPages; i++)
{
writer.AddPage(writer.GetImportedPage(reader2, i));
progressBar.PerformStep();
}
progressBar.Increment(100);
document.Close();
}
}
示例11: SetPdfMetadata
/// <summary>
/// Настройка метаданных создаваемого PDF отчета
/// </summary>
/// <param name="doc">Документ</param>
private static void SetPdfMetadata(Document doc)
{
doc.AddAuthor("ToDoApp by Digiman");
doc.AddCreator("ToDoApp application");
doc.AddTitle("Report for To-Do list");
doc.AddSubject("Report file");
doc.AddKeywords("Metadata, PDF, iText, ToDoList, Report");
}
示例12: CreateFactuur
public static string CreateFactuur(Factuur factuur)
{
try
{
var filename = GenerateFileName(factuur);
using (var fs = new FileStream(Path.Combine(FactuurFolder.FullName, filename), FileMode.Create))
{
var document = new Document(PageSize.A4, 25, 25, 30, 1);
var writer = PdfWriter.GetInstance(document, fs);
writer.PageEvent = new FactuurHelper();
// Add meta information to the document
document.AddAuthor("Dura - Vanseveren");
document.AddCreator("DuraFact");
document.AddKeywords("Factuur");
document.AddSubject(string.Format("Factuur {0}", factuur.FactuurNummer));
document.AddTitle("Factuur");
// Open the document to enable you to write to the document
document.Open();
// Makes it possible to add text to a specific place in the document using
// a X & Y placement syntax.
var content = writer.DirectContent;
// Add a footer template to the document
// content.AddTemplate(PdfFooter(content, factuur), 30, 1);
// Add a logo to the invoice
var img = DuraLogo;
img.ScalePercent(80);
img.SetAbsolutePosition(40, 650);
content.AddImage(img);
// First we must activate writing
content.BeginText();
// First we write out the header information
AddKlantData(factuur, content);
WriteText(content, "Factuur", 40, 600, 20, true);
AddFactuurData(factuur, content);
// You need to call the EndText() method before we can write graphics to the document!
content.EndText();
// Separate the header from the rows with a line
// Draw a line by setting the line width and position
content.SetLineWidth(0f);
content.MoveTo(40, 590);
content.LineTo(560, 590);
content.Stroke();
// Don't forget to call the BeginText() method when done doing graphics!
content.BeginText();
// Before we write the lines, it's good to assign a "last position to write"
// variable to validate against if we need to make a page break while outputting.
// Change it to 510 to write to test a page break; the fourth line on a new page
const int lastwriteposition = 150;
// Loop thru the table of items and set the linespacing to 12 points.
// Note that we use the -= operator, the coordinates goes from the bottom of the page!
var topMargin = 570;
if (!string.IsNullOrEmpty(factuur.Opmerking))
{
WriteText(content, "Opmerking", 40, topMargin, 12, true);
topMargin -= 20;
foreach (string s in factuur.Opmerking.Split(new string[] { Environment.NewLine }, StringSplitOptions.None))
{
WriteText(content, s, 40, topMargin, 10);
topMargin -= 16;
}
topMargin -= 4;
}
AddItemData(factuur, document, lastwriteposition, content, ref topMargin);
// You need to call the EndText() method before we can write graphics to the document!
content.EndText();
// Separate the header from the rows with a line
// Draw a line by setting the line width and position
content.SetLineWidth(0f);
content.MoveTo(40, topMargin);
content.LineTo(560, topMargin);
content.Stroke();
// Don't forget to call the BeginText() method when done doing graphics!
content.BeginText();
topMargin -= 15;
AddBTWData(factuur, content, topMargin);
// End the writing of text
content.EndText();
// Close the document, the writer and the filestream!
document.Close();
writer.Close();
fs.Close();
return Path.Combine(FactuurFolder.FullName, filename);
}
}
catch
{
return string.Empty;
}
}
示例13: Publish
public void Publish(IReadOnlyList<ReleaseNoteWorkItem> workItems)
{
var stream = new MemoryStream();
try
{
_document = new Document(PageSize.A4, 36, 36, 90, 72);
// Initialize pdf writer
_writer = PdfWriter.GetInstance(_document, stream);
_writer.PageEvent = new ReleaseNotesPdfPageEvents(Settings);
// Open document to write
_document.Open();
_document.AddTitle(Settings.GetDocumentTitle());
_document.AddSubject(Settings.ProductName + " Release Notes");
_document.AddAuthor("ReleaseNotes Generator");
_document.AddKeywords(Settings.ProductName + "Release Notes");
_document.AddCreationDate();
_document.AddCreator("ReleaseNotes Generator");
// Add manual release notes for current release
int chapterNumber = 1;
if (!string.IsNullOrEmpty(Settings.MergeReleaseNotesFile) && File.Exists(Settings.MergeReleaseNotesFile))
{
Bookmarks.AddRange(Merge(Settings.MergeReleaseNotesFile, 1));
if (Bookmarks.Count > 0)
chapterNumber = Bookmarks.Count;
}
// Add automatic releases notes for current release
WriteWorkItems("How do I?", ref chapterNumber, workItems.Where(x => x.ResolutionType == "How do I" || x.ResolutionType == "As Designed"));
WriteWorkItems("Bug Fixes", ref chapterNumber, workItems.Where(x => x.ResolutionType == "Bug Fix"));
WriteWorkItems("Known Issues", ref chapterNumber, workItems.Where(x => x.ResolutionType == "Known Issue"));
WriteWorkItems("User Manual", ref chapterNumber, workItems.Where(x => x.ResolutionType == "User Manual"));
CreateBookmarks();
}
catch (Exception exception)
{
throw new Exception("There has an unexpected exception occured whilst creating the release notes: " + exception.Message, exception);
}
finally
{
_document.Close();
}
File.WriteAllBytes(Settings.OutputFile, stream.GetBuffer());
}
示例14: CreatePdfAutomatic
// ---------------------------------------------------------------------------
/**
* Creates a PDF document.
*/
public byte[] CreatePdfAutomatic() {
using (MemoryStream ms = new MemoryStream()) {
// step 1
using (Document document = new Document()) {
// step 2
PdfWriter writer = PdfWriter.GetInstance(document, ms);
document.AddTitle("Hello World example");
document.AddSubject("This example shows how to add metadata & XMP");
document.AddKeywords("Metadata, iText, step 3");
document.AddCreator("My program using 'iText'");
document.AddAuthor("Bruno Lowagie & Paulo Soares");
writer.CreateXmpMetadata();
// step 3
document.Open();
// step 4
document.Add(new Paragraph("Hello World"));
}
return ms.ToArray();
}
}
示例15: GenerateHerinnering
public static string GenerateHerinnering(Factuur factuur)
{
try
{
var filename = GenerateFileNameHerinnering(factuur);
using (var fs = new FileStream(Path.Combine(HerinneringFolder.FullName, filename), FileMode.Create))
{
var document = new Document(PageSize.A4, 25, 25, 30, 1);
var writer = PdfWriter.GetInstance(document, fs);
// Add meta information to the document
document.AddAuthor("Dura - Vanseveren");
document.AddCreator("DuraFact");
document.AddKeywords("Herinnering");
document.AddSubject(string.Format("Herinnering voor factuur {0}", factuur.FactuurNummer));
document.AddTitle("Herinnering");
// Open the document to enable you to write to the document
document.Open();
// Makes it possible to add text to a specific place in the document using
// a X & Y placement syntax.
var content = writer.DirectContent;
// Add a footer template to the document
// content.AddTemplate(PdfFooter(content, factuur), 30, 1);
// Add a logo to the invoice
var img = DuraLogo;
img.ScalePercent(80);
img.SetAbsolutePosition(40, 650);
content.AddImage(img);
// First we must activate writing
content.BeginText();
// First we write out the header information
AddKlantData(factuur, content);
WriteText(content, string.Format("Tielt, {0}", DateTime.Now.ToShortDateString()), 40, 600, 10);
WriteText(content, "Herinnering", 40, 550, 20, true);
WriteText(content, "Geachte heer/mevrouw", 40, 520, 10);
WriteText(content, string.Format("Wij hebben bij u een betalingsachterstand van {0:C} geconstateerd.", factuur.TotaalIncl), 40, 500, 10);
WriteText(content, "Dit bedrag heeft betrekking op de onderstaande factuur:", 40, 485, 10);
const int aantalMargin = 230, ehprijsMargin = 300, totaalMargin = 460;
WriteText(content, "Factuur", 140, 460, 12, true, PdfContentByte.ALIGN_RIGHT);
WriteText(content, "Datum", aantalMargin, 460, 12, true, PdfContentByte.ALIGN_RIGHT);
WriteText(content, "Bedrag", ehprijsMargin, 460, 12, true, PdfContentByte.ALIGN_RIGHT);
WriteText(content, "Betalingskenmerk", totaalMargin, 460, 12, true, PdfContentByte.ALIGN_RIGHT);
WriteText(content, factuur.FactuurNummer.ToString(), 140, 440, 10, false, PdfContentByte.ALIGN_RIGHT);
WriteText(content, factuur.FacturatieDatum.ToShortDateString(), aantalMargin, 440, 10, false, PdfContentByte.ALIGN_RIGHT);
WriteText(content, string.Format("{0:C}", factuur.TotaalIncl), ehprijsMargin, 440, 10, false, PdfContentByte.ALIGN_RIGHT);
WriteText(content, factuur.FacturatieDatum.ToShortDateString(), totaalMargin, 440, 10, false, PdfContentByte.ALIGN_RIGHT);
WriteText(content, string.Format("Wij verzoeken u nu vriendelijk het bovenstaande bedrag zulks ten bedrage van {0:C} te doen overmaken.", factuur.TotaalIncl), 40, 400, 10);
WriteText(content, "Dit kan op rekeningnummer 733-0318587-69 bij KBC of 001-6090654-03 bij BNP Paribas Fortis onder vermelding", 40, 385, 10);
WriteText(content, "van uw betalingskenmerk.", 40, 370, 10);
WriteText(content, "Wanneer u vragen mocht hebben over deze herinnering, verzoeken wij u zo spoedig mogelijk contact op te nemen", 40, 355, 10);
WriteText(content, "op het telefoonnummer (051) 40 34 77.", 40, 340, 10);
WriteText(content, "Heeft u inmiddels uw betalingsachterstand voldaan, dan is deze herinnering voor u niet meer van toepassing.", 40, 325, 10);
WriteText(content, "Hoogachtend,", 40, 280, 10);
WriteText(content, "Filip Vanseveren", 40, 180, 10);
// End the writing of text
content.EndText();
// Close the document, the writer and the filestream!
document.Close();
writer.Close();
fs.Close();
return Path.Combine(HerinneringFolder.FullName, filename);
}
}
catch
{
return string.Empty;
}
}