iTextSharp etiketine sahip kayıtlar gösteriliyor. Tüm kayıtları göster
iTextSharp etiketine sahip kayıtlar gösteriliyor. Tüm kayıtları göster
3 Eylül 2012 Pazartesi
Itextsharp ParsePdf
public string ParsePdf(string fileName)
{
string text = string.Empty;
PdfReader reader = new PdfReader(fileName);
byte[] streanBytes = reader.GetPageContent(1);
PRTokeniser tokenizer = new PRTokeniser(streanBytes);
while (tokenizer.NextToken())
if (tokenizer.TokenType == PRTokeniser.TK_STRING)
{
text += tokenizer.StringValue;
}
return text;
}
26 Temmuz 2011 Salı
Itextsharp File Attachment Event
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using iTextSharp.text.pdf;
using iTextSharp.text;
using iTextSharp.text.xml;
using iTextSharp.text.pdf.events;
using System.IO;
public class FileAttachmentEvent : PdfPCellEventForwarder
{
protected PdfWriter writer;
protected PdfFileSpecification fs;
protected String description;
public FileAttachmentEvent(PdfWriter Writer, PdfFileSpecification Fs, String Description)
{
this.writer = Writer;
this.fs = Fs;
this.description = Description;
}
public void cellLayout(PdfPCell cell, Rectangle position, PdfContentByte[] canvases)
{
try
{
PdfAnnotation annonation = PdfAnnotation.CreateFileAttachment(writer, new Rectangle(position.GetLeft(20f), position.GetTop(15f),
position.GetLeft(5f), position.GetTop(5f)), description, fs);
annonation.Name = description;
writer.AddAnnotation(annonation);
}
catch (IOException)
{
throw;
}
}
}
using System.Collections.Generic;
using System.Linq;
using System.Text;
using iTextSharp.text.pdf;
using iTextSharp.text;
using iTextSharp.text.xml;
using iTextSharp.text.pdf.events;
using System.IO;
public class FileAttachmentEvent : PdfPCellEventForwarder
{
protected PdfWriter writer;
protected PdfFileSpecification fs;
protected String description;
public FileAttachmentEvent(PdfWriter Writer, PdfFileSpecification Fs, String Description)
{
this.writer = Writer;
this.fs = Fs;
this.description = Description;
}
public void cellLayout(PdfPCell cell, Rectangle position, PdfContentByte[] canvases)
{
try
{
PdfAnnotation annonation = PdfAnnotation.CreateFileAttachment(writer, new Rectangle(position.GetLeft(20f), position.GetTop(15f),
position.GetLeft(5f), position.GetTop(5f)), description, fs);
annonation.Name = description;
writer.AddAnnotation(annonation);
}
catch (IOException)
{
throw;
}
}
}
29 Haziran 2011 Çarşamba
Itextsharp PageNumber Method
Itextsharp'da yapmış olduğunuz sayfaların footer kısmına sayfa numarası eklemek için yazmış olduğum method örneği. İyi günlerde kullanmanız dileğiyle
namespace Methods
{
public class PageNumber
{
public void NumberPage(string Path,int PageNumber)
{
Document doc = new Document();
PdfWriter writer = PdfWriter.GetInstance(doc, new FileStream(Path, FileMode.Create));
doc.Open();
PdfContentByte cb = writer.DirectContent;
PdfTemplate template = cb.CreateTemplate(50, 50);
BaseFont bf = BaseFont.CreateFont(BaseFont.HELVETICA, BaseFont.CP1252, BaseFont.NOT_EMBEDDED);
for (int i = 0; i < PageNumber; i++)
{
String PageText = "Page " + writer.PageNumber + " of ";
float len = bf.GetWidthPoint(PageText, 12);
cb.BeginText();
cb.SetFontAndSize(bf, 12);
cb.SetTextMatrix(280, 40);
cb.ShowText(PageText);
cb.EndText();
cb.AddTemplate(template, 280 + len, 40);
doc.NewPage();
}
template.BeginText();
template.SetFontAndSize(bf, 12);
template.ShowText((writer.PageNumber - 1).ToString());
template.EndText();
doc.Close();
}
}
}
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using iTextSharp.text.pdf;
using iTextSharp.text;
using System.IO;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using iTextSharp.text.pdf;
using iTextSharp.text;
using System.IO;
{
public class PageNumber
{
public void NumberPage(string Path,int PageNumber)
{
Document doc = new Document();
PdfWriter writer = PdfWriter.GetInstance(doc, new FileStream(Path, FileMode.Create));
doc.Open();
PdfContentByte cb = writer.DirectContent;
PdfTemplate template = cb.CreateTemplate(50, 50);
BaseFont bf = BaseFont.CreateFont(BaseFont.HELVETICA, BaseFont.CP1252, BaseFont.NOT_EMBEDDED);
for (int i = 0; i < PageNumber; i++)
{
String PageText = "Page " + writer.PageNumber + " of ";
float len = bf.GetWidthPoint(PageText, 12);
cb.BeginText();
cb.SetFontAndSize(bf, 12);
cb.SetTextMatrix(280, 40);
cb.ShowText(PageText);
cb.EndText();
cb.AddTemplate(template, 280 + len, 40);
doc.NewPage();
}
template.BeginText();
template.SetFontAndSize(bf, 12);
template.ShowText((writer.PageNumber - 1).ToString());
template.EndText();
doc.Close();
}
}
}
Kaydol:
Kayıtlar (Atom)