It might help if you read the Font section in the PDF standard (ISO 32000-1).

A couple of points that might help
1) Obviously, a subset font is smaller than the full embed.  
2) Even if multiple that smaller number by 100 (or may even 1000) it may/will 
be smaller than a full embed depending on the number of glyphs in the font.  
3) If the font is a simple font, then there will be 256 glyphs.  So you would 
need 256 copies of a subset (approx, since there is more involved in the actual 
#'s) before you reached the size of one full embed.  
4) A fully Unicode-aware font, with THOUSANDS of glyphs, is going to make even 
more of an impact when fully embedded.

And on to related issues
5) Merging subsets is REALLY HARD since it may/will require that the actual 
page content be rewritten.  To my knowledge, Adobe's PDFLibrary and products 
built on top of it (Acrobat, LiveCycle and various 3rd parties) is the only 
solution for that.  Thus there are commercial options for you.
6) However, if you have a single copy of a fully embedded for all text in the 
document, there are a variety of commercial solutions (no open source or free, 
sorry) that can THEN convert the full embed to a subset embed, at least for 
Latin-based text.
7) Doing #6 above using the current iText source code as a starting point IS 
possible - but would require someone with low level PDF and font knowledge and 
a bunch of time and sample documents.

Hope that helps.

Leonard

-----Original Message-----
From: Jason Berk [mailto:jb...@purdueefcu.com] 
Sent: Sunday, April 25, 2010 11:04 AM
To: Post all your questions about iText here
Subject: Re: [iText-questions] iText 5.0.1 embedded fonts and smartcopy


if that's the case, then why does the doc say the same font exists 100 times?  
Sorry if I'm beating a dead horse, just trying to understand.

Jason

-----Original Message-----
From: Paulo Soares [mailto:psoa...@glintt.com]
Sent: Sun 4/25/2010 4:02 AM
To: Post all your questions about iText here
Subject: Re: [iText-questions] iText 5.0.1 embedded fonts and smartcopy
 
No mistery. As you have a single glyph the subset will be the same and 
PdfSmartCopy will include a single instance of the file. The difference comes 
from the width table that has a single element in the case of the subset and 
256 entries for the full embed.

Paulo
  ----- Original Message ----- 
  From: Jason Berk 
  To: Post all your questions about iText here 
  Sent: Saturday, April 24, 2010 4:31 PM
  Subject: Re: [iText-questions] iText 5.0.1 embedded fonts and smartcopy



  anybody know why this happens?  Seems "wrong" to see the same font embedded 
