align2: Example code of Early Access iText
2006-07-31 16:46
513 查看
using System;
using iTextSharp.text;
using iTextSharp.text.pdf;
using System.IO;
public class align2
{
[STAThread]
public static void Main(string[] args)
{
// creation of the document with a certain size and certain margins
Document document = new Document(PageSize.A4, 50, 50, 50, 50);
try
{
// creation of the different writers
PdfWriter writer = PdfWriter.GetInstance(document, new FileStream(@"e:\java\pdfalign2.Pdf", FileMode.Create));
document.Open();
BaseFont bf = BaseFont.CreateFont("Helvetica", "Cp1252", false);
PdfContentByte cb = writer.DirectContent;
cb.SetLineWidth(0f);
cb.MoveTo(250, 500);
cb.LineTo(250, 800);
cb.MoveTo(50, 700);
cb.LineTo(400, 700);
cb.MoveTo(50, 650);
cb.LineTo(400, 650);
cb.MoveTo(50, 600);
cb.LineTo(400, 600);
cb.Stroke();
cb.BeginText();
cb.SetFontAndSize(bf, 12);
string text = "Sample text for alignment";
cb.ShowTextAligned(PdfContentByte.ALIGN_CENTER, text + " Center", 250, 700, 0);
cb.ShowTextAligned(PdfContentByte.ALIGN_RIGHT, text + " Right", 250, 650, 0);
cb.ShowTextAligned(PdfContentByte.ALIGN_LEFT, text + " Left", 250, 600, 0);
cb.SetTextMatrix(100, 400);
cb.SetFontAndSize(bf, 14);
cb.ShowText("Text at position 100,400.");
cb.EndText();
document.Close();
System.Console.Out.WriteLine("FIM.");
}
catch (System.Exception de)
{
System.Console.Error.WriteLine(de.Message);
}
}
}
using iTextSharp.text;
using iTextSharp.text.pdf;
using System.IO;
public class align2
{
[STAThread]
public static void Main(string[] args)
{
// creation of the document with a certain size and certain margins
Document document = new Document(PageSize.A4, 50, 50, 50, 50);
try
{
// creation of the different writers
PdfWriter writer = PdfWriter.GetInstance(document, new FileStream(@"e:\java\pdfalign2.Pdf", FileMode.Create));
document.Open();
BaseFont bf = BaseFont.CreateFont("Helvetica", "Cp1252", false);
PdfContentByte cb = writer.DirectContent;
cb.SetLineWidth(0f);
cb.MoveTo(250, 500);
cb.LineTo(250, 800);
cb.MoveTo(50, 700);
cb.LineTo(400, 700);
cb.MoveTo(50, 650);
cb.LineTo(400, 650);
cb.MoveTo(50, 600);
cb.LineTo(400, 600);
cb.Stroke();
cb.BeginText();
cb.SetFontAndSize(bf, 12);
string text = "Sample text for alignment";
cb.ShowTextAligned(PdfContentByte.ALIGN_CENTER, text + " Center", 250, 700, 0);
cb.ShowTextAligned(PdfContentByte.ALIGN_RIGHT, text + " Right", 250, 650, 0);
cb.ShowTextAligned(PdfContentByte.ALIGN_LEFT, text + " Left", 250, 600, 0);
cb.SetTextMatrix(100, 400);
cb.SetFontAndSize(bf, 14);
cb.ShowText("Text at position 100,400.");
cb.EndText();
document.Close();
System.Console.Out.WriteLine("FIM.");
}
catch (System.Exception de)
{
System.Console.Error.WriteLine(de.Message);
}
}
}
相关文章推荐
- fdf_write: Example code of Early Access iText
- field_merge: Example code of Early Access iText(how to fill PDF form with iTextSharp)
- font_selector: Example code of Early Access iText
- form_combo: Example code of Early Access iText
- form_checkbox: Example code of Early Access iText
- DumpFields: Example code of Early Access iText
- form_radio: Example code of Early Access iText
- About itextSharp version example codes of Early Access iText(updated on 07/31/2006)
- Understand Code Access Security of SPS
- Class com.googlecode.jsonplugin.JSONWriter can not access a member of class*
- Example Code of Using XML Parser in Symbian OS
- An example code in .net of AWS EC2
- example code of Ajax
- A example code of multithread communication in Python
- The target assembly contains no service types. You may need to adjust the Code Access Security policy of this assembly." 目标程序集不包含服务类型。可能需要调整此程序集的代码访问安全策略。
- Example code of searching in WordNet Dictionary with JAWS library
- Class com.googlecode.jsonplugin.JSONWriter can not access a member of class*
- Question 29: The C++ code below generates a compiler error. Which of the following solutions can be used to correctly access the
- A real example of vioplot in R (sample data and code attached)
- Class com.googlecode.jsonplugin.JSONWriter can not access a member of class*