itext

Paint Swing Component to PDF using iText

我怕爱的太早我们不能终老 提交于 2020-01-05 08:57:23
问题 I have a JFrame, which i wish to save as a PDF. How do i paint this JFrame using iText? public PrintFrameToPDF(JFrame bill) { try { Document d = new Document(); PdfWriter writer = PdfWriter.getInstance(d, new FileOutputStream ("sample.pdf")); d.open (); // HOW ? d.close (); } catch(Exception e) { // } } 回答1: This should do the trick (and it's generic for JComponent object): public PrintFrameToPDF(JFrame bill) { try { Document d = new Document(); PdfWriter writer = PdfWriter.getInstance(d, new

Paint Swing Component to PDF using iText

末鹿安然 提交于 2020-01-05 08:57:07
问题 I have a JFrame, which i wish to save as a PDF. How do i paint this JFrame using iText? public PrintFrameToPDF(JFrame bill) { try { Document d = new Document(); PdfWriter writer = PdfWriter.getInstance(d, new FileOutputStream ("sample.pdf")); d.open (); // HOW ? d.close (); } catch(Exception e) { // } } 回答1: This should do the trick (and it's generic for JComponent object): public PrintFrameToPDF(JFrame bill) { try { Document d = new Document(); PdfWriter writer = PdfWriter.getInstance(d, new

How to apply double line bottom border to a cell in iText

眉间皱痕 提交于 2020-01-05 08:48:46
问题 I need your help in applying the double line bottom border only to a cell and to remove the other top, right and left borders. I am able to implement the dotted line cell borders by using the below code: class DoubleCell implements PdfPCellEvent { public void cellLayout(PdfPCell cell, Rectangle position, PdfContentByte[] canvases) { PdfContentByte canvas = canvases[PdfPTable.LINECANVAS]; canvas.setLineDash(5f, 5f); canvas.rectangle(position.getLeft(), position.getBottom(), position.getWidth()

Trying to sign pdf with a smart card

元气小坏坏 提交于 2020-01-05 08:03:22
问题 I am trying to sign pdf with a smart card. I use the following code: public class SC { public static final String SRC = "src/test.pdf"; public static final String DEST = "src/test_smartCard.pdf"; public void sign(String src, String dest, Certificate[] chain, PrivateKey pk, String digestAlgorithm, String provider, CryptoStandard subfilter, String reason, String location, Collection<CrlClient> crlList, OcspClient ocspClient, TSAClient tsaClient, int estimatedSize) throws

Show the number of pages in a pdf generated using itext only on the first page

試著忘記壹切 提交于 2020-01-05 07:44:32
问题 I am creating a PDF file using itext 2.1.7 and java servlets where I am inserting header and footer by overriding PdfpageEvents the onEndPage and onCloseDocument i am successfully able to put the pagev X of Y in the header/footer Now I want to calculate the cost of the pages (i.e. Cost of printing). So for that I need find the no. of pages in the pdf(i.e. Suppose printing of a page costs 3 I need to calculate the amount(3 * total no. of pages in pdf) for the entire pdf) and the catch is I

Parse PDF table and display it as CSV(Java)

霸气de小男生 提交于 2020-01-05 05:26:25
问题 I am trying to parse a TABLE in PDF file and display it as CSV. I have attached sample data from PDF below(only few columns) and sample output for the same. Each column width is fixed, let's say Company Name(18 char),Amount(8 char), Type(5 char) etc. I tried using Itext and PDFBox jars to get each page data and parsed line by line, but sounds like it is not a great solution as the line breaks and page breaks in PDF are not proper. Please me let me know if there is any other appropriate

itext XMLWorkerFontProvider.DONTLOOKFORFONTS and generate multi language HTML page

亡梦爱人 提交于 2020-01-05 04:54:07
问题 Can someone help to explain what is XMLWorkerFontProvider.DONTLOOKFORFONTS for? Not much explainations in the apidoc. Also, I have seen some examples on XMLWorkerFontProvider.DONTLOOKFORFONTS, mostly used with XMLWorkerFontProvider.register("font file path") to generate multi language file for known text / fonts, in the case where the text is dynamic (i.e.: can be a mixture of any language ), how should this be handled? I tried to register all the google noto fonts that can support a lot of

Generate PDF from Android

a 夏天 提交于 2020-01-05 04:20:09
问题 I want to build a pdf file from my Activity in Android. So this is the code: public File creaOrdinePDF(Ordine ordine,String linkImage,Context context){ doc = new Document(); File dir = null; String path=""; try { path = Environment.getExternalStorageDirectory() .getAbsolutePath() + directoryFolder; dir = new File(path); if (!dir.exists()) { dir.mkdirs(); //Toast.makeText(getApplicationContext(), "Directory creata", 10).show(); } Log.d("PDFCreator", "PDF Path: " + path); nomeFile="Ordine

PDF creation using iTextsharp taking too much of time

别来无恙 提交于 2020-01-05 04:06:08
问题 Iam using ASP.Net along with iTextsharp to generate PDF files. Data is returned from SQL Server in to ASP.Net in the form of a DataTable. For example if my datatable contains 1000 records with varying company id and branch id, my requirement is to write PDFs grouped by companyid and branch id. CompanyID Code Name BranchId Amount 1 XXXX xxx 10 XXXX 1 XXXX xxx 20 XXXX 5 XXXX xxx 20 XXXX 1 XXXX xxx 10 XXXX 1 XXXX xxx 10 XXXX 2 XXXX xxx 30 XXXX 5 XXXX xxx 30 XXXX 3 XXXX xxx 20 XXXX 1 XXXX xxx 50

How to avoid to tag the the empty <TR<TD> cells to PDF using Itext 5

依然范特西╮ 提交于 2020-01-05 03:56:04
问题 I an using i text 5 to generate the PDF from html as input . As part of PDF accessibility,adding pdfwriter.settagged(). But here all the empty and non-empty tags are tagging .can you please help how to avoid to tagging the non empty html tags 回答1: I suppose one way to go around it, would be to go through the StructTree on the output PDF document, and try to find the tag you are looking for, without any kids, and remove it from the parent. I do not use iText 5 anymore, as it has been