itext

Why doesn'n create pdf-documents in java servlet? [duplicate]

若如初见. 提交于 2019-12-20 08:09:38
问题 This question already has answers here : How can I serve a PDF to a browser without storing a file on the server side? (4 answers) Closed 3 years ago . I use iText/Pdfbox to create a PDF document. Everything works when I create the PDF using a standalone Java class like this: public static void main(String[] args){ ... ... ... } The document is created correctly. But I need create a PDF document from a Servlet. I paste the code into the get or post method, run that servlet on the server, but

Get text preceding image in PDF

99封情书 提交于 2019-12-20 07:50:34
问题 What I'm trying to do is extract the image associated with some text in a PDF file. For instance, a PDF would have a photo of the front of a house. Just above the photo, there would be a caption which reads "Front View". I want the program to search the PDF for the text "Front View" and extract the photo that follows it. I've looked iTextSharp, PDFsharp, and other utilities, but all of them treat the text in a PDF and the images separately. There doesn't seem to be any way to figure out that

How can I test if a PDF document is PDF/A compliant using iTextSharp?

我的梦境 提交于 2019-12-20 07:40:03
问题 I have a existing PDF file and with iTextSharp I want to test if it is PDF/A compliant. I don't want convert or create a file, just read and check if it is a PDF/A. I have not tried anything because I did not find any methods or properties of the class PdfReader of iTextSharp, saying that the PDF is PDF/A. For now it would be enough to know how to verify that the document claims to be PDF/A compatible Thanks Antonio 回答1: After a long search i tried this way and seems to work: Dim reader As

IText - Generating PDF with Chinese characters (Chinese Simplified)

痞子三分冷 提交于 2019-12-20 07:23:58
问题 I am using iText to generate some PDFs, these pdfs have some Chinese characters (Simplified Chinese - GB2312), however I am unable to generate a pdf with these characters. Anyone could tell me where I am wrong? I tried using various forms of creation but did not succeed: BaseFont bf = BaseFont.createFont("STSong-Light", "UniGB-UCS2-H", BaseFont.NOT_EMBEDDED); com.itextpdf.text.DocumentException: Font 'STSong-Light' with 'UniGB-UCS2-H' is not recognized. at com.itextpdf.text.pdf.BaseFont

How to add a shading pattern to a custom shape

可紊 提交于 2019-12-20 07:23:21
问题 I have drawn an equilateral triangle as follows using iText canvas.setColorStroke(BaseColor.BLACK); int x = start.getX(); int y = start.getY(); canvas.moveTo(x,y); canvas.lineTo(x + side,y); canvas.lineTo(x + (side/2), (float)(y+(side*Math.sin(convertToRadian(60))))); canvas.closePathStroke(); I wish to multi color gradient in this shape i.e. fill it with shading comprising of BaseColor.PINK and BaseColor.BLUE . I just can't find a way to do this with iText ? 回答1: I've created an example

how can I add cellspacing to pdftable when parsing html using XMLWorker and itext

不问归期 提交于 2019-12-20 07:16:52
问题 I am using XMLWorker and itext to convert html to pdf . my html have a table and I need to set it's cellspacing =0 cellpadding=0 . does anyone know how to do it ? in html I saw I can replace it by setting the style : border-collapse: collapse; border-spacing: 0px ; border : 0; padding : 0; thanks Tami 回答1: I've tried what you're doing using the CSS you propose and it works for me: You can find my test here: ParseHtmlTable5 This is my HTML (including the CSS): table3_css.html <html> <head>

Text extraction is empty and unknown for text has type3 font using PDFBox,iText (difficult topic!)

北城余情 提交于 2019-12-20 07:09:33
问题 I have PDF file in Arabic that has text with font Type3 when I extract text using PDFBox some characters are empty and their font equals null? I want to know what is the problem? code: protected void processTextPosition(TextPosition text) { String character=text.getCharacter(); // is empty String font=text.getFont().getBaseFont(); // equal null } stream produced with iText: ( dJ� v{d W�cG�)Tj I speak about these question marks, why do I get the characters in this format? These question marks

JTable to PDF converter

做~自己de王妃 提交于 2019-12-20 07:05:05
问题 I have a problem in Java code to convert JTable to PDF. It throws NullPointerException and same code works in another page no difference at all in both. The code private void print() { Document document = new Document(); try { PdfWriter writer = PdfWriter.getInstance(document, new FileOutputStream("jTable.pdf")); document.open(); PdfContentByte cb = writer.getDirectContent(); cb.saveState(); Graphics2D g2 = cb.createGraphicsShapes(800, 500); Shape oldClip = g2.getClip(); g2.clipRect(0, 0, 800

JTable to PDF converter

放肆的年华 提交于 2019-12-20 07:04:25
问题 I have a problem in Java code to convert JTable to PDF. It throws NullPointerException and same code works in another page no difference at all in both. The code private void print() { Document document = new Document(); try { PdfWriter writer = PdfWriter.getInstance(document, new FileOutputStream("jTable.pdf")); document.open(); PdfContentByte cb = writer.getDirectContent(); cb.saveState(); Graphics2D g2 = cb.createGraphicsShapes(800, 500); Shape oldClip = g2.getClip(); g2.clipRect(0, 0, 800

Creating table with 2 rows in pdf footer using itext

让人想犯罪 __ 提交于 2019-12-20 06:36:32
问题 Hi I want to add footer with 2 rows. 1st row will have document name with background color. 2nd row will have copy rights notes. I tried to create using ColumnText. but I am not able to set the background color for the row(only text getting background color). Is there any ay to achieve this. i spend my whole night to find a solution but not able to do. 回答1: You could have saved yourself a sleepless night by reading the documentation. You'd have discovered that you can set the background of a