Learn itext from scratch create pdf1. Create a PDF with a streamImportJava.io.File;ImportJava.io.FileOutputStream;Importcom.itextpdf.text.*;ImportCom.itextpdf.text.pdf.PdfWriter; Public classPdftest { Public Static voidMain (string[] args)throwsException {/*** PDF Preparation defines the document file output stream and other files. pdf*/Document Pdfdoc=NewDocument (); //path output stream of the PDF file to be generatedFileOutputStream Pdffile =NewFil
This document uses the itext jar package to encapsulate and export existing data. You can also use office to open the RTF file.
The Code includes setting the header and footer, adding a table, etc.
For details, see the source code: annotation description.
/*** Wordserver. java * copyright (c) 2012 * created: cuiran 13:20:40 */package COM. cayden. web. base; import Java. AWT. color; import Java. io. fileoutputstream; import Java. io. ioexception; impo
Java itext package usage exception
Java itext package usage exception
Java. lang. NoClassDefFoundError: org/bouncycastle/asn1/ASN1Primitive exceptions must be introduced in pom when using itext.
Then java. lang. securityException: class "org. bouncycastle. asn1.ASN1Primitive "'s signer information does not match signer information of other classes in the s
In the newer version of Itext, there is still a problem with the support of Chinese, the information obtained on the network and the various attempts, the font file XX. TTF into the project, and then loaded into the basefont, feasible. As follows:
basefont font = basefont.createfont (path + msyh). TTF ", Basefont.identity_h, basefont.embedded);
Jar Package Required:
The jar package under the Itext-5.3.0.z
Itext the latest version of 5.0.1, the official binary version of the Asian font is still not directly integrated solution, loading Itextasian.jar to Classpath has not been working, prompted the following error:Font ' stsong-light ' with ' unigb-ucs2-h ' isn't recognizedThe whole day did not get to the path, had to go to view the source code, find the Cjkfont class, from which to seeInputStream is = Getresourcestream (Resource_path + "cjkfonts.propert
Java Itext Package Usage exception problemItext java.lang.noclassdeffounderror:org/bouncycastle/asn1/asn1primitive exceptions are required to be introduced into the POM when usingthen appears java.lang.SecurityException:class "Org.bouncycastle.asn1.ASN1Primitive" ' s signer information does not match Signer information of other classes in the same package this exception is due to the introduction of the Bcprov packet conflict was checked because the f
Recently, the project needs to investigate how to add the logo in pdf to differentiate versions. Finally, it is determined to use itext for implementation.
The Code is as follows:
Java code/*** Authory kingviker* Time: 2012-12-12*/Import java. io. FileOutputStream;Import java. io. IOException; www.2cto.comImport com. itextpdf. text. DocumentException;Import com. itextpdf. text. Font;Import com. itextpdf. text. Image;Import com.itext;.text=. BaseFont;I
1, import the required jar package: Itext-asian-5.2.0.jar Itextpdf-5.5.11.jar.2. New Word document, create template, save file as PDF, open edit with Adobe Acrobat DC, click "Prepare form" on the right and click "Start"3. In the space where you need to insert the data, right click, click "Text Field", drag and drop the text field to the location you want, change the domain name as the variable name you passed in.4. Save the file and put the file in th
ITEXT5 Header and Footer tool class, implementing page X of Y perfect compatibility with various format sizes document A4/B5/B3, compatible with various document formats automatically calculate footer xy axis coordinates
Since no one has done so carefully, he wrote a ITEXT5 header and Footer tool class, to achieve the first few pages/a total of several pages, to facilitate you just enter the itext of children's shoes call. September 16, 2013 14:51:
PageFormat ();Paper pp = new Paper ();Pp. setSize (width, height );Pp. setImageableArea (0, 0, width, height );Pg. setPaper (pp );Prm. print (g2, pg, 0 );G2.dispose ();
ImgTemplate img = new ImgTemplate (template );Document. add (img );} Catch (incluentexception e ){System. err. println (e );} Catch (IOException e ){System. err. println (e );}Document. close ();
}
Keep in mind that you will need the Batik and Xerces libraries in addition to the iTExt
Related ja bag: Itext-5.0.6.jar,itextasian-1.5.2.jar.
Note: You must modify the package path in the Itextasian-1.5.2.jar with WinRAR or haozip to change the package path to com.itextpdf.text.pdf.fonts. Otherwise, the PDF-times error is generated.
Example code:
Package com.xy6;
Import Java.io.File;
Import Java.io.FileOutputStream;
Import Java.io.OutputStream;
Import Java.util.Date;
Import Com.itextpdf.text.BaseColor;
Import com.itextpdf.text.Document
(). GetBytes ());Xmlworkerhelper.getinstance (). parsexhtml (writer, document, bis,cssis);Document.close (); } /*** Obtain the source code of the website through the website domain URL * *@paramURL *@returnString *@throwsException*/ Public StaticString geturlsource (File URL)throwsException {inputstream instream=Newfileinputstream (URL); //get HTML binary data from an input stream byte[] data = Readinputstream (instream);//converts binary data to byte byte dataString Htmlsource =NewSt
Html2canvas JSHtml1 Div ID = "Divpdf" > 2 Required Area 3 Div >Js12Background using picture Base64 encoding for image conversion1 //2 ///convert Base64 encoding to image3 /// 4 /// Base64 String5 /// The conversion succeeded in returning the image; Failed returns null6 Public stringBase64toimage (stringImgname,stringBase64string,stringpath)7 {8base64string = Base64string.replace ("Data:image/png;base64,","");9MemoryStream ms =NULL;TenS
https://kathleen1974.wordpress.com/category/itext-pdf/In one of my project, we need to give the user a Web UI (a textbox) to enter some text and allow input of superscriptand s Ubscript tag Take your own change as follows:public class Pdfutil {private static Logger Logger = Loggerfactory.getlogger (pdfutil.class);/** handles superscript and small labels for numbers */public Static final String subscript = "public static Font fontgeneral;//general cont
The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion;
products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the
content of the page makes you feel confusing, please write us an email, we will handle the problem
within 5 days after receiving your email.
If you find any instances of plagiarism from the community, please send an email to:
info-contact@alibabacloud.com
and provide relevant evidence. A staff member will contact you within 5 working days.