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 85EAA1883D for ; Mon, 26 Oct 2015 21:47:08 +0000 (UTC) Received: (qmail 70598 invoked by uid 500); 26 Oct 2015 21:47:08 -0000 Delivered-To: apmail-pdfbox-users-archive@pdfbox.apache.org Received: (qmail 70507 invoked by uid 500); 26 Oct 2015 21:47:07 -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 70496 invoked by uid 99); 26 Oct 2015 21:47:07 -0000 Received: from Unknown (HELO spamd2-us-west.apache.org) (209.188.14.142) by apache.org (qpsmtpd/0.29) with ESMTP; Mon, 26 Oct 2015 21:47:07 +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 112391A0AC3 for ; Mon, 26 Oct 2015 21:47:07 +0000 (UTC) X-Virus-Scanned: Debian amavisd-new at spamd2-us-west.apache.org X-Spam-Flag: NO X-Spam-Score: -0.001 X-Spam-Level: X-Spam-Status: No, score=-0.001 tagged_above=-999 required=6.31 tests=[RCVD_IN_MSPIKE_H2=-0.001, SPF_PASS=-0.001, URIBL_BLOCKED=0.001] autolearn=disabled Received: from mx1-us-east.apache.org ([10.40.0.8]) by localhost (spamd2-us-west.apache.org [10.40.0.9]) (amavisd-new, port 10024) with ESMTP id Y579poWpnybS for ; Mon, 26 Oct 2015 21:46:59 +0000 (UTC) Received: from mout.gmx.net (mout.gmx.net [212.227.15.15]) by mx1-us-east.apache.org (ASF Mail Server at mx1-us-east.apache.org) with ESMTPS id 2A83342B60 for ; Mon, 26 Oct 2015 21:46:59 +0000 (UTC) Received: from [192.168.178.22] ([213.196.255.7]) by mail.gmx.com (mrgmx001) with ESMTPSA (Nemesis) id 0MBExR-1ZhEhF0t1B-00AAzz for ; Mon, 26 Oct 2015 22:46:52 +0100 From: Timm Friedholz Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: quoted-printable Subject: Merging pages of two PDF documents Message-Id: <184B5EB5-BCE9-47AF-AFF3-5154002E06F1@gmx.de> Date: Mon, 26 Oct 2015 22:46:51 +0100 To: users@pdfbox.apache.org Mime-Version: 1.0 (Mac OS X Mail 9.0 \(3094\)) X-Mailer: Apple Mail (2.3094) X-Provags-ID: V03:K0:Y3c8ObgkxHf6xYZuJsnEmUPlxBGQBloXDf1JkrKP6meeMPgbNKF mBtu2+FICiYxp22jgOWrYOE7Q3yjFR47s7KpbvIYB5017uCd7zkM5PcVXColF/vYEQo5hrJ j9hjk+EeKv+SHMJH2GYd97lyaMVn3okDtuWa4u5qUvzVgUeGbEeMJmnvi5PiQfUb6K0xkj4 0rn8Ufn86dyNbeD64bP+A== X-UI-Out-Filterresults: notjunk:1;V01:K0:AajlgEoYvno=:nQiGcZHDQp/kP5X5MG71Qw pMsxpQnY7BQ+mV/5cloZ7m0etk6Y/6de9MQwrntKQjpb8VvivhXS4OnazGGkUGkpKX3Kf3d4y W/XnnKoBCJrl9XL/9HBhwhac2AK6LeCWw6G27qHHyIWkG3uOzfcSTflx4fFnnigsL0VaVGc0X MwqV+0uKNxmVBFCh7tdUaW+rBCYlPVX5AbZm+H4PMOzlLDZDl9Rz3osmnl0pEbRRsXpeFLCLu /5RjSWVvP7dazdVyh2DaCtcDF+6ivhOCOOycQ9v3ukRSUH3Ur5qtBlfB6Xf7ujuelTxjUbEP7 2I6TUV/rEDsbHQF6xhH8yIQO4gwd3HgP8gh12WFIvHpQN7cnMhyfUAsjG+QUyU/aGLUy+gUyc GJHsQul9W1V/hfl9iwIXa8byMMx5mxugQAv/71/+jZIycP4IzHekBUNKIO2O0c5R1ZwA4Yll8 D5QyUDKlKKzLNngN079law0F7PSf+6XSI6C2O2ZC1Go8ujbXNKg1TqScooI4BedU3iyNLhAD0 WuLtAZeRck9fxWxwiL+Mugcxx0N3sIj0nI83M91Jq786zrGMihuxaA6Rv7d4YDeJuayS4Mw9h SXfrqjCLd5rvJOUuyVFNk8MZf94qR9wc3BIx0J6s6kRW4sGEyQl/PvBEaTJB26x7YTVZJ0uO3 XGJfPoafYwvYKlZYKuIpGWESLgjYsbZMEjyE26vOsQE5JwwDPzem2eY84O+AsvJihuWywhdgL UvEv9IUMQJxSilYvvVluF2e90a7BEf17reUD6oYLIMNMV0wuXeKWZkLZWR9J7M3RXF9re/L2I HD6/Pr6 Hello, I have some PDF documents in which the glyph-Unicode character mapping = is destroyed so that it's not possible to search and copy the text. In = an attempt to remove this restriction I've converted the PDFs to TIFF = images and performed OCR on them using tesseract. Tesseract exports the = recognized text as PDF files in which the text is positioned = transparently on top of the images such that the text is searchable and = selectable. The problem is that the images in the PDF that tesseract outputs are = gray-scaled, large and high contrast versions of the original PDFs and I = would like to have the quality and file size of the original PDFs = instead. Thus my idea is to copy the text objects of the OCR output to = the original PDFs. To avoid interference with the old text, I've = converted the original PDFs to vector paths using Ghostscript: gs -o = out.pdf -dNoOutputFonts -sDEVICE=3Dpdfwrite in.pdf Now the problem is that I'm not sure how to approach this = programmatically. Can I simply iterate over the pages and copy the text = objects from each page of one document to the corresponding page of the = other document? Which operators do I need to copy if I parse it token = by token? Should I actually do it as directly via the PDFStreamParser = class or are there abstraction in PDFBox that will make this easier? The code for the PDF export by tesseract is here: = https://github.com/tesseract-ocr/tesseract/blob/dd8c12997385cf7f5961093bcd= 44f0396b08f96f/api/pdfrenderer.cpp#L1 Here is the line that specifies the text objects: = https://github.com/tesseract-ocr/tesseract/blob/dd8c12997385cf7f5961093bcd= 44f0396b08f96f/api/pdfrenderer.cpp#L317 Thanks. Timm= --------------------------------------------------------------------- To unsubscribe, e-mail: users-unsubscribe@pdfbox.apache.org For additional commands, e-mail: users-help@pdfbox.apache.org