multiple times yet end up with a smaller document.  Short of Document Props > 
Fonts scrolling forever, is there any harm in letting it embed the subset.  My 
main goal was to reduce file size after concat'ing several (~30,000) PDFs.

  Jason


  -----Original Message-----
  From: Jason Berk [mailto:jb...@purdueefcu.com]
  Sent: Fri 4/23/2010 5:14 PM
  To: Post all your questions about iText here
  Subject: [iText-questions] iText 5.0.1 embedded fonts and smartcopy

  I have three fonts which each contain 1 glyph.



  I created 100 identical pdfs that uses this font and then used smartcopy
  to merge all 100 pages.



  The resulting PDF is 184KB and when I look at the document properties,
  it shows the font 100 times (presumably because it was an embedded
  subset).



  I added "myFont.setSubset(false);" and reran the test.



  Now when I view the properties of the merged pdf, I only see my font
  once (as expected), yet the size of my merged PDF grew to 327KB! (not
  expected)



  As I understood it, SmartCopy didn't reuse fonts that were subsets.



  public class Fonts {



        public static final Font VISA;

        public static final Font SCORECARD;

        public static final Font MICR;



        static {

              BaseFont _visa = null;

              BaseFont _scorecard = null;

              BaseFont _micr = null;

              try {

                    _visa = BaseFont.createFont("/fonts/CREDITCARD.ttf",
  BaseFont.WINANSI, BaseFont.EMBEDDED);

                    _visa.setSubset(false); // INCREASES FILE SIZE?!?!

                    _scorecard =
  BaseFont.createFont("/fonts/SCORECARD.ttf", BaseFont.WINANSI,
  BaseFont.EMBEDDED);

                    _scorecard.setSubset(false); // INCREASES FILE
  SIZE?!?!

                    _micr = BaseFont.createFont("/fonts/OCRAEXT.ttf",
  BaseFont.WINANSI, BaseFont.EMBEDDED);

                    _micr.setSubset(false); // INCREASES FILE SIZE?!?!

              } catch (Exception e) {

                    e.printStackTrace();

                    System.exit(1);

              }

              VISA = new Font(_visa, 12);

              SCORECARD = new Font(_scorecard, 12);

              MICR = new Font(_micr, 12);

        }

  }



  private void generateStatements() {

              try {

                    log.info("begin generating statements");

                    Document d = new Document();

                    PdfSmartCopy copy = new PdfSmartCopy(d, new
  FileOutputStream("C:/temp/aMerged.pdf"));

                    d.open();

                    for (int i = 1; i <= 100; i++) {



                          Document document = new Document();

                          PdfWriter.getInstance(document, new
  FileOutputStream("C:/temp/test" + i + ".pdf"));

                          document.open();



                          document.add(new Paragraph("LARGE FONTS",
  Fonts.NORMAL));

                          document.add(new Paragraph("testing our font
  class", Fonts.LARGE_NORMAL));

                          document.add(new Paragraph("testing our font
  class", Fonts.LARGE_BOLD));

                          document.add(new Paragraph("testing our font
  class", Fonts.LARGE_UNDERLINE));

                          document.add(new Paragraph("testing our font
  class", Fonts.LARGE_ITALIC));



                          document.add(new Paragraph("\n\nNORMAL FONTS",
  Fonts.NORMAL));

                          document.add(new Paragraph("testing our font
  class", Fonts.NORMAL));

                          document.add(new Paragraph("testing our font
  class", Fonts.BOLD));

                          document.add(new Paragraph("testing our font
  class", Fonts.UNDERLINE));

                          document.add(new Paragraph("testing our font
  class", Fonts.ITALIC));



                          document.add(new Paragraph("\n\nSMALL FONTS",
  Fonts.NORMAL));

                          document.add(new Paragraph("testing our font
  class", Fonts.SMALL_NORMAL));

                          document.add(new Paragraph("testing our font
  class", Fonts.SMALL_BOLD));

                          document.add(new Paragraph("testing our font
  class", Fonts.SMALL_UNDERLINE));

                          document.add(new Paragraph("testing our font
  class", Fonts.SMALL_ITALIC));



                          document.add(new Paragraph("\n\nCOLORED FONTS",
  Fonts.NORMAL));

                          document.add(new Paragraph("testing our font
  class", Fonts.PEFCU_RED_NORMAL));



                          document.add(new Paragraph("\n\nWHITE FONTS",
  Fonts.NORMAL));

                          Chunk chunk = new Chunk("testing our font
  class", Fonts.WHITE_NORMAL);

                          chunk.setBackground(Colors.BLACK);

                          document.add(new Paragraph(chunk));



                          Chunk chunk2 = new Chunk("testing our font
  class", Fonts.WHITE_BOLD);

                          chunk2.setBackground(Colors.BLACK);

                          document.add(new Paragraph(chunk2));



                          document.add(new Paragraph("\n\nSPECIAL FONTS",
  Fonts.NORMAL));

                          document.add(new Paragraph("A", Fonts.VISA));

                          document.add(new Paragraph("A",
  Fonts.SCORECARD));

                          document.add(new Paragraph("1 2 3 4 5 6 7 8 9
  0", Fonts.MICR));



                          document.close();



                          log.info("merging C:/temp/test" + i + ".pdf");

                          PdfReader reader = new PdfReader("C:/temp/test"
  + i + ".pdf");

                          ByteArrayOutputStream baos = new
  ByteArrayOutputStream();

                          PdfStamper stamper = new PdfStamper(reader,
  baos);

                          stamper.close();

                          reader = new PdfReader(baos.toByteArray());

                          copy.addPage(copy.getImportedPage(reader, 1));



                    }

                    d.close();

                    log.info("finished generating statements");

              } catch (Exception e) {

                    log.fatal(e.getMessage(), e);

              }

        }



------------------------------------------------------------------------------
_______________________________________________
iText-questions mailing list
iText-questions@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/itext-questions

Buy the iText book: http://www.itextpdf.com/book/
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