Hi,
Have you had a chance to check this out? (http://www.nabble.com/file/p15203186/itext_font_merging_patch.zip) Regards, Lari Paulo Soares wrote: > > I'll have a look. > > Paulo > >> -----Original Message----- >> From: [EMAIL PROTECTED] >> [mailto:[EMAIL PROTECTED] On >> Behalf Of Lari Hotari >> Sent: Thursday, January 31, 2008 12:03 PM >> To: itext-questions@lists.sourceforge.net >> Subject: [iText-questions] contribution: >> FontReplacingPdfSmartCopy: duplicate TTF font subset merging >> and replacement (was: How to remove embedded fonts from a pdf >> document) >> >> >> This contribution is about TTF font merging and replacement, >> but it should >> help with the original font problem. It would also be >> possible to continue >> developing this code to remove embedded fonts and replace >> them with pdf >> document fonts. With this code you can remove other fonts and >> replace them >> with some TTF font. >> >> Here's (itext_font_merging_patch.zip) some additional classes to >> com.lowagie.text.pdf . >> http://www.nabble.com/file/p15203186/itext_font_merging_patch.zip >> itext_font_merging_patch.zip >> The main class is FontReplacingPdfSmartCopy (extends PdfSmartCopy). >> >> This subclass of PdfSmartCopy will replace different subsets >> of the same >> font in the resulting pdf file with one font (same font name >> or replacement >> can be also done). It needs the TrueType font files (TTF) to >> do the job. >> >> This usually reduces the final PDF file size by 40%-60% >> compared to plain >> PdfSmartCopy when several single page pdfs are merged in to >> one big pdf >> file. >> >> The original motivation was to make it possible to print very >> large pdf >> files which have been concatenated of thousands of small pdf files >> containing the same fonts. Some printers just clog when they receive >> thounsands of embedded fonts in a single print job. Maybe the >> reason is that >> the resulting Postscript files are quite huge when there's >> thousands of >> embedded fonts. Having less fonts makes it more simple to >> print-process the >> concatenated pdf. It also uses less disk space. >> >> Merging/replacement currently works only with WinAnsiEncoding >> (iso-8859-1 / >> Cp1252 / latin1) >> >> Page resources are scanned while copying and it checks for a >> dictionary >> under FONT key. Possible FONT references in the font >> dictionary are replaced >> on demand. The new font will get a new indirect reference and >> the font will >> be written to the stream in the overridden >> PdfWriter.addSharedObjectsToBody() method. >> >> This class has to be in the com.lowagie.itext.pdf package >> because it needs >> access to some package private methods. >> >> I would like to contribute this implementation to the >> community and I hope >> this gets in to the itext release as soon as possible. Bruno >> or Paulo, can >> you add this to the itext release? >> >> There's also a helper class for concatenating pdfs. >> >> PdfConcator makes it easier to concatenate multiple PDF files >> in to a single >> PDF file. It uses FontReplacingPdfSmartCopy to reduce the >> number of fonts in >> the resulting PDF file. It's also possible to replace TTF >> fonts with other >> fonts. Sample usage: >> >> >> PdfConcator pdfConcator=new PdfConcator(); >> pdfConcator.setFontDir(new File("fonts")); // or >> pdfConcator.useDefaultSystemFonts(); >> Map fontNameMapping = new HashMap(); >> fontNameMapping.put("ComicSansMS", "Arial-Black"); >> pdfConcator.setFontNameMapping(fontNameMapping); >> >> List files = new ArrayList(); >> files.add("pdf1.pdf"); >> files.add("pdf2.pdf"); >> pdfConcator.concat(files, new File("concat.pdf")); >> >> Supports IoC/DI. Example Spring configuration xml: >> >> <beans >> xsi:schemaLocation="http://www.springframework.org/schema/beans >> http://www.springframework.org/schema/beans/spring-beans-2.0.xsd"> >> <bean id="pdfConcator" class="com.lowagie.text.pdf.PdfConcator"> >> <property name="fonts"> >> <bean factory-bean="fontArrayFactory" >> factory-method="getInstance"/> >> </property> >> <property name="fontNameMapping"> >> <map> >> <entry key="ComicSansMS" value="ArialMT"/> >> </map> >> </property> >> </bean> >> <bean id="fontArrayFactory" >> class="com.lowagie.text.pdf.BaseFontArrayFactory"> >> <property name="fontDirs"> >> <list> >> <value>C:/myfonts</value> >> <value>fonts</value> >> <value>/usr/share/fonts/truetype/msttcorefonts</value> >> <value>C:/WINDOWS/FONTS</value> >> </list> >> </property> >> <property name="extensions" value="ttf,otf"/> >> <property name="ignoreUnreadable" value="true"/> >> </bean> >> </beans> >> >> >> Regards, >> >> Lari Hotari >> >> >> >> Bruno Lowagie (iText) wrote: >> > >> > new2pdf wrote: >> >> Is there a better way of doing this? >> > >> > That's not a question I can answer in only a few lines. >> > Due to lack of time, I have to pass on this question for now. >> > Maybe somebody else can explain how to remove fonts >> > (although that's always a very delicate matter). >> > br, >> > Bruno > > > Aviso Legal: > > Esta mensagem é destinada exclusivamente ao destinatário. Pode conter > informação confidencial ou legalmente protegida. A incorrecta transmissão > desta mensagem não significa a perca de confidencialidade. Se esta > mensagem for recebida por engano, por favor envie-a de volta para o > remetente e apague-a do seu sistema de imediato. É proibido a qualquer > pessoa que não o destinatário de usar, revelar ou distribuir qualquer > parte desta mensagem. > > > > Disclaimer: > > This message is destined exclusively to the intended receiver. It may > contain confidential or legally protected information. The incorrect > transmission of this message does not mean the loss of its > confidentiality. If this message is received by mistake, please send it > back to the sender and delete it from your system immediately. It is > forbidden to any person who is not the intended receiver to use, > distribute or copy any part of this message. > > > > > ------------------------------------------------------------------------- > This SF.net email is sponsored by: Microsoft > Defy all challenges. Microsoft(R) Visual Studio 2008. > http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/ > _______________________________________________ > 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/ > > -- View this message in context: http://www.nabble.com/How-to-remove-embedded-fonts-from-a-pdf-document-tp14033717p15299848.html Sent from the iText - General mailing list archive at Nabble.com. ------------------------------------------------------------------------- This SF.net email is sponsored by: Microsoft Defy all challenges. Microsoft(R) Visual Studio 2008. http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/ _______________________________________________ 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/