pdfbox-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Thiruppathi M. <thiruppa...@sps.co.in>
Subject RE: Replace text and adjust text positon
Date Fri, 03 Jun 2016 10:19:59 GMT
Hi,

I tried one way to solve this. But i can't set the exact the value for match with pdf text
line start and end position.

For example input.pdf content 
 
COSName{F8}, COSInt{1}, PDFOperator{Tf}, COSFloat{18.4316}, COSFloat{-1.3357}, PDFOperator{TD},
COSString{}, PDFOperator{Tj}, COSName{F3}, COSInt{1}, PDFOperator{Tf}, COSFloat{1.1159},
COSInt{0}, PDFOperator{TD}, COSArray{[COSString{2015}, COSFloat{-326.5}, COSString{Elsevier},
COSFloat{-332.7}, COSString{Ltd.}, COSFloat{-324.8}, COSString{All}, COSFloat{-325.4}, COSString{rights},
COSFloat{-326.5}, COSString{reserved.}]}

Here the text position is changed while i reduce the COSFloat{18.4316} value to COSFloat{-11.2842}.
	
The replacement is done through the pdfbox coding.(Refer after_replace.pdf).

How to find increase or decrease the value?

Please advice.

Regards
Thiruppathi M.

-----Original Message-----
From: Tilman Hausherr [mailto:THausherr@t-online.de] 
Sent: 02 June 2016 PM 11:41
To: users@pdfbox.apache.org
Subject: Re: Replace text and adjust text positon

Am 02.06.2016 um 12:15 schrieb Thiruppathi M.:
> Hi,
>
> Sorry for the delay. Please download the file using the below link,
>
> Input file:
>
> https://www.dropbox.com/s/vsvpiiyvgwgzexn/input.pdf?dl=0
>
> output file:
>
> https://www.dropbox.com/s/hikjsy7ayjg3ful/after_replace.pdf?dl=0
>
>
> here i need to replace and adjust the text (refer input and output file)
>
> "2015 Elsevier Ltd. All rights reserved." To "2016 The Author. Production and hosting
by Elsevier B.V. on behalf of King Saud University. This is an
> open access article under the CC BY-NC-ND license (http://creativecommons.org/licenses/by-nc-nd/4.0/)."
>
>
> Case1:
>
> If content length is small, set text based on end position of pdf text area content length.
>
> For example:
>
> 						                  			   "2015 Elsevier Ltd. All rights reserved."
>   
> 			                    		    "2015 Civil-Comp Ltd and Elsevier Ltd. All rights reserved."

Try the PrintTextLocations example, this shows where the text is. But it 
will be tricky... you could try to limit it to an area, and then decide 
which part is relevant.

As I said, you can't replace the text. You could draw a blank rectangle 
over the existing text.

To create a link, see the AddAnnotations.java example in the source code 
download.

To see how to output text, see the EmbeddedFonts.java example.

To append a content stream to an existing stream, use the constructor of 
PDPageContentStream with the fifth parameter set to true to avoid surprises.

Tilman

>
>
>
> Case2:
>
> If the content length is large, set the text based on start position and end position
of pdf text area content length and wrap the text to next line.
>
> For example:
>
> "2016 The Authors. Published by Elsevier Ltd. This is an open access article under the
CC BY-NC-ND license (http://
> 										     creativecommons.org/licenses/by-nc-nd/4.0/)."
>
> Please advice.
>
> Regards
> Thiruppathi M.
>
> -----Original Message-----
> From: Tilman Hausherr [mailto:THausherr@t-online.de]
> Sent: 24 May 2016 AM 01:05
> To: users@pdfbox.apache.org
> Subject: Re: Replace text and adjust text positon
>
> Hi,
>
> You attached a .docx file, no idea why this got through. I never open
> .docx files from people I don't know.
>
> Please upload screenshots as images somewhere, e.g. imageshack. PDF
> files can be uploaded to a sharehoster, eg. filedropper.com
>
> Tilman
>
> Am 23.05.2016 um 09:00 schrieb Thiruppathi M.:
>> Hi,
>>
>> Please find the attached docx.
>>
>>
>> Regards
>> Thiruppathi M.
>>
>>
>> -----Original Message-----
>> From: Tilman Hausherr [mailto:THausherr@t-online.de]
>> Sent: 21 May 2016 PM 04:41
>> To: users@pdfbox.apache.org
>> Subject: Re: Replace text and adjust text positon
>>
>> Hi,
>>
>> Attachments don't go through, please upload them somewhere.
>>
>> Replacing text is difficult, sometimes impossible, see "Why was the
>> ReplaceText example removed"https://pdfbox.apache.org/2.0/migration.html
>>
>> It can be done only if the formats are similar, i.e. from the same source.
>>
>> Tilman
>>
>> Am 21.05.2016 um 08:45 schrieb Thiruppathi M.:
>>> Hi,
>>>
>>> We are using Pdfbox for our internal pdf file automation.
>>>
>>> We struck in line adjustment.
>>>
>>> Refer the below input pdf file screen shot:
>>>
>>> For example:
>>>
>>> Here we need to replace the content "2016 Elsevier Ltd. All rights
>>> reserved." To below mention format
>>>
>>> Case1:
>>>
>>> Case2:
>>>
>>> Please advice how to achieve.
>>>
>>> Regards
>>>
>>> Thiruppathi M.
>>>
>>
>> ---------------------------------------------------------------------
>> 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


Mime
View raw message