itext

iText Java disable print pdf

霸气de小男生 提交于 2019-12-24 02:57:22
问题 We are using the following code to disable Print option in PDF. Works really well. PdfReader reader = new PdfReader("my-old-file.pdf"); PdfStamper stamper = new PdfStamper(reader, new FileOutputStream("my-new-file.pdf")); stamper.setEncryption("my-owner-password".getBytes(), "my-user-password".getBytes(), PdfWriter.AllowCopy, PdfWriter.STRENGTH40BITS); stamper.close(); Everything was hunky dory till yesterday. We decided to update PDF Reader version to 9.3 from version 8.2 The print option is

Cannot use border-radius CSS3 property with Flying Saucer

荒凉一梦 提交于 2019-12-24 02:33:08
问题 I am working on a project where I need to convert an HTML to a PDF. I am using Flying Saucer 9.1.6 from Maven Central for this. The subjacent PDF generation library is IText 2.1.7 . Although Flying Saucer Git repo states that it supports CSS3 border-radius syntax I am unable to achieve rounded corners with border-radius. Here is the sample code ITextRenderer pdfRenderer = new ITextRenderer(); String resumeHTML = "<html>\n" + "<head>\n" + " <title>JS Bin</title>\n" + " <style>\n" + " .circle{

C# Append PDF file to MemoryStream - Cannot access a closed Stream

早过忘川 提交于 2019-12-24 02:14:35
问题 Is it possible to append an existing PDF file to a dynamically created PDF using iTextSharp? I have attempted as per my code below using PdfCopy, but I am getting a Cannot access a closed Stream error. I've seen examples merging actual PDF files together, but I am not storing the finished PDFs, simply outputting the MemoryStream to a FilestreamResult: private readonly float _spacingBefore = 3f; private readonly float _spacingAfter = 3f; private readonly float _totalWidth = PageSize.A4.Width -

Java How to close PDF from using pdf javascript?

若如初见. 提交于 2019-12-24 02:14:12
问题 I'm using a servlet to send a pdf stream to a browser. There is a request that the pdf must open the print dialog when I show it to the user. I was successful doing this using iText api. Something like this: stamper.setPageAction(PdfWriter.PAGE_OPEN, new PdfAction(PdfAction.PRINTDIALOG), 1); Now I do need to close the pdf file after print. I tried using pdfactions, but I'm can't get it. What I tried is: writer.setAdditionalAction(PdfWriter.DID_PRINT, PdfAction.javaScript("app.execMenuItem(

iTextSharp XmlWorker: right-to-left

元气小坏坏 提交于 2019-12-24 01:53:52
问题 After a long time of struggling with this not-so-friendly API, I am finally making progress, but now I've come to a really nasty issue.. I have placed "dir" attributes in various places in my html with the value being "rtl".. but the XMLWorker doesn't seem to respect that at all. Does anyone know of a workaround? Here's my method: public static void Generate<TModel>(string templateFile, TModel model, string outputFile, IEnumerable<string> fonts) { string template = System.IO.File.ReadAllText

Can you set a background imaged to a PdfPTable when using iText

白昼怎懂夜的黑 提交于 2019-12-24 01:16:28
问题 I am using iText to generate Pdf Reports for data in a database... The header of the pages of the pdfs is an image with some text on the image added dynamically, say for example date generated.. Anyone knows if we can set background images to Tables of type PdfPTable in itext.. Thanks 回答1: I know its very late but might help someone. Here is the way to do it. Create a class BGClass, implement PdfPCellEvent and enter following method. @Override public void cellLayout(PdfPCell arg0, Rectangle

Rotating text using center in itext

社会主义新天地 提交于 2019-12-24 01:08:16
问题 I'm converting a document which is created with a online editor. I need to be able to rotate the text using it's central point and not (0,0). Since Image rotates using the centre I assumed this would work but it doesn't. Anyone has a clue how to rotate text using the central point in itext? float fw = bf.getWidthPoint(text, textSize); float fh = bf.getAscentPoint(text, textSize) - bf.getDescentPoint(text, textSize); PdfTemplate template = content.createTemplate(fw, fh); Rectangle r = new

JFreeChart & iText : black image when creating pdf

|▌冷眼眸甩不掉的悲伤 提交于 2019-12-24 00:55:56
问题 I am using JFreeChart 1.0.9 to create a chart, and iText 1.3.1 to display this chart in a PDF file. To do so, I am creating a JFreeChart, and then converting it to a byte array : final TimeSeriesCollection dataset = new TimeSeriesCollection(); final TimeSeries s1 = new TimeSeries("Series 1", Minute.class); s1.add(new Minute(0, 0, 7, 12, 2003), 1.2); s1.add(new Minute(30, 12, 7, 12, 2003), 3.0); // 12h30 => value = 3 s1.add(new Minute(15, 14, 7, 12, 2003), 8.0); final TimeSeries s2 = new

Changing font size of pdfptable

心已入冬 提交于 2019-12-23 23:52:46
问题 How do I set the font for a pdfptable? 回答1: You must set the font in each cell when you're creating a phrase: Dim yourFont As BaseFont = BaseFont.CreateFont( _ Current.Server.MapPath("~/fonts/somefont.TTF"), _ BaseFont.WINANSI, BaseFont.EMBEDDED) Dim mainFont As New Font(yourFont, SOME_FONT_SIZE, Font.NORMAL) Dim cell As New PdfPCell(New Phrase("some text", mainFont)) yourTable.Add(cell) 回答2: You need to create a 'Base Font' object which is a little different than a regular font object in

Itextpdf : set image in middle of text

为君一笑 提交于 2019-12-23 23:06:52
问题 I have a text in paragraph I want set an image in the middle of text : public void createPdf(String dest, String imgSource) throws IOException, DocumentException { Document doc = new Document (); PdfWriter writer = PdfWriter.getInstance(doc, new FileOutputStream(dest)); doc.open (); Paragraph p = new Paragraph(); Image image1 = Image.getInstance(imgSource); p.add(new Chunk("This is my photo : ")); p.add (image1); p.add(new Chunk(" so beautifull :)")); doc.add(p); doc.close(); } it is a small