Return-Path: X-Original-To: apmail-pdfbox-users-archive@www.apache.org Delivered-To: apmail-pdfbox-users-archive@www.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id 2576C171DB for ; Mon, 27 Oct 2014 14:30:29 +0000 (UTC) Received: (qmail 84326 invoked by uid 500); 27 Oct 2014 14:30:28 -0000 Delivered-To: apmail-pdfbox-users-archive@pdfbox.apache.org Received: (qmail 84301 invoked by uid 500); 27 Oct 2014 14:30:28 -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 84288 invoked by uid 99); 27 Oct 2014 14:30:28 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Mon, 27 Oct 2014 14:30:28 +0000 X-ASF-Spam-Status: No, hits=1.5 required=5.0 tests=HTML_MESSAGE,RCVD_IN_DNSWL_LOW,SPF_PASS X-Spam-Check-By: apache.org Received-SPF: pass (athena.apache.org: domain of corinna.kinchin@gmail.com designates 209.85.212.179 as permitted sender) Received: from [209.85.212.179] (HELO mail-wi0-f179.google.com) (209.85.212.179) by apache.org (qpsmtpd/0.29) with ESMTP; Mon, 27 Oct 2014 14:30:22 +0000 Received: by mail-wi0-f179.google.com with SMTP id h11so4583593wiw.0 for ; Mon, 27 Oct 2014 07:29:16 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:date:message-id:subject:from:to:content-type; bh=mJYNnaUTMz+wF/sXyMkaEHq5svM4NPW3GJ8AZMHIGaA=; b=U5Sq0VOkqBQDiVIXgs4/waiQSo7OPwgDAibxfzTqKfaKTKPLH7sJj4jhUfHXyAcQxm nDcv2frJ1EJRa757/O6aN8gQhRNYqlYvMgq8UnNSChmRZXIv7VuQPrb1sLoSksblokov Jm0buquEVIfsbtgUwQFirhEm87+jhNOW/8IZDErHFIwMSNligxSh3INgpA8eHBtxj4hR mytpciKEvqy7vf1HCfQ14/NirQ5whittju5rEf1FmENgP2NNJJNVDcgvAbxqV/SXrvmF pvk+1V02VaqOWAsal6C0UzPVsjuF3d4GyblQOZXbZ4ygrYK/GgtmeYy4GBz6fcCIR4Pq Zn4Q== MIME-Version: 1.0 X-Received: by 10.194.209.230 with SMTP id mp6mr15899359wjc.2.1414420156167; Mon, 27 Oct 2014 07:29:16 -0700 (PDT) Received: by 10.216.241.135 with HTTP; Mon, 27 Oct 2014 07:29:16 -0700 (PDT) Date: Mon, 27 Oct 2014 14:29:16 +0000 Message-ID: Subject: Creating PDF files with OTF fonts From: Corinna Kinchin To: users@pdfbox.apache.org Content-Type: multipart/alternative; boundary=047d7b3a8c08f8bae60506685a9a X-Virus-Checked: Checked by ClamAV on apache.org --047d7b3a8c08f8bae60506685a9a Content-Type: text/plain; charset=UTF-8 Good afternoon all! I have a newbie question which I'm hoping for some help with: I've just (last week) downloaded the latest PDFbox source from github and am trying to create a HelloWorldOTF.java, based on the HelloWorldTTF.java example, with the hope of creating a PDF file which uses an OTF font (in this case, Adobe Caslon Pro Regular) to add text to the output PDF. Here's what I have so far: doc = new PDDocument(); PDPage page = new PDPage(); doc.addPage(page); String testOtfFontFile = "c:/windows/fonts/ACaslonPro-Regular.otf"; String testTtfFontFile = "c:/windows/fonts/arial.ttf"; String testPdfFile = "c:/tmp/pdfboxtest.pdf"; CFFFont font = loadCFFFont(testOtfFontFile); PDFont ttfFont = PDTrueTypeFont.loadTTF(doc, new File(testTtfFontFile)); PDPageContentStream contentStream = new PDPageContentStream(doc, page); contentStream.beginText(); // How to set the CFFFont? contentStream.setFont(ttfFont, 12); contentStream.moveTextPositionByAmount(100, 700); contentStream.drawString(text); contentStream.endText(); contentStream.close(); doc.save(testPdfFile); System.out.println(testPdfFile + " created!"); I can load a CFFFont using this code: (loadCFFFont()): CFFFont cff = null; input = new FileInputStream(file); byte[] bytes = IOUtils.toByteArray(input); CFFParser cffParser = new CFFParser(); cff = cffParser.parse(bytes).get(0); ... but can't for the life of me figure out how to get from a CFFFont to a PDFont in order to be able to use it to set the font via setFont(). Any help or pointers would be hugely appreciated ... Thank you! -- ... Corinna Palm Gate Greenane Killarney Co Kerry +353 64 66 28964 --047d7b3a8c08f8bae60506685a9a--