There's no issue here. iText can copy page contents from other pdf but can't
change them.

Best Regards,
Paulo Soares

----- Original Message -----
From: "krishnakumar" <[EMAIL PROTECTED]>
To: <[EMAIL PROTECTED]>
Sent: Wednesday, August 14, 2002 11:38
Subject: [iText-questions] Embed Font Issuse in PDF


> Hi,
> Here i have a issuse with Embed the Font into the PDF.I need to read a
> PDF and write into another file with the content should be in different
> Font with font Embeding.Form your examples i am able to read and concat
> the PDF's.But i am not able to change the Source File text Font by
> embeding.
> Regs,
> Thanks With Regards,
> K.Krishna Kumar
>
> Here i am attachig the Java Source to Embed the Font:
> import java.io.*;
> import com.lowagie.text.*;
> import com.lowagie.text.pdf.*;
> public class EmbedFont
> {
>   private static final String FONT_TimesNewRoman =
> "c:\\winnt\\fonts\\times.ttf";
>   private static final String FONT_CordiaUPC =
> "c:\\winnt\\fonts\\CORDIAU.TTF";
>   private static BaseFont bfont;
>   public static void main (String args[])
>   {
>         if (args.length < 2)
>  {
>             System.err.println("This tool needs at least 2
> parameters:\njava Concat destfile Srcfile");
>         }
>         else
>  {
>             try {
>                 int f = 1;
>   PdfReader reader = new PdfReader(args[f]);
>   int n = reader.getNumberOfPages();
>   System.out.println(n);
>
>   Document document = new Document(reader.getPageSizeWithRotation(1));
>   PdfWriter writer = PdfWriter.getInstance(document, new
> FileOutputStream(args[0]));
>
>          bfont= BaseFont.createFont( FONT_CordiaUPC,BaseFont.IDENTITY_H,
> BaseFont.EMBEDDED);
>   document.open();
>
>   PdfContentByte cb = writer.getDirectContent();
>
>   PdfImportedPage page;
>                 int rotation;
>    file://cb.setFontAndSize <file://cb.setFontAndSize> (bfont, 14);
>                 // step 4: we add content
>                 while (f < args.length) {
>                     int i = 0;
>                     while (i < n) {
>                         i++;
>
> document.setPageSize(reader.getPageSizeWithRotation(i));
>                         document.newPage();
>                         page = writer.getImportedPage(reader, i);
>     file://page.setTextRenderingMode <file://page.setTextRenderingMode>
> (1);//kk
>     file://page.setFontAndSize <file://page.setFontAndSize>
> (bfont,14);//kk
>                         rotation = reader.getPageRotation(i);
>                         if (rotation == 90 || rotation == 270) {
>                             cb.addTemplate(page, 0, -1f, 1f, 0, 0,
> reader.getPageSizeWithRotation(i).height());
>                         }
>                         else {
>                             cb.addTemplate(page, 1f, 0, 0, 1f, 0, 0);
>                         }
>                         System.out.println("Processed page  :" + i);
>                     }
>                     f++;
>                     if (f < args.length) {
>                         reader = new PdfReader(args[f]);
>                         // we retrieve the total number of pages
>                         n = reader.getNumberOfPages();
>                         System.out.println("There are " + n + " pages in
> the original file.");
>                     }
>                 }
>   Paragraph paragraph = newParagraph( document, newCordiaUPCFont());
>   document.close();
>   }//end of try
>   catch(Exception e)
>   {
>                 System.err.println(e.getClass().getName() + ": " +
> e.getMessage());
>   }//end of catch
>         }//end of else
>     }//end of main function
>     static private Paragraph newParagraph (Document document, Font font)
>     throws Exception
>     {
>       document.newPage();
>       Paragraph paragraph = new Paragraph("This is the test For Embed
> the Font", font);
>       paragraph.setAlignment( Element.ALIGN_JUSTIFIED);
>       document.add(paragraph);
>       return paragraph;
>     }
>     static private Font newTimesNewRomanFont ()throws Exception
>     {
>       Font font = new Font(bfont, 8);
>       return font;
>     }
>     static private Font newCordiaUPCFont ()throws Exception
>     {
>       Font font = new Font(bfont, 14);
>       return font;
>     }
>
>
> }//end of class
>
>
>



-------------------------------------------------------
This sf.net email is sponsored by: Dice - The leading online job board
for high-tech professionals. Search and apply for tech jobs today!
http://seeker.dice.com/seeker.epl?rel_code=31
_______________________________________________
iText-questions mailing list
[EMAIL PROTECTED]
https://lists.sourceforge.net/lists/listinfo/itext-questions

Reply via email to