Hi,
with the following source can you replease test with blanks
NO WARRANTY!

--------------------------------------------------
  public static void main(String argv[]) {
System.out.println("input file: " + argv[0] + "; putputfile: " + argv[1]);
     String existingPdf = argv[0];
     int nextToken;
     try {
        PdfReader reader = new PdfReader(existingPdf);
        File outFile = new File(argv[1]);
Document document = new Document(reader.getPageSizeWithRotation (1)); PdfWriter writer = PdfWriter.getInstance(document, new FileOutputStream(outFile));
        document.open();
        //empty content from the writer
        PdfContentByte cb = writer.getDirectContent();
        for (int i = 1; i <= reader.getNumberOfPages(); i++) {
           document.newPage();
           int thisToken = 0;
           byte btPage[] = reader.getPageContent(i);
           PRTokeniser tk = new PRTokeniser(btPage);
           while (tk.nextToken()) {
              switch (tk.getTokenType()) {
                 case PRTokeniser.TK_STRING:
                    nextToken = tk.getFilePointer();
                    String tmpStr = tk.getStringValue();
                    String srcText = "---";
                    if (tmpStr.startsWith(srcText)) {
                       for (int zz=thisToken +2; zz < nextToken-1; zz++)
                          btPage[zz] = 0x20; //or another character
                    }  //if (tmpStr.startsWith("---"))
                    break;
              }  //switch (tk.getTokenType())
              thisToken = tk.getFilePointer();
           }  //while (tk.nextToken())
           reader.setPageContent(i, btPage);
           PdfImportedPage page = writer.getImportedPage(reader, i);
           cb.addTemplate(page, 0, 0);
        }  //for (int i = 1; i <= reader.getNumberOfPages(); i++)
        document.close();
     } catch (Exception e) {e.printStackTrace();}
  }  //main

---------------------------------------------------

br
rumen
begin:vcard
fn:Rumen Varbanov
n:Varbanov;Rumen
org:dox.at;Software
adr;quoted-printable:;;Wartingergasse 43/13;Graz;Steiermark;8010;=C3=96sterreich
email;internet:[EMAIL PROTECTED]
title:Dipl. Ing.
tel;work:+43 316 811 966 -40
tel;fax:+43 316 811 899
tel;cell:+43 676 41 949 40
x-mozilla-html:TRUE
url:http://www.dox.at
version:2.1
end:vcard

-------------------------------------------------------------------------
This SF.net email is sponsored by: Splunk Inc.
Still grepping through log files to find problems?  Stop.
Now Search log events and configuration files using AJAX and a browser.
Download your FREE copy of Splunk now >>  http://get.splunk.com/
_______________________________________________
iText-questions mailing list
iText-questions@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/itext-questions
Buy the iText book: http://itext.ugent.be/itext-in-action/

Reply via email to