You have to find every instance of Font Dictionary in the PDF object "tree" 
that refers to Arial and convert that single Font Dictionary into a Font 
Dictionary + Font Descriptor + Embedded Font stream.   In addition, you MAY 
need to recode the content streams themselves depending on whether you do a 
full embed (easier, but will make the PDF VERY large) or a subset embed 
(harder, but smaller).

If none of the above make sense to you - it's because you haven't read the PDF 
reference to understand the complexities of what you are asking for...

I am done explaining this to you.  Start reading and then ask some 
specific/pointed questions.

Leonard

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


Hello Leornard,

I don't have to find all the ocurrences of non-embedded fonts because I know
that the only font used in the PDF is Arial and that's why I do this:

>   BaseFont font = BaseFont.createFont("c:\\windows\\fonts\\arial.ttf",
>   BaseFont.WINANSI, true);
>   PdfContentByte content = writer.getDirectContent(); 
>   content.setFontAndSize(font, 12);

I don't know if I'm wrong, but if you know a better way to do this, please
let
me see. Thanks.

And Rahul Khadikar, thanks a lot but this method is for creating a new PDF,
not
copying an existing, and that's what I should do.

Leonard Rosenthol <lrosenth <at> adobe.com> writes:

> 
> 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:fbga81 <at> hotmail.com] 
> Sent: Wednesday, March 10, 2010 5:41 AM
> To: itext-questions <at> lists.sourceforge.net
> 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Ā® 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
> iText-questions <at> lists.sourceforge.net
> 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Ā® 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
> iText-questions <at> lists.sourceforge.net
> 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/
> 
> 



-- 
View this message in context: 
http://old.nabble.com/Embedding-fonts-when-copying-PDF-tp27848053p27850079.html
Sent from the iText - General mailing list archive at Nabble.com.


------------------------------------------------------------------------------
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