What, in the code below, would you think would be responsible for finding all 
occurrences of non-embedded fonts in your imported content and then embedding 
them?  Is there anything in the documentation that would imply that any of 
these methods - or any other method in iText - would do that?

-----Original Message-----
From: fbga81 [mailto:[email protected]] 
Sent: Wednesday, March 10, 2010 5:41 AM
To: [email protected]
Subject: [iText-questions] Embedding fonts when copying PDF

Hello,

I'm triying to copy an existing PDF to make it a PDF/A and I must embed the
fonts but I don't get it. I'm doing this:

try {
  int pageOffset = 0;
  ArrayList master = new ArrayList();
  Document document = null;
  PdfCopy  writer = null;
  String outFile = "D:\\tmp\\OUT_PDF.pdf";
  FileOutputStream("D:\\tmp\\hello_A1-b.pdf"));
  PdfReader reader = new PdfReader("D:\\tmp\\IN_PDF.pdf");
  reader.consolidateNamedDestinations();

  // we retrieve the total number of pages
  int n = reader.getNumberOfPages();

  List bookmarks = (List) SimpleBookmark.getBookmark(reader);

  if (bookmarks != null) 
  {
    if (pageOffset != 0)
      SimpleBookmark.shiftPageNumbers(bookmarks, pageOffset, null);

      master.addAll(bookmarks);
  }
  
  pageOffset += n;

  // step 1: creation of a document-object
  document = new Document(reader.getPageSizeWithRotation(1));
  // step 2: we create a writer that listens to the document
  writer = new PdfCopy(document, new FileOutputStream(outFile));
  writer.setPDFXConformance(PdfCopy.PDFA1B); 

  PdfDictionary outi = new PdfDictionary(PdfName.OUTPUTINTENT);

  outi.put(PdfName.OUTPUTCONDITIONIDENTIFIER, 
           new PdfString("sRGB IEC61966-2.1")); 
  outi.put(PdfName.INFO, new PdfString("sRGB IEC61966-2.1")); 
  outi.put(PdfName.S, PdfName.GTS_PDFA1);

  com.itextpdf.text.pdf.ICC_Profile icc =
  com.itextpdf.text.pdf.ICC_Profile.getInstance(new 
                         FileInputStream("D:\\iText\\srgb.profile"));
  PdfICCBased ib = new PdfICCBased(icc);

  ib.remove(PdfName.ALTERNATE);

  // step 3: we open the document
  document.open();
  //document.add(new Paragraph("ss", f));
  BaseFont font = BaseFont.createFont("c:\\windows\\fonts\\arial.ttf",
  BaseFont.WINANSI, true);
  PdfContentByte content = writer.getDirectContent(); 
  content.setFontAndSize(font, 12);

  // step 4: we add content
  PdfImportedPage page = null;
  float numero = 12;

  //writer.getExtraCatalog().put(PdfName.OUTPUTINTENTS, new PdfArray(outi));
  //page.setFontAndSize(font2,numero);

  for (int i = 0; i < n; ) 
  {
    ++i;
    page = writer.getImportedPage(reader, i);
    writer.addPage(page);
  }

  PRAcroForm form = reader.getAcroForm();

  if (form != null)
    writer.copyAcroForm(reader);

  if (master.size() > 0)
    writer.setOutlines(master);

  // step 5: we close the document
  document.close();

When I do this the filesize increments, but if I look into the properties of the
resultant document, the fonts don't seem to be embedded. If anyone can help me I
would thank him.


------------------------------------------------------------------------------
Download Intel&#174; Parallel Studio Eval
Try the new software tools for yourself. Speed compiling, find bugs
proactively, and fine-tune applications for parallel performance.
See why Intel Parallel Studio got high marks during beta.
http://p.sf.net/sfu/intel-sw-dev
_______________________________________________
iText-questions mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/itext-questions

Buy the iText book: http://www.1t3xt.com/docs/book.php
Check the site with examples before you ask questions: 
http://www.1t3xt.info/examples/
You can also search the keywords list: http://1t3xt.info/tutorials/keywords/

------------------------------------------------------------------------------
Download Intel&#174; Parallel Studio Eval
Try the new software tools for yourself. Speed compiling, find bugs
proactively, and fine-tune applications for parallel performance.
See why Intel Parallel Studio got high marks during beta.
http://p.sf.net/sfu/intel-sw-dev
_______________________________________________
iText-questions mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/itext-questions

Buy the iText book: http://www.1t3xt.com/docs/book.php
Check the site with examples before you ask questions: 
http://www.1t3xt.info/examples/
You can also search the keywords list: http://1t3xt.info/tutorials/keywords/

Reply via email to