pdfbox-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Tilman Hausherr <THaush...@t-online.de>
Subject Re: overlap issue
Date Sat, 17 Dec 2016 11:29:08 GMT
Am 17.12.2016 um 09:59 schrieb Thiruppathi M.:
> Hi,
>
> Herewith I have enclosed the PDF input and output as images for your reference.

This didn't get through. Attachments get blocked most of the time.

>
> I have to remove the sentence "00 (2015) 000-000" and insert the new sentence with appropriate
values.
>
> It was updated correctly and I am facing the below issue,
>
> 1. The ndash (-) in the page range was getting overlapped with the next character after
the conversion.
> Please refer PDF_output.png. eg.3622-3628
>
>
> a. [You have a tokens object (what type?)]
> 	
> 		This is the tokens object sample code.
>
> 				PDDocument doc = PDDocument.load( "input.pdf" );
> 				List pages = doc.getDocumentCatalog().getAllPages();
> 				PDPage page = (PDPage)pages.get( 1);
> 		            	PDStream contents = page.getContents();
> 		
> 		            	PDFStreamParser parser = new PDFStreamParser(contents.getStream());
> 		            	parser.parse();
> 		
> 		            	List tokens = parser.getTokens();
>
>
> b. [You have a tokens object (what type?)]
> 			
> 		  The code for array,
>
> 				COSArray array = new COSArray();
> 				String newSentence = "Materials Today: Proceedings "+ volume_number+"("+strYear+
") "+ First_Page_Number+"-"+Last_Page_Number";
> 				array.add(new COSString(newSentence));
> 				tokens.add(stvalue-1, array);
>
> Please advice how to proceed further.

OK, so what really happened is that you were trying to use the 
ReplaceText example to replace some text. Read at the end of

https://pdfbox.apache.org/2.0/migration.html
"Why was the ReplaceText example removed?

You are now having exactly the problem we're talking about. PDF isn't 
made for editing.

To understand this, what you could do is to use the WriteDecodedDoc 
command line utility. You can then edit the PDF with NOTEPAD++. Be 
careful not to change any offsets, i.e. the byte position of "endstream" 
must stay the same. But you can now try to change the numbers of positions.

Tilman


>
> Regards
> Thiruppathi M.
>
> -----Original Message-----
> From: Tilman Hausherr [mailto:THausherr@t-online.de]
> Sent: 16 December 2016 PM 08:53
> To: users@pdfbox.apache.org
> Subject: Re: overlap issue
>
> Am 16.12.2016 um 15:18 schrieb Thiruppathi M.:
>> Hi,
>>
>> The sentence doesn't appear properly in PDF when delete and insert the
>> new sentence.
>>
>> This is the code:
>>
>> String newSentence = "Materials Today: Proceedings "+ volume_number+"
>> ("+strYear+ ") "+ First_Page_Number+"-"+Last_Page_Number";
>>
>> array.add(new COSString(newSentence));
>>
>> tokens.add(stvalue-1, array);
>>
>> Refer the below output,
>>
> The image didn't get through. And I have no idea what you want to do.
> You have a tokens object (what type?) to which you added a value and an
> array. For what?
>
> Tilman
>
>> 3268 is overlapped on ndash. Please advice how to resolve this issue.
>>
>> Regards
>>
>> Thiruppathi M.
>>
>
>
>
> ---------------------------------------------------------------------
> 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