pdfstamper

Add page number to pdf using pdfstamper(Itext)

爱⌒轻易说出口 提交于 2019-12-11 02:55:33
问题 I have this code protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { ByteArrayOutputStream output = new ByteArrayOutputStream(); try{ response.setContentType("application/pdf"); response.setHeader("Content-Disposition", "inline; filename=details.pdf"); try{ Document document = new Document(PageSize.A4, 20, 20, 130, 20); PdfWriter writer=PdfWriter.getInstance(document, output); document.open(); BaseFont bf = BaseFont.createFont

Converting Multiple Images into Multiple Pages PDF using itextsharp

六眼飞鱼酱① 提交于 2019-12-02 02:15:38
问题 I have requirement to convert images into PDF with a template . I'm able to create one page PDF using itextsharp. Assumption 1 image for 1 page PDF . The problem comes when I have multiple images . How I can create multiple pages PDF with predefined template. Below is my code: public static string CreatePDFDocument(string docname, string imagePath, string mediaField) { PdfReader pdfReader = null; string pdfPortrait = ConfigurationManager.AppSettings["PdfPortraitTemplate"]; string pdfLandscape

Converting Multiple Images into Multiple Pages PDF using itextsharp

会有一股神秘感。 提交于 2019-12-02 00:17:14
I have requirement to convert images into PDF with a template . I'm able to create one page PDF using itextsharp. Assumption 1 image for 1 page PDF . The problem comes when I have multiple images . How I can create multiple pages PDF with predefined template. Below is my code: public static string CreatePDFDocument(string docname, string imagePath, string mediaField) { PdfReader pdfReader = null; string pdfPortrait = ConfigurationManager.AppSettings["PdfPortraitTemplate"]; string pdfLandscape = ConfigurationManager.AppSettings["PdfLandscapeTemplate"]; iTextSharp.text.Image instanceImg =

Arabic Data disappears on Form flattening in iText

被刻印的时光 ゝ 提交于 2019-12-01 13:48:24
I have populated an acrofield with some Arabic data using PDFStamper. The text disappears when I flatten the form while it is working fine for English. Please guide. BaseFont unicode = null; unicode = BaseFont.createFont("D:/arialuni.ttf", BaseFont.IDENTITY_H, BaseFont.EMBEDDED); form.setGenerateAppearances(true); form.addSubstitutionFont(unicode); form.setField("TextBox","اب اب اب اب اب اب اب اب اب اب اب اب اب اب اب اب اب"); stamper.setFormFlattening(true); It's probably an encoding problem when you save, compile or execute your code (which means your problem is not related to iText). This is

Arabic Data disappears on Form flattening in iText

折月煮酒 提交于 2019-12-01 12:48:29
问题 I have populated an acrofield with some Arabic data using PDFStamper. The text disappears when I flatten the form while it is working fine for English. Please guide. BaseFont unicode = null; unicode = BaseFont.createFont("D:/arialuni.ttf", BaseFont.IDENTITY_H, BaseFont.EMBEDDED); form.setGenerateAppearances(true); form.addSubstitutionFont(unicode); form.setField("TextBox","اب اب اب اب اب اب اب اب اب اب اب اب اب اب اب اب اب"); stamper.setFormFlattening(true); 回答1: It's probably an encoding

Cannot access the file because it is being used by another process

冷暖自知 提交于 2019-11-30 07:31:59
问题 My web method creates a pdf file in my %temp% folder and that works. I then want to add some custom fields (meta) to that file using the code below. The class PdfStamper generates an IOException , whether I use its .Close() method or the using block just ends. The process that is still holding on to the file handle is the webdev web server itself (I'm debugging in VS2010 SP1). private string AddCustomMetaData(string guid, int companyID, string filePath) { try { PdfReader reader = new

Cannot access the file because it is being used by another process

社会主义新天地 提交于 2019-11-29 04:35:41
My web method creates a pdf file in my %temp% folder and that works. I then want to add some custom fields (meta) to that file using the code below. The class PdfStamper generates an IOException , whether I use its .Close() method or the using block just ends. The process that is still holding on to the file handle is the webdev web server itself (I'm debugging in VS2010 SP1). private string AddCustomMetaData(string guid, int companyID, string filePath) { try { PdfReader reader = new PdfReader(filePath); using (FileStream fs = new FileStream(filePath, FileMode.Open, FileAccess.ReadWrite,

Getting PdfStamper to work with MemoryStreams (c#, itextsharp)

泄露秘密 提交于 2019-11-27 23:30:20
It came to me to rework old code which signs PDF files into new one, which signs MemoryStreams (byte arrays) that come and are sent by web services. Simple, right? Well, that was yesterday. Today I just can't get it to work. This is the old code, which uses FileStreams and it works: public static string OldPdfSigner(PdfReader pdfReader, string destination, string password, string reason, string location, string pathToPfx) { using (FileStream pfxFile = new FileStream(pathToPfx, FileMode.Open, FileAccess.Read)) { ... using (PdfStamper st = PdfStamper.CreateSignature(pdfReader, new FileStream

Getting PdfStamper to work with MemoryStreams (c#, itextsharp)

天涯浪子 提交于 2019-11-26 21:28:32
问题 It came to me to rework old code which signs PDF files into new one, which signs MemoryStreams (byte arrays) that come and are sent by web services. Simple, right? Well, that was yesterday. Today I just can't get it to work. This is the old code, which uses FileStreams and it works: public static string OldPdfSigner(PdfReader pdfReader, string destination, string password, string reason, string location, string pathToPfx) { using (FileStream pfxFile = new FileStream(pathToPfx, FileMode.Open,