From users-return-11011-archive-asf-public=cust-asf.ponee.io@pdfbox.apache.org Mon Apr 30 17:01:41 2018 Return-Path: X-Original-To: archive-asf-public@cust-asf.ponee.io Delivered-To: archive-asf-public@cust-asf.ponee.io Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by mx-eu-01.ponee.io (Postfix) with SMTP id 09212180647 for ; Mon, 30 Apr 2018 17:01:40 +0200 (CEST) Received: (qmail 81483 invoked by uid 500); 30 Apr 2018 15:01:39 -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 81466 invoked by uid 99); 30 Apr 2018 15:01:39 -0000 Received: from pnap-us-west-generic-nat.apache.org (HELO spamd2-us-west.apache.org) (209.188.14.142) by apache.org (qpsmtpd/0.29) with ESMTP; Mon, 30 Apr 2018 15:01:39 +0000 Received: from localhost (localhost [127.0.0.1]) by spamd2-us-west.apache.org (ASF Mail Server at spamd2-us-west.apache.org) with ESMTP id A37D11A2FA9 for ; Mon, 30 Apr 2018 15:01:38 +0000 (UTC) X-Virus-Scanned: Debian amavisd-new at spamd2-us-west.apache.org X-Spam-Flag: NO X-Spam-Score: 1.879 X-Spam-Level: * X-Spam-Status: No, score=1.879 tagged_above=-999 required=6.31 tests=[DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, HTML_MESSAGE=2, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H3=-0.01, RCVD_IN_MSPIKE_WL=-0.01, SPF_PASS=-0.001] autolearn=disabled Authentication-Results: spamd2-us-west.apache.org (amavisd-new); dkim=pass (2048-bit key) header.d=gmail.com Received: from mx1-lw-us.apache.org ([10.40.0.8]) by localhost (spamd2-us-west.apache.org [10.40.0.9]) (amavisd-new, port 10024) with ESMTP id 5QoYkFtLT6pP for ; Mon, 30 Apr 2018 15:01:37 +0000 (UTC) Received: from mail-oi0-f41.google.com (mail-oi0-f41.google.com [209.85.218.41]) by mx1-lw-us.apache.org (ASF Mail Server at mx1-lw-us.apache.org) with ESMTPS id 059D75F30C for ; Mon, 30 Apr 2018 15:01:37 +0000 (UTC) Received: by mail-oi0-f41.google.com with SMTP id e80-v6so7631897oig.11 for ; Mon, 30 Apr 2018 08:01:36 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:in-reply-to:references:from:date:message-id:subject:to; bh=WUjVkt8kwdavqXVE/OhkHucXJ8Rm9iwxj2AmqG0wIaU=; b=sg/MaNDkcdZkye8nwdwGIvhCtyiRle6oLihpjcngNIwxEFR6qqLiP7B/AIQm2XXxy3 UNrnqIzV+l4826BOzSXTwSpD3Y5u5eNpISu+RP0dQNtRRKzoDE5g4Z65heaYWw42I7m3 EYzdY3tYopd6znUIUaC+v9UOdf9AtXvbrBH6pV9ZKeFj9+mTZOJzYTovnScXTU9Efkw1 UJn/EFCif/XgjI44znkirQQvZ4KIRCpCIfR1SgBFSart1lQIO6qXb9f2JaVwmmbItVx6 TDvbNDdKJ3stMduzQ+YomsgRKd8KVkE8ej7uzlgiCXVPGVYHyQ7doVBsZhfBptXBSt0U SrhA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:in-reply-to:references:from:date :message-id:subject:to; bh=WUjVkt8kwdavqXVE/OhkHucXJ8Rm9iwxj2AmqG0wIaU=; b=B/6CnIcrEB3QzckOAvPShtmseF0uEFCW1J2oLsnEtL7IREqLRshgPy1z5lK+25d/LK /zLWh46iIAcYkWcWy3MQimS23uAYciY5/GKH5YFgnOIWzOnua91VAxHRY+h01HgxcnBR q6LX5XcKuiN+/JUU48UZ6atuPHcTCksJn3kcfA/XylhfQuJilOU9+c0ItCuGji+Bc8O6 ZOWgf+TuQueLIsG8ngQLkPW7PKabTz9td589RjqZgKHvYYmOZLUuL1hN6KX/XNF7q1xw dQsDqGsIgXl596gJAr8/+P8SQhyVP5pukmyi7KgkY0lLqZ0XCxk1N/4eRhOBupgT88gJ BdyQ== X-Gm-Message-State: ALQs6tCTijlvzFbwICXaLf5s97OM1xJR8TnOq9NpZNdxzyWCiUEL3aLy 9x+dEQOB6WZpQ3LD5DCO7AwQE3Hj/y0nXS++Gzj7bg== X-Google-Smtp-Source: AB8JxZoJ4bxlFiqY/IA7lPitdT+v+F8xINqqoFhOeVv2pKF9Q0DPHoFUTEtPZOzkmp032958eyADGkORv/TMWtw20As= X-Received: by 2002:a54:4e14:: with SMTP id a20-v6mr7968870oiy.25.1525100496096; Mon, 30 Apr 2018 08:01:36 -0700 (PDT) MIME-Version: 1.0 Received: by 10.74.193.135 with HTTP; Mon, 30 Apr 2018 08:01:35 -0700 (PDT) In-Reply-To: References: From: JZ Q Date: Mon, 30 Apr 2018 11:01:35 -0400 Message-ID: Subject: Re: RubberstampWithImage To: users@pdfbox.apache.org Content-Type: multipart/alternative; boundary="0000000000005110cb056b12212e" --0000000000005110cb056b12212e Content-Type: text/plain; charset="UTF-8" Dear Tilman, Using a sizing parameter solved the problem. Thank you. I found out the rubberstamp does not get printed, even if it is visible in PDF reader? Why? On the print dialog, I have selected to print stamp. Thanks. Jason On Mon, Apr 30, 2018 at 6:54 AM, Tilman Hausherr wrote: > In the drawXObject call, divide / multiply the size parameters by a float > value, e.g. 0.5. > > TilmaN > > > Am 30.04.2018 um 03:35 schrieb JZ Q: > >> Hi everyone, >> >> I used a lightly modified example code (RubberstampWithImage) to add >> rubber stamp to a text field. it works fine except the resolution of image >> seems to be too low. >> >> See below, if I use the image of same pixel width as the box size, the >> image becomes very blur. But I increase the image, it only shows part of >> it. >> >> So how do I add a clear stamp (image) that fits into the RECT of the text >> widget? Thanks. >> >> >> Field FQN: broker_sig >> Image File: broker_signature.png >> Image Size: (170, 34) >> Box Size (424.46, 16.25) >> in inch (5.8952775, 0.22569445) >> Box Position (135.035, 182.717) >> >> >> public static void addStamp(PDDocument document, PDField selectedField, >> String imageFilename) throws IOException { >> >> PDPage page = selectedField.getWidgets().get(0).getPage(); >> >> PDRectangle rect = selectedField.getWidgets().get(0).getRectangle(); >> List annotations = page.getAnnotations(); >> PDAnnotationRubberStamp rubberStamp = new PDAnnotationRubberStamp(); >> >> // create a PDXObjectImage with the given image file >> PDImageXObject ximage = PDImageXObject.createFromFile(imageFilename, >> document); >> >> // define and set the target rectangle >> int imgWidth = ximage.getImage().getWidth(); >> int imgHeight = ximage.getImage().getHeight(); >> System.out.println("Field FQN: " + selectedField.getFullyQualifie >> dName()); >> System.out.println("Image File: " + imageFilename); >> System.out.println("Image Size: (" + imgWidth + ", " + imgHeight + ")"); >> System.out.println("Box Size (" + rect.getWidth() + ", " + >> rect.getHeight() >> + ")"); >> System.out.println("in inch (" + rect.getWidth()/72 + ", " + >> rect.getHeight()/72 + ")"); >> System.out.println("Box Position (" + rect.getLowerLeftX() + ", " + >> rect.getLowerLeftY() + ")"); >> // Create a PDFormXObject >> PDFormXObject form = new PDFormXObject(document); >> form.setResources(new PDResources()); >> form.setBBox(rect); >> form.setFormType(1); >> >> // adjust the image to the target rectangle and add it to the stream >> OutputStream os = form.getStream().createOutputStream(); >> //center the object horizontally >> float imageLeftX = rect.getLowerLeftX() + (rect.getWidth() - imgWidth)/2; >> drawXObject(ximage, form.getResources(), os, imageLeftX, >> rect.getLowerLeftY(), imgWidth, imgHeight); >> os.close(); >> >> PDAppearanceStream myDic = new PDAppearanceStream(form.getCOSObject()); >> PDAppearanceDictionary appearance = new PDAppearanceDictionary(new >> COSDictionary()); >> appearance.setNormalAppearance(myDic); >> rubberStamp.setAppearance(appearance); >> rubberStamp.setRectangle(rect); >> >> // add the new RubberStamp to the document >> annotations.add(rubberStamp); >> } >> >> > > --------------------------------------------------------------------- > To unsubscribe, e-mail: users-unsubscribe@pdfbox.apache.org > For additional commands, e-mail: users-help@pdfbox.apache.org > > -- Best Wishes, Jason --0000000000005110cb056b12212e--