Return-Path: X-Original-To: archive-asf-public-internal@cust-asf2.ponee.io Delivered-To: archive-asf-public-internal@cust-asf2.ponee.io Received: from cust-asf.ponee.io (cust-asf.ponee.io [163.172.22.183]) by cust-asf2.ponee.io (Postfix) with ESMTP id A5212200B39 for ; Sat, 9 Jul 2016 17:48:49 +0200 (CEST) Received: by cust-asf.ponee.io (Postfix) id A3A0E160A67; Sat, 9 Jul 2016 15:48:49 +0000 (UTC) Delivered-To: archive-asf-public@cust-asf.ponee.io Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by cust-asf.ponee.io (Postfix) with SMTP id C6CB4160A59 for ; Sat, 9 Jul 2016 17:48:48 +0200 (CEST) Received: (qmail 34718 invoked by uid 500); 9 Jul 2016 15:48:47 -0000 Mailing-List: contact users-help@pdfbox.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: users@pdfbox.apache.org Delivered-To: mailing list users@pdfbox.apache.org Received: (qmail 34706 invoked by uid 99); 9 Jul 2016 15:48:47 -0000 Received: from pnap-us-west-generic-nat.apache.org (HELO spamd1-us-west.apache.org) (209.188.14.142) by apache.org (qpsmtpd/0.29) with ESMTP; Sat, 09 Jul 2016 15:48:47 +0000 Received: from localhost (localhost [127.0.0.1]) by spamd1-us-west.apache.org (ASF Mail Server at spamd1-us-west.apache.org) with ESMTP id 2092AC1324 for ; Sat, 9 Jul 2016 15:48:47 +0000 (UTC) X-Virus-Scanned: Debian amavisd-new at spamd1-us-west.apache.org X-Spam-Flag: NO X-Spam-Score: 1.493 X-Spam-Level: * X-Spam-Status: No, score=1.493 tagged_above=-999 required=6.31 tests=[AC_HTML_NONSENSE_TAGS=1, KAM_ASCII_DIVIDERS=0.8, KAM_LAZY_DOMAIN_SECURITY=1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H3=-0.01, RCVD_IN_MSPIKE_WL=-0.01, RP_MATCHES_RCVD=-1.287] autolearn=disabled Received: from mx2-lw-eu.apache.org ([10.40.0.8]) by localhost (spamd1-us-west.apache.org [10.40.0.7]) (amavisd-new, port 10024) with ESMTP id GkR7m5hXW35l for ; Sat, 9 Jul 2016 15:48:43 +0000 (UTC) Received: from mailout12.t-online.de (mailout12.t-online.de [194.25.134.22]) by mx2-lw-eu.apache.org (ASF Mail Server at mx2-lw-eu.apache.org) with ESMTPS id C7A6D5FAF0 for ; Sat, 9 Jul 2016 15:48:42 +0000 (UTC) Received: from fwd25.aul.t-online.de (fwd25.aul.t-online.de [172.20.26.130]) by mailout12.t-online.de (Postfix) with SMTP id 1785041FC992 for ; Sat, 9 Jul 2016 17:48:36 +0200 (CEST) Received: from [192.168.2.104] (EIG7IkZbghl4AHfeMmM7OQlnNICfO6dg1orn62-Sk102pIxzX6tU6GJ6fPTqGA5QwF@[217.231.135.157]) by fwd25.t-online.de with (TLSv1.2:ECDHE-RSA-AES256-SHA encrypted) esmtp id 1bLuUc-3iaKh60; Sat, 9 Jul 2016 17:48:34 +0200 Subject: Re: unable to calculate text width To: users@pdfbox.apache.org References: <35D05BA0C1DAFF459AAA18507A41A593367F53A7@vmail01.inside.de> <73B52620-1E63-4F2E-8ABA-688BAB147E5C@jahewson.com> <35D05BA0C1DAFF459AAA18507A41A593367F884D@vmail01.inside.de> <54358F0D-0CA8-4EA1-9154-35FD7E0458D5@jahewson.com> <35D05BA0C1DAFF459AAA18507A41A593367FC1C5@vmail01.inside.de> From: Tilman Hausherr Message-ID: Date: Sat, 9 Jul 2016 17:48:46 +0200 User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:45.0) Gecko/20100101 Thunderbird/45.2.0 MIME-Version: 1.0 In-Reply-To: <35D05BA0C1DAFF459AAA18507A41A593367FC1C5@vmail01.inside.de> Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 8bit X-ID: EIG7IkZbghl4AHfeMmM7OQlnNICfO6dg1orn62-Sk102pIxzX6tU6GJ6fPTqGA5QwF X-TOI-MSGID: 3dc3ca0b-1d41-4618-99fd-3ba594b48fda archived-at: Sat, 09 Jul 2016 15:48:49 -0000 What version and code did you use? I used this: import java.io.IOException; import java.net.URL; import org.apache.pdfbox.cos.COSName; import org.apache.pdfbox.pdmodel.PDDocument; import org.apache.pdfbox.pdmodel.PDPage; import org.apache.pdfbox.pdmodel.font.PDFont; public class Buir { public static void main(String[] args) throws IOException { PDDocument doc = PDDocument.load(new URL("http://www.buir.de/ABCD.pdf").openStream()); PDPage page = doc.getPage(0); PDFont font = page.getResources().getFont(COSName.getPDFName("F1")); float w = font.getStringWidth("%"); System.out.println("w: " + w); doc.close(); } } output: w: 833.0 Tilman Am 06.06.2016 um 08:17 schrieb Croe.David: > Hi, > > this is a pretty simple example created with powerpoint: > it displays the '%' Sign but pdfbox isn't able to calculate the width: > > http://www.buir.de/ABCD.pdf > > best regards, > David > > > -----Ursprüngliche Nachricht----- > Von: John Hewson [mailto:john@jahewson.com] > Gesendet: Dienstag, 31. Mai 2016 17:21 > An: users@pdfbox.apache.org > Betreff: Re: unable to calculate text width > > >> On 30 May 2016, at 23:57, Croe.David wrote: >> >> Thanks for reply, >> >> the pdf looks correct in pdf debugger and reader, thus if it can display the "%" sign why pdfbox can't calculate the width ? >> It lacks a part in the puzzle. >> How to determine if it’s a subset ? >> >> The toUnicode seems to have the character "%" .. 0025 ... >> <0001> <0024> [<0025> <004E> <0041> <004D> <0045> <003A> <0043> <0054> > Hmm, post the PDF online somewhere and I’ll take a look. > >> thanks, >> David >> >> >> >> -----Ursprüngliche Nachricht----- >> Von: John Hewson [mailto:john@jahewson.com] >> Gesendet: Montag, 30. Mai 2016 18:52 >> An: users@pdfbox.apache.org >> Betreff: Re: unable to calculate text width >> >> >>> On 25 May 2016, at 01:14, Croe.David wrote: >>> >>> Dear all, >>> >>> i'm trying to replace and center a text in a pdf which has been created by phantomjs. >>> >>> I'm not sure if it's a problem within phantomjs or pdfbox, but I get following exception while calculating the text width of a string starting with Symbol %: >>> >>> Exception in thread "main" java.lang.IllegalArgumentException: No glyph for U+0025 in font TimesNewRomanStandard >>> at org.apache.pdfbox.pdmodel.font.PDCIDFontType2.encode(PDCIDFontType2.java:411) >>> at org.apache.pdfbox.pdmodel.font.PDType0Font.encode(PDType0Font.java:351) >>> at org.apache.pdfbox.pdmodel.font.PDFont.encode(PDFont.java:286) >>> at >>> org.apache.pdfbox.pdmodel.font.PDFont.getStringWidth(PDFont.java:315) >>> >>> >>> in PDCIDFontType2: >>> isEmbedded is true >>> parent.getCMap().getName() is Identity-H cmap is null cid is -1 >>> >>> >>> >>> a closer look with pdfdebugger , this is the toUnicode: >>> >>> /CIDInit /ProcSet findresource begin >>> 12 dict begin >>> begincmap >>> /CIDSystemInfo << /Registry (Adobe) /Ordering (UCS) /Supplement 0 >> >>> def /CMapName /Adobe-Identity-UCS def /CMapType 2 def >>> 1 begincodespacerange >>> <0000> >>> endcodespacerange >>> 2 beginbfrange >>> <0000> <0000> <0000> >>> <0001> <0024> [<0025> <004E> <0041> <004D> <0045> <003A> <0043> >>> <0054> <0052> <0062> <0065> <0073> <0074> <0061> <006E> <0064> <0020> >>> <006D> <0069> <0066> <006F> <006C> <0067> <0072> <0050> <0075> <006B> >>> <007A> <0068> <0055> <004B> <0044> <00FC> <0042> <0079> <0070> ] >>> endbfrange endcmap CMapName currentdict /CMap defineresource pop end >>> end >>> >>> how to calculate the width or fix the problem ? >> As Tilman has suggested, this font is likely a subset and does not contain that symbol. You may be able to configure phantoms to not subset fonts, I believe that it uses CUPS-PDF for this. >> >> — John >> >>> best regards, >>> David Croé >>> ____________________________________________________________ >>> >>> [https://www.inside-online.de/mail/footer/anbieter_des_jahres.jpg]>> t >>> p://www.inside-online.de/de/pressemeldungen-news/anbieter-des-jahres- >>> 2 >>> 016.html?utm_source=Signatur&utm_medium=E-Mail&utm_campaign=Signatur- >>> A >>> nbieter-des-Jahres> Danke an unsere Kunden für die Wahl zum Anbieter >>> des Jahres 2016! >>> Kontaktieren Sie uns >>> hier und erfahren Sie, warum uns unsere Kunden zum Anbieter des Jahres gewählt haben. >>> Gerne sprechen wir auch über Ihr E-Learning-Projekt! >>> ____________________________________________________________ >> >> --------------------------------------------------------------------- >> To unsubscribe, e-mail: users-unsubscribe@pdfbox.apache.org >> For additional commands, e-mail: users-help@pdfbox.apache.org >> >> >> >> >> >> >> --------------------------------------------------------------------- >> To unsubscribe, e-mail: users-unsubscribe@pdfbox.apache.org >> For additional commands, e-mail: users-help@pdfbox.apache.org >> > > --------------------------------------------------------------------- > To unsubscribe, e-mail: users-unsubscribe@pdfbox.apache.org > For additional commands, e-mail: users-help@pdfbox.apache.org > > > > > > > --------------------------------------------------------------------- > To unsubscribe, e-mail: users-unsubscribe@pdfbox.apache.org > For additional commands, e-mail: users-help@pdfbox.apache.org > --------------------------------------------------------------------- To unsubscribe, e-mail: users-unsubscribe@pdfbox.apache.org For additional commands, e-mail: users-help@pdfbox.apache.org