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 032A81808E for ; Tue, 12 May 2015 16:35:13 +0000 (UTC) Received: (qmail 19582 invoked by uid 500); 12 May 2015 16:35:12 -0000 Delivered-To: apmail-pdfbox-users-archive@pdfbox.apache.org Received: (qmail 19557 invoked by uid 500); 12 May 2015 16:35:12 -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 19542 invoked by uid 99); 12 May 2015 16:35:12 -0000 Received: from Unknown (HELO spamd3-us-west.apache.org) (209.188.14.142) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 12 May 2015 16:35:12 +0000 Received: from localhost (localhost [127.0.0.1]) by spamd3-us-west.apache.org (ASF Mail Server at spamd3-us-west.apache.org) with ESMTP id 073CA18294F for ; Tue, 12 May 2015 16:35:12 +0000 (UTC) X-Virus-Scanned: Debian amavisd-new at spamd3-us-west.apache.org X-Spam-Flag: NO X-Spam-Score: 1.789 X-Spam-Level: * X-Spam-Status: No, score=1.789 tagged_above=-999 required=6.31 tests=[KAM_ASCII_DIVIDERS=0.8, KAM_LAZY_DOMAIN_SECURITY=1, RCVD_IN_MSPIKE_H2=-0.001, T_RP_MATCHES_RCVD=-0.01] autolearn=disabled Received: from mx1-us-west.apache.org ([10.40.0.8]) by localhost (spamd3-us-west.apache.org [10.40.0.10]) (amavisd-new, port 10024) with ESMTP id qFLEx-g0sxWM for ; Tue, 12 May 2015 16:35:11 +0000 (UTC) Received: from mailout06.t-online.de (mailout06.t-online.de [194.25.134.19]) by mx1-us-west.apache.org (ASF Mail Server at mx1-us-west.apache.org) with ESMTPS id 97A0E25F6F for ; Tue, 12 May 2015 16:35:10 +0000 (UTC) Received: from fwd00.aul.t-online.de (fwd00.aul.t-online.de [172.20.26.147]) by mailout06.t-online.de (Postfix) with SMTP id 2C0FA2619CD for ; Tue, 12 May 2015 18:35:08 +0200 (CEST) Received: from [192.168.2.102] (S8V3R8ZQghK-NvxzVJdSb7PhyoA1cicOpdacPkaqYml+Ww2u-JnqpwnkuPwgLOCQ08@[217.231.137.15]) by fwd00.t-online.de with (TLSv1.2:ECDHE-RSA-AES256-SHA encrypted) esmtp id 1YsD96-3vuNc00; Tue, 12 May 2015 18:35:04 +0200 Message-ID: <55522BC1.2000903@t-online.de> Date: Tue, 12 May 2015 18:35:13 +0200 From: Tilman Hausherr User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:31.0) Gecko/20100101 Thunderbird/31.6.0 MIME-Version: 1.0 To: users@pdfbox.apache.org Subject: Re: Embedding an image References: <559867498.955713996.1431445109520.JavaMail.root@zimbra65-e11.priv.proxad.net> In-Reply-To: <559867498.955713996.1431445109520.JavaMail.root@zimbra65-e11.priv.proxad.net> Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 8bit X-ID: S8V3R8ZQghK-NvxzVJdSb7PhyoA1cicOpdacPkaqYml+Ww2u-JnqpwnkuPwgLOCQ08 X-TOI-MSGID: 2a8e52c8-6c50-4c84-995d-adf7ac3c0596 Hi, See the ImageToPDF example in the source download, or here: https://svn.apache.org/viewvc/pdfbox/branches/1.8/examples/src/main/java/org/apache/pdfbox/examples/pdmodel/ImageToPDF.java?view=markup&sortby=date Tilman Am 12.05.2015 um 17:38 schrieb phiroc@free.fr: > AS a file that is shown on a page. > > ----- Mail original ----- > De: "Tilman Hausherr" > À: users@pdfbox.apache.org > Envoyé: Mardi 12 Mai 2015 17:34:40 > Objet: Re: Embedding an image > > With embedding, do you mean as a file attachment or as an image that is > shown in a page? > > Tilman > > Am 12.05.2015 um 15:32 schrieb phiroc@free.fr: >> Hello, >> >> I am trying to embed an image in a PDF. >> >> How do you load an image in PDFBox? >> >> PDDocument.load() does not work ("Error: Header doesn't contain versioninfo") because my JPG image is not a PDF. >> >> Any suggestions? >> >> Many thanks. >> >> Philippe >> >> >> >> void embedFile(PDPage aPage) throws URISyntaxException, IOException { >> >> final String rond = "/META-INF/templates/rond.jpg"; >> final java.net.URL rondUrl = getClass().getClass().getResource(rond); >> final File rondPath = new File(rondUrl.toURI()); >> >> final String randomPdfName = "random.pdf"; >> // Error in original code: randomPdfName missing >> final File randomAccessFilePath = new File(pathToRandomAccessDirectory, randomPdfName); >> RandomAccess randomAccessFile = new RandomAccessFile(randomAccessFilePath, "rw"); >> >> PDDocument importedRond = PDDocument.load(rondPath); >> >> PDEmbeddedFile embFile = new PDEmbeddedFile(importedRond); >> >> List annotationList = aPage.getAnnotations(); >> >> BoundingBox box = new BoundingBox(10, 790, 80, 740); >> PDRectangle rect = new PDRectangle(box); >> >> PDAnnotationFileAttachment attach = new PDAnnotationFileAttachment(); >> attach.setRectangle(rect); >> PDFileSpecification simpleSpec = new PDSimpleFileSpecification(); >> simpleSpec.setFile("image"); >> attach.setFile(simpleSpec); >> attach.setPage(aPage); >> >> } >> >> --------------------------------------------------------------------- >> 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