Hello, world! PDF版
Posted feedbacks - C#
A4ページ全体に広げて。
see: iTextSharp
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 | using System.IO;
using iTextSharp.text;
using iTextSharp.text.pdf;
class Program {
static void Main(string[] args) {
string s = "Hello, world!";
Document doc = new Document(PageSize.A4.Rotate(), 0f, 0f, 0f, 0f);
PdfWriter.GetInstance(doc, File.Create("hello.pdf"));
doc.Open();
Font f = FontFactory.GetFont(FontFactory.TIMES_BOLD);
f.Size *= doc.PageSize.Height /
(f.BaseFont.GetAscentPoint(s, f.Size) - f.BaseFont.GetDescentPoint(s, f.Size));
Chunk chunk = new Chunk(s, f);
chunk.SetTextRise(-f.BaseFont.GetAscentPoint(chunk.Content, f.Size));
chunk.SetHorizontalScaling((doc.PageSize.Width - 0f) / chunk.GetWidthPoint());
doc.Add(chunk);
doc.Close();
}
}
|


にしお
#3406()
Rating0/0=0.00
[ reply ]