pdfbox-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Gilad Denneboom <gilad.denneb...@gmail.com>
Subject Re: Resize existing image
Date Wed, 11 Jan 2017 18:56:52 GMT
Thanks, I'll check it out...

On Wed, Jan 11, 2017 at 7:12 PM, Tilman Hausherr <THausherr@t-online.de>
wrote:

> Am 11.01.2017 um 12:47 schrieb Gilad Denneboom:
>
>> I'm facing a different issue now that maybe you can help me out with...
>> After writing the decoded document to a text file I can edit it manually
>> and it works fine. However, if I want to edit it in my code I obviously
>> need to read it in as a binary file, right? But then I only get an array
>> of
>> bytes. How I can split that into lines so I can perform String
>> manipulations on the image definition line, and then compose it back into
>> a
>> valid PDF file?
>>
>
> So you want to do this programmatically. The trick then is to read the
> tokens from the content stream. See the RemoveAllText.java example for how
> to do this. Instead of looking for TJ, look for cm and Do.
>
> All this will only work if all your files are somewhat similar.
>
> Tilman
>
>
>
>> On Wed, Jan 11, 2017 at 10:18 AM, Gilad Denneboom <
>> gilad.denneboom@gmail.com
>>
>>> wrote:
>>> Thanks, I'll give it a try!
>>>
>>> On Wed, Jan 11, 2017 at 12:03 AM, Tilman Hausherr <THausherr@t-online.de
>>> >
>>> wrote:
>>>
>>> Am 10.01.2017 um 23:37 schrieb Gilad Denneboom:
>>>>
>>>> Hi all,
>>>>>
>>>>> I'm trying to manipulate an existing image in my PDF file (double it
in
>>>>> size, for example), but I'm coming up short-handed... Any tips on how
>>>>> to
>>>>> approach this using PDFBox? Is it at all possible?
>>>>>
>>>>> Thanks in advance!
>>>>>
>>>>>
>>>>> The easiest way would be to edit the PDF. Run WriteDecodedDoc to get
an
>>>> uncompressed PDF, find where the image is invoked, then change the "cm"
>>>> parameters just before the image is invoked. Usually the cm command is
>>>> like
>>>> this:
>>>>
>>>> width 0 0 height xpos ypos cm
>>>>
>>>> (You can also view it with PDFDebugger, but you can't change it)
>>>>
>>>>
>>>> if you edit the PDF make sure that the offsets stay identical. (position
>>>> of "endstream")
>>>>
>>>>
>>>> When done, open the PDF with Adobe Reader and save it. It will be
>>>> compressed again.
>>>>
>>>>
>>>> Tilman
>>>>
>>>>
>>>> ---------------------------------------------------------------------
>>>> 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
>
>

Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message