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 7261417B11 for ; Tue, 1 Sep 2015 16:31:16 +0000 (UTC) Received: (qmail 4028 invoked by uid 500); 1 Sep 2015 16:31:16 -0000 Delivered-To: apmail-pdfbox-users-archive@pdfbox.apache.org Received: (qmail 4002 invoked by uid 500); 1 Sep 2015 16:31:16 -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 3991 invoked by uid 99); 1 Sep 2015 16:31:15 -0000 Received: from Unknown (HELO spamd3-us-west.apache.org) (209.188.14.142) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 01 Sep 2015 16:31:15 +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 7752B18234F for ; Tue, 1 Sep 2015 16:31:15 +0000 (UTC) X-Virus-Scanned: Debian amavisd-new at spamd3-us-west.apache.org X-Spam-Flag: NO X-Spam-Score: 0.974 X-Spam-Level: X-Spam-Status: No, score=0.974 tagged_above=-999 required=6.31 tests=[KAM_LAZY_DOMAIN_SECURITY=1, RCVD_IN_MSPIKE_H3=-0.01, RCVD_IN_MSPIKE_WL=-0.01, RP_MATCHES_RCVD=-0.006] autolearn=disabled Received: from mx1-eu-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 gFSQgIIKvVTa for ; Tue, 1 Sep 2015 16:31:14 +0000 (UTC) Received: from mailout08.t-online.de (mailout08.t-online.de [194.25.134.20]) by mx1-eu-west.apache.org (ASF Mail Server at mx1-eu-west.apache.org) with ESMTPS id E12E02576D for ; Tue, 1 Sep 2015 16:31:13 +0000 (UTC) Received: from fwd27.aul.t-online.de (fwd27.aul.t-online.de [172.20.26.132]) by mailout08.t-online.de (Postfix) with SMTP id C4BBC4690E3 for ; Tue, 1 Sep 2015 18:31:06 +0200 (CEST) Received: from [192.168.2.102] (Z60LDaZfoh2eauanJZ3g2NhEZk9AEer6LdjcWnsEeepjblMDO9EABWeDPW8Qf9TZLz@[217.231.150.244]) by fwd27.t-online.de with (TLSv1.2:ECDHE-RSA-AES256-SHA encrypted) esmtp id 1ZWoSc-2ATSs40; Tue, 1 Sep 2015 18:31:02 +0200 Subject: Re: Replacing images in PDFs. To: users@pdfbox.apache.org References: From: Tilman Hausherr Message-ID: <55E5D2C5.7050405@t-online.de> Date: Tue, 1 Sep 2015 18:31:01 +0200 User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:38.0) Gecko/20100101 Thunderbird/38.2.0 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 8bit X-ID: Z60LDaZfoh2eauanJZ3g2NhEZk9AEer6LdjcWnsEeepjblMDO9EABWeDPW8Qf9TZLz X-TOI-MSGID: f371fe69-0ce1-49ec-97d8-dc48869a8f68 Am 01.09.2015 um 11:26 schrieb Lachezar Dobrev: > Hello all. > I'm tasked with providing a service to generate PDFs from template PDFs > by replacing text place holders and image place holders with data from a > database. > ​ For replacing text we decided to use Form Field​s to keep minimal effect > on the page layout, and to avoid problems with texts being split into parts > by the editor. > Replacing images is also achievable using > COSStream.replaceWithStream(COSStream). > > Q1: The replaceWithStream method is being deprecated. What can I use to > do the same thing in PDFBox 2? I tried stream-copying, but I get a > "WARNING: DCTFilter#encode is not implemented yet, skipping this stream." > and the image disappears from the output file. If you want to copy a JPEG, you should use createRawInputStream(). The JPEG should be of the same size and same colorspace than the original image. Alternatively - just put nothing in the templare, and simply put an image of whatever size you want with traditional methods (see image handling in PDPageContentStream) > > Q2: Is there any way to identify which image is what? Form fields have > Mapping Name that I can use to detect which field needs to contain what, > but I can not find a way to get some user-controllable identifier for an > image. Any thoughts? Images do have a name in the resources. So it should work if you do the template yourself. Tilman > --------------------------------------------------------------------- To unsubscribe, e-mail: users-unsubscribe@pdfbox.apache.org For additional commands, e-mail: users-help@pdfbox.apache.org