itextsharp

convert office documents to pdf in c#

五迷三道 提交于 2019-12-06 16:35:01
问题 i want to pragmatically convert office documents to pdf.i do not want to use the microsoft office service ddl. this is the code which i used, using System; using System.IO; using Microsoft.Office.Interop.Word; using System; using System.Collections.Generic; using System.IO; using System.Linq; using System.Text; using System.IO.Compression; using Document = Microsoft.Office.Interop.Word.Document; namespace pdfconversion { public class PdfMerge { static void Main() { var wordApplication = new

Using itextsharp and MVC to display a range of PDF pages in a web page

ⅰ亾dé卋堺 提交于 2019-12-06 15:57:55
I used this site to copy examples and to ask help from various people so I thought I would share my attempt at putting things together with others who might be interested. The following takes a range of pages from an existing PDF file and displays the result in an iframe or a new Tab. It uses [itextsharp][1] The code contains a fair amount of novice code but at least it works. There is absolutely no point point in asking me any questions because I almost certainly will not know the answer. If anyone would like to point out where improvements might be made, I would be very grateful. VIEW <input

Watermark in itextsharp is not displaying properly

喜夏-厌秋 提交于 2019-12-06 15:45:59
I'm using iTextSharp to populate the data to PDF Templates, which is created in OpenOffice. it populating fine, I'm getting proper PDF, Watermark is not displaying properly. below is my code: public void addWaterMark(PdfStamper stamper, int pageNumber, Watermark watermark) { List<WatermarkField> watermarkFields = watermark.getWatermarkFieldAsReference(); for (WatermarkField watermarkField : watermarkFields) { // setting font and font size for the watermark text Font FONT = new Font(FontFamily.HELVETICA, watermarkField.getFontSize(), Font.BOLD, new GrayColor(0.75f)); // setting alignment for

How can convert XML to PDF using iTextSharp?

爱⌒轻易说出口 提交于 2019-12-06 15:34:10
问题 How can convert XML to PDF using iTextSharp? the iTextSharp's current XML to PDF is clearly out of date and does not work. So I went about fixing the problem but i am not been able to covert it Can any one help me. <?xml version="1.0" encoding="utf-8" ?> <catalog> <cd> <SR.No>14</SR.No> <test>loss test</test> <code>ISO-133</code> <unit>gm</unit> <sampleid>36</sampleid> <boreholeid>21</boreholeid> <pieceno>63</pieceno> </cd> <cd> <SR.No>24</SR.No> <test>sand</test> <code>ISO-133</code> <unit

How to decrypt a pdf file by supplying password of the file as argument using c#?

荒凉一梦 提交于 2019-12-06 15:11:52
问题 I have generated a pdf file with password protection by using the following code: using (Stream input = new FileStream(InputFile, FileMode.Open, FileAccess.Read, FileShare.Read)) { using (Stream output = new FileStream(OutputFile, FileMode.Create, FileAccess.Write, FileShare.None)) { PdfReader reader = new PdfReader(input); PdfEncryptor.Encrypt(reader, output, true, strDob, "secret", PdfWriter.ALLOW_SCREENREADERS); } } I want to remove the password for the PDF file generated using the above

iTextSharp custom paper size

时光怂恿深爱的人放手 提交于 2019-12-06 13:16:57
I'm using iTextsharp library to create PDF files. I can declare for A4 Landscape paper like this: Dim pdfTable As New PdfPTable(9) pdfTable.WidthPercentage = 100 Dim pdfDoc As New Document(PageSize.A4.Rotate()) I'm wondering how I can set Height of pdfTable or A4 Height manually. Because there's a lot more margin left at the bottom, and I need to put some text at that margin. Right now, I put a line of text at the bottom, the line's got pushed to the new page. Q1: How can I override the height of A4 paper provied by iTextsharp? Q2: How can I create a custom size paper, say Width = 29cm, Height

embed font into pdf using itextsharp

江枫思渺然 提交于 2019-12-06 12:58:59
I am trying to embed a font using itextsharp 5.2.1.0, but am getting errors. the font is KozGoPro-Light.otf which after doing a bit of research is a japenese font. I have tried the following... Dim tblx1 As PdfPTable = New PdfPTable(1) Dim tblrightcell_margin2 As PdfPCell Dim bfR As iTextSharp.text.pdf.BaseFont **bfR = iTextSharp.text.pdf.BaseFont.CreateFont("KozGoPro-Light.otf", iTextSharp.text.pdf.BaseFont.IDENTITY_H, iTextSharp.text.pdf.BaseFont.EMBEDDED) fntKozgoProExtra = New Font(bfR, 18)** tblrightcell_margin2 = New PdfPCell(New Phrase("testing....", fntKozgoProExtra)) tblx1.AddCell

Unable to print Check Boxes in pdf

女生的网名这么多〃 提交于 2019-12-06 12:41:37
问题 We are using WkHtmlToPdf to convert from html to pdf. Now I have make all the form fields editable on request as well. Since there is a bug in WkHtmlToPdf while converting Html to Pdf it makes all the form field's property as Visible Not Printable. To get around this problem we are using ITextSharp to read existing pdf that has been generated by WkHtmlToPdf and setting that property as Visible for every form field. This is how I am doing that var pdfReader = new PdfReader(inputFilename);

Merge PDFs iTextSharp

爷,独闯天下 提交于 2019-12-06 12:33:13
I looked at a few examples online and came up with this code to merge pdfs using iTextSharp. But I am getting an error :. {"The document has no pages."} It fails at Page = writer.GetImportedPage(reader, X); Here is stack trace : at iTextSharp.text.pdf.PdfPages.WritePageTree() at iTextSharp.text.pdf.PdfWriter.Close() at iTextSharp.text.pdf.PdfCopy.Close() at iTextSharp.text.Document.Close() It has 3 pages when I debugged it. What is wrong here?? Here is my code public static MemoryStream MergePdfs(List<MemoryStream> pdfStreams) { //Create output stream MemoryStream OutStream = new MemoryStream(

iTextSharp get PDF DPI

允我心安 提交于 2019-12-06 12:03:46
How can I get the DPI of the PDF that I am reading from my hard drive into iTextSharp? PDF's do not necessarily use DPI in their definitions. PDF's allow the document creator to define their own user coordinate space which may or may not map to anything similar to Dots Per Inch. MK. Check this How to calculate the correct image size in out pdf using itextsharp ? PDF UserUnit shall give the size of default user space units, in multiples of 1 ⁄ 72 inch. ISO-32000-1 (section 8.3.2.3) tells us “the default for the size of the unit in default user space (1/72 inch) is approximately the same as a