Japanese text from jsp to pdf using itext

I am using itext for pdf export in my application.
It works well for english text.But I have pages in japanese also.
when i export japanese pages to pdf it shows ??? in pdf files.

Install Google at your machine, enter the following keywords "java", "pdf" and "api" in that input field, hit the submit button and explore the results.

Similar Messages

  • Adding text to PDF using iText instead of CFPDF

    Hi,
    I know this may seem a bit off topic being posted here but i'm asking this board since i'm a complete JAVA noob and i figure some of you CF folk might have had to do this before.
    Anyway, about my question...i'm already adding a watermark image to a pdf using iText (CF8) thanks to the help of fellow poster (=cfSearching=).  What i'm looking for is the best way to go about adding some text to this same pdf.  I need to add 4 lines of text (with specific font and size) and center it underneath the added image.   Does anyone have a site they could point me to as to how to add formatted text and how to get the width of that text so as to align it correctly?  I've search Google and looked at a lot of JAVA code but being a JAVA noob it's tough to figure out exactly which libs and methods can be used to do this. 
    Any help would be greatly appreciated!
    -Michael

    Hi again!
    Well, the merged image is an idea but i'd rather have it be actual text so that it is at least copy/paste-able if viewed on a computer.
    The four lines of text are dynamic (company name, broker name, phone number, email address) and limited to 40 characters.  Right now they are being added via CFPDF and DDX and use the following code in the DDX file to add it to the PDF.
    <PDF result="DestinationFile">
         <PDF source="SourceFile">
              <Watermark
              rotation="0"
              opacity="100%"
              horizontalAnchor="#horzAnchor#"
              horizontalOffset="#horzOffset#"
              verticalAnchor="#vertAnchor#"
              verticalOffset="#vertOffset#"
              alternation="OddPages"
              >
                   <StyledText text-align="center">
                        <p font="#font#" color="#color#" >#left(dCompany,maxlinechars)#</p>
                        <p font="#font#" color="#color#" >#left(dName,maxlinechars)#</p>
                        <p font="#font#" color="#color#" >#left(dPhone,maxlinechars)#</p>
                        <p font="#font#" color="#color#" >#left(dEmail,maxlinechars)#</p>
                   </StyledText>
              </Watermark>
         </PDF>
    </PDF>
    Then using the created pdf from above, i use a slightly modified version of the cfscript code ( that uses iText) you provided me previously to add a logo image just above this text.  The only changes i made to it were resizing of the image and adding where to place it.  Here is that code:
    <cfscript>                    
        fullPathToInputFile = "#tempdestfilepath#";
         writeoutput("<br>fullPathToInputFile=#fullPathToInputFile#");
        fullPathToWatermark = osFile("#request.logofilepath##qord.userlogo_file#",request.os);
         writeoutput("<br>fullPathToWatermark=#fullPathToWatermark#");
        fullPathToOutputFile =  "#destfilepath#";
         writeoutput("<br>fullPathToOutputFile=#fullPathToOutputFile#");
         ppi = 72; // points per inch
         watermark_x =  ceiling(#qord.pdftemplate_logo_x# * ppi);      // from bottom left corder of pdf
         watermark_y =  ceiling(#qord.pdftemplate_logo_y# * ppi);     // from bottom left corder of pdf
         fh = ceiling(0.75 * ppi);
         fw = ceiling(1.75 * ppi);
       if( not fileexists(fullPathToInputFile) )
                  savedErrorMessage = savedErrorMessage & "<li>Input file pdf for logo add does not exist<br>#fullPathToInputFile#</li>";
       else
                 try {
                 // create PdfReader instance to read in source pdf
                 pdfReader = createObject("java", "com.lowagie.text.pdf.PdfReader").init(fullPathToInputFile);
                 totalPages = pdfReader.getNumberOfPages();
                 // create PdfStamper instance to create new watermarked file
                 outStream = createObject("java", "java.io.FileOutputStream").init(fullPathToOutputFile);
                 pdfStamper = createObject("java", "com.lowagie.text.pdf.PdfStamper").init(pdfReader, outStream);
                 // Read in the watermark image
                 img = createObject("java", "com.lowagie.text.Image").getInstance(fullPathToWatermark);
                    w = img.scaledWidth();
                   h = img.scaledHeight();
                   //$is[0] = w
                   //$is[1] = h
                   if( w >= h )
                      orientation = 0;
                  else
                      orientation = 1;
                      fw = max_h;
                      fh = max_w;
                  if ( w > fw || h > fh )
                      if( ( w - fw ) >= ( h - fh ) )
                          iw = fw;
                          ih = ( fw / w ) * h;
                      else
                          ih = fh;
                          iw = ( ih / h ) * w;
                      t = 1;
                  else
                      iw = w;
                      ih = h;
                      t = 2;
                 // adding content to each page
                 i = 0;
                 //while (i LT totalPages) {
                     i = i + 1;
                     content = pdfStamper.getOverContent( javacast("int", i) );
                     img.setAbsolutePosition(javacast("float", watermark_x), javacast("float", watermark_y));
                        if(t==1)
                             img.scaleAbsoluteWidth( javacast("float", iw) );
                             img.scaleAbsoluteHeight( javacast("float", ih) );
                     content.addImage(img);
                     WriteOutput("Watermarked page "& i &"<br>");
                 //WriteOutput("Finished!");
                 catch (java.lang.Exception e) {
                 savedErrorMessage = savedErrorMessage & "<li>#e#</li>";
             // closing PdfStamper will generate the new PDF file
             if (IsDefined("pdfStamper")) {
                 pdfStamper.close();
             if (IsDefined("outStream")) {
                 outStream.close();
    </cfscript>
    The above code resized the image to a certain width/height if needed and adds it to the pdf. 
    I just figured they might be a way to tap into one of the java objects that would allow adding the text.  Ideally, adding the text and image to some sort of 'bounding box' that would allow centering of the image and text in relation to that bounding box.  Or if there is no way to add to a bounding box, a way to get the horizontal length of the longest line of text so i could calculate a common centerline for the image and text.
    I've attached the following pdf to show how the image and text would look together.  This example is not to scale but a similar image and text would be added to a separate pdf.
    Thanks for you help.

  • Read text from a simple PDF file

    Is it possible to extract text from a simple PDF (Non-Interactive) in ABAP? May be using the class CL_FP_PDF_OBJECT ?
    Let's say I have a pdf document with a couple of lines of text. How can I read the "actual" text in an ABAP program?
    Thanks for your help!

    Of course you can do this, but not using the standard SAP/ABAP/Adobe.
    Check for the Java library called iText. Now you think you don´t need Java, of course. If you cannot use Java, at least you can check the coding of this library and do it in ABAP for yourself.
    But there is no such a tool in standard SAP because why would one buy a Interactive form licence if it would be so easy?

  • How to replace numbers with text in tax return pdf using Adobe Acrobat X Pro

    How do I replace numbers with text in tax return pdf using Adobe Acrobat X Pro? The tax return was created using CCH software. Thanks for your review.

    Thanks Bill for your quick reply. CCH software is one of the major
    suppliers of tax return software. I found an internal source that helped me
    make the changes from numbers to text i.e. "$123,456" to "See Schedule O".
    I am not sure if I am working in form or final text. Thanks again! Kelly

  • Creating PDF using ITEXT API's - error

    Hi,
    In my WebDynpro Application I want to generate a PDF (using ITEXT API's) out of the data retrieved from back end system .
    I used this source code.
    Document document = new Document(PageSize.A4);
    document.open();
    PdfPTable table = new PdfPTable(1);
    PdfPCell cell;
    cell = new PdfPCell(new Paragraph("ONE"));
    table.addCell(cell);
    cell = new PdfPCell(new Paragraph("TWO"));      
    table.addCell(cell);
    document.add(table);
    document.close();
    byte[] b = new byte[100 * 1024];
    b =  document.toString().getBytes("UTF-8");
    IWDCachedWebResource pdfRes = WDWebResource.getPublicCachedWebResource(b, WDWebResourceType.PDF, WDScopeType.CLIENTSESSION_SCOPE,      wdThis.wdGetAPI().getComponent().getDeployableObjectPart(),"FileNameHelloText"));
    I have used Window Manager to create a external window with the URL from pdfRes.getUrl() method.
    After execution i get a pop up window with out PDF document.
    Please let me know your thoughts & solutions to the above mentioned problem.
    Thanks
    Senthil

    Hello Folks,
                   Use the following snippet of the code to generate PDF using ITEXT API.
                                       Document document = new Document(PageSize.A4);
         ByteArrayOutputStream bos = new ByteArrayOutputStream();
         PdfWriter.getInstance(document, bos);
         document.open();
                    PdfPTable table = new PdfPTable(1);
                    PdfPCell cell;
                    cell = new PdfPCell(new Paragraph("ONE"));
                    table.addCell(cell);
                    cell = new PdfPCell(new Paragraph("TWO"));      
                    table.addCell(cell);
                    document.add(table);
                    document.close();
                    byte [] byteContent = bos.toByteArray();
         IWDCachedWebResource cachedResource =
                             WDWebResource.getPublicCachedWebResource(
              byteContent,
              WDWebResourceType.PDF,
              WDScopeType.CLIENTSESSION_SCOPE,
              wdThis
                                          .wdGetAPI()
                                          .getComponent()
                                          .getDeployableObjectPart(),
              "TestPDF");
                  IWDWindow externalWindow =
            wdComponentAPI
                            .getWindowManager()
                            .createExternalWindow(cachedResource.getURL(),                         "PDF Window",true);
                  externalWindow.open();
    Thanks and Regards,
    Gopi

  • Adding a link in PDF using itext

    I am adding a link in PDF using itext and opening the link from the final created pdf using app.launchURL and app.getURL
    it works fine on windows XP but does nothing on MAC OSX /IOS

    Hi Lynn
    And here I was about to suggest you review the link below.
    Silly me.
    Click
    here to read the article
    Sincerely... Rick

  • Hypertext links are not always preserved from Word to PDF, using Aperçu or Adobe, depending on OS 10 or Lion. Why? This generally works perfectly in Windows. Why are Apple and Adobe unable to correctly handle links when converting from Word to PDF?

    Hypertext links are not always preserved from Word to PDF, using Aperçu or Adobe, depending on OS 10 or Lion. Why? This generally works perfectly in Windows. Why are Apple and Adobe unable to correctly handle links when converting from Word to PDF?
    Depending on the system version, and Office Word version:
    - a pure URL link starting with http or even www sometimes works in PDF, either produced by Aperçu or Adobe, sometimes does not work;
    - other kind of links where the text under display is not a URL, never work!
    I like everything with Apple computers and software, except PDF generation. Output files are usually bigger in size, and no better quality, than under Windows. Furthermore, it is weird that something as common as hyperlinks does not work correctly!
    I related this question with Mac OS X Snow Leopard, but the problem is still there with Mac OS Lion.
    This problem seems to have been around for years, without any proper solution from Apple and/or Adobe! To me, this is very embarrassing!

    Greetings NoNameGiven,
    If I understand the problem correctly (I’m not sure I do) you would prefer ‘iii’ to be read as “eye eye eye” rather than “three”? The alt text property is the only way that I know of to make this happen. Hope this helps.
    a ‘C’ student

  • Cannot copy text from DRM-free PDF on PC

    I can on my Mac. Both use Adobe Reader v11.x. I think the behaviour started when I updated to version 11 on the PC.
    I cannot copy text from DRM-free PDFs that I read. I can switch to the Select Tool cursor but drag-select does not work as it did before. Double-click can highlight (and copy) a word. A triple-click can do so for a line. This is clumsy and inefficient and I cannot grab more than a line of text.
    File > Properties: Security shows 'No Security'. I am stumped. Is there some detail I am missing? (I downloaded and switched to FoxIt Reader to take notes now but prefer my knowledge of navigation shortcuts in Adobe Reader.)

    Hi jroth,
    How are you "re-printing" the PDF? Once you have a PDF file, it shouldn't be necessary to re-create it just because you've made changes. You could simply save the file at that point. But it sounds like you're concerned about preventing changes to the comments. If that's the case, rather than reprinting, you could assign some document permissions to the PDF to prevent people from changing the content. To assign that security, choose File > Properties and click the Security tab.
    I'm guessing here, because I'm not sure what process you're using, but it sounds as though that second iteration is being printed as an image. That would change the searchable text to an image, and could certainly cause the issue you're encountering.
    Best,
    Sara

  • Problem while generating PDF using iText

    Hi:
    I have generated PDF using iText, where i have written all code in sequential flow.
    <code>
    com.lowagie.text.Document document = new com.lowagie.text.Document(PageSize.A4, 55, 5, 20, 20);
    OutputStream outputstream = response.getOutputStream();
    PdfWriter.getInstance(document,outputstream);
    </code>
    And i have added all fields in the document.
    But my problem is how to display total pagecount on all pages e.g.1\20 (because i have generated PDF sequentially)
    Also i want to add watermark on all pages.
    So, can any body help me to solve this problem?
    Thank You,
    Balaji

    sabre150 wrote:
    Maybe http://itext-general.2136553.n4.nabble.com/
    Nice pron link in there :/

  • How to write special characters in PDF using iText

    How to write special characters encoded with UTF-8 in PDF using iText.
    Regards,
    Pandharinath.

    I don't know what your problem is but that's almost certainly the wrong question to ask about it. Java (including iText) uses only Unicode characters. (You may consider some of them to be "special" if you like but Unicode doesn't.) And when it does that, they aren't encoded in UTF-8 or any other encoding.
    So can you describe your problem? That question doesn't make sense.

  • Convert list item attachment from docx to pdf using Word Automation Services

    I have been trying to convert List Item attachments from docx to pdf using word automation services, it works in a normal document library but when I use the list attachment it throws a null reference error.
    var settings = new ConversionJobSettings();
    settings.OutputFormat = Microsoft.Office.Word.Server.Conversions.SaveFormat.PDF;
    var conversion = new ConversionJob("Word Automation Services", settings);
    conversion.UserToken = SPContext.Current.Site.UserToken;
    var wordFile = SPContext.Current.Site.RootWeb.Url + "/" + wordForm.Url;
    var pdfFile = wordFile.Replace(".docx", ".pdf");
    conversion.AddFile(wordFile, pdfFile);
    conversion.Start();
    Using reflector I was able to see my problem lies in Microsoft.Office.Word.Server.FolderIterator.cs where it uses SPFile.Item which returns NULL
    internal void CheckSingleItem(SPFile inputFile, SPFile outputFile)
    Microsoft.Office.Word.Server.Log.TraceTag(0x67337931, Microsoft.Office.Word.Server.Log.Category.ObjectModel, Microsoft.Office.Word.Server.Log.Level.Verbose, "OM: FolderIterator start a single item: source='{0}'; dest='{1}'", new object[] { inputFile.Url, outputFile.Url });
    Stopwatch stopwatch = Microsoft.Office.Word.Server.Log.StartPerfStopwatch();
    try
    this.CheckInputFile(inputFile.Item);
    this.CheckOutputFile(outputFile.Url);
    Is there any way to get around this?

    Hi Qfroth,
    According to your description, my understanding is that when you use word automation service to convert Word to PDF for list item attachment, it throws the null reference error.
    I suggest you can create an event receiver and convert the word to memory stream like below:
    private byte[] ConvertWordToPDF(SPFile spFile, SPUserToken usrToken)
    byte[] result = null;
    try
    using (Stream read = spFile.OpenBinaryStream())
    using (MemoryStream write = new MemoryStream())
    // Initialise Word Automation Service
    SyncConverter sc = new SyncConverter(WORD_AUTOMATION_SERVICE);
    sc.UserToken = usrToken;
    sc.Settings.UpdateFields = true;
    sc.Settings.OutputFormat = SaveFormat.PDF;
    // Convert to PDF
    ConversionItemInfo info = sc.Convert(read, write);
    if (info.Succeeded)
    result = write.ToArray();
    catch (Exception ex)
    // Do your error management here.
    return result;
    Here is a detailed code demo for your reference:
    Word to PDF Conversion using Word Automation Service
    Best Regards
    Zhengyu Guo
    TechNet Community Support

  • How to display Japanese text from an XML file

    Hiya,
    I have various adapted mp3 players [called playlists on my site] which retrieve the songs and song titles/artists from an XML file. One of them plays Japanese music.
    Most of the tracks are in English but I now have a couple of songs with Japanese titles and file names which I can't get to preview/display in Flash Pro CS5 [Mac]. I can type static Japanese text and it displays fine but Flash seems to be having a problem with the Japanese from the XML file.
    Though I can find the English titles, etc, it would be nice if there were a way to display Japanese text from a 'multi-lingual' [English and Japanese] XML file [probably something really easy].
    Thanks a bunch.
    steve

    This should help you:
    http://http://www.packtpub.com/article/working-with-xml-in-flex3-and-java-1http://www.packtpub.com/article/working-with-xml-in-flex3-and-java-1

  • Arabic text in my web application using iText..

    Hey Guys,
    I'm using the iText library to produce PDF reports in my web application; platform (ADF 11g and Weblogic 10g). I'm having a problem with rendering arabic text on the page, is there a way to print arabic text outside of a PdfPTable ?? I need to print a simple text like the title of the report , the subtitle and so on... please guys I need an answer...
    Thanks in advance.
    AccadSoft

    gimbal2 wrote:
    sabre150 wrote:
    AccadSoft wrote:
    please guys I need an answer.To get answers about using iText I use "iText In Action, 2nd edition" by the prime author of iText - Bruno Lowagie.Classic way to make money - make the API free and sell the documentation. Also an honorable way to make money IMO.I was using iText before 2004 when the first edition of the book came out ( 4 years or so after the library was first introduced) and it was hard work. PDF is a very complex document format and just using the Javadoc does not really get you anywhere. There are many 'gotchas' in iText and most of the iText tutorials cover only the very basics and pretty much none of the 'gochas'. The book starts off with very simple examples that could be constructed from the Javadoc but then it does move on to the more complex issues. Worth every penny.

  • Japanese text display problems in applet using plugin

    Hi,
    We've been beating our heads against the wall on this one for quite some time, so any help would be greatly appreciated.
    Our product uses a third party applet (Kavachart from Visual Engineering) to display graphical statistics from our database. We are currently localizing our product to support english and japanese. With Japanese enabled, all pages use euc-jp encoding. The problem we are running into is in the display of japanese text inside this applet in IE 5 and NS 4.7x when using the java plugin (1.3 or 1.4). If the default jre of the browsers are used, the text in the applet renders fine.
    On a suggestion from the supprot folks at Visual Engineering, I modified our code to set the defaultFont parameter on the applet to "serif, 14, 1". With this set, the text in the applet renders ok in IE, but NS on windows and unix is still broken. Given that we are doing all these tests on machines running a native japanese OS, it's not even clear to me why setting the defaultFont should even be required, but at this point, I'll take anything :-)
    Has anyone else run into this and either solved it or proven that a solution is not feasible? I'm at my wits end here....
    Thanks in advance,
    Mark Evangelisto
    Synchronicity Inc.

    If you are using different java plugin, you need to install the international version of the JRE; otherwise, some characters may not be able to display correctly since some of the properties files are missing.
    As for Visual Engineering's suggestion. I don't know why they tell you to set the default font on the applet because it may cause the browser to use the font specified. Your applet works on IE because it will try to use the best font to match the web page's content. For NS anything less then 6.0 (technology based on Mozilla), they never display web page correctly especially if you did what VE suggest.
    If you are running the applet on the native langauge OS with the international version of the JRE installed, the applet should display correctly without setting the default font. If it is not the native langauge OS, first you need to install the international version of the JRE and have the fonts that are able to display the language the applet use.

  • Select a text from a word/pdf document for tagging.

    Hi,
    After an overwhelming response for my [first thread|Thumbnail creation during Image Upload; , I am hoping that my second post will have a solution.
    I am currently working on a knowledge management tool using ABAP WD. The requirement is to open the existing documents and select some text and tag/categorize it.  I also found out that using flash islands, it is possible to get the selected text from textField and pass it back to the ABAP WD binded variable.
    Is there a way to display word/pdf file and perform the text tagging in WD ? using office integration ? Kind help would be greatly appreciated.

    Never mind--I figured it out.

Maybe you are looking for

  • Can someone read this crash log and tell me whats wrong please

    Anonymous UUID:       7F4336E4-C6DA-0238-7240-8EEE20983BFD Thu Aug  7 16:08:47 2014 panic(cpu 1 caller 0xffffff80082dc24e): Kernel trap at 0xffffff7f8a16f9f1, type 14=page fault, registers: CR0: 0x000000008001003b, CR2: 0xffffef811ed3bf00, CR3: 0x000

  • Lenovo - can we get an idea on timing for drivers for windows 7?

    I know the standard answer - soon after the final version ships. However, I also know that OEMs and Microsoft are working hard to make sure drivers are available at launch. So how about some love here and let us folks leaning into the wind test some

  • FIFO at the time of 541 and 543

    Dear experts, I am having two issues here 1. We are having subcontracting scenario.We want to issue componets to the subcontractor on the basis of FIFO based on batch.System will have to propose the quantities available for the batch at the time of T

  • How do I receive the download information via e-mail for photoshop elements again?

    My computer crashed and all data was lost.  This software was purchased online about a year ago.

  • Trying to take one phone off my account

    i have three phones on our family account. my contract is up on one phone i want to remove this number from the account. Verizon has options for every other thing in the world,all i want to do is remove this phone!!! live chat is unavailable/busy. an