iText - Manipulate existing PDF - add dashes to end of each paragraph -


i need manipulate existing pdf in itext add dashes end of each paragraph. this:

tab leaders

i make in word tab leaders.

is possible itext on existing document.

any appreciated.

thanks!

edit clarifications

itext version 5.5.x, guess can upgrade if task easier newer version.

there paragraph not need dashes, have control of original pdf. assembled different system , add kind of markers paragraphs need leaders (ie. can add text "~tab~" @ end of such paragraphs).

at moment documents need kind of editing have headers , footer, nothing text , 1 column justified alignment.

edit more clarification

i can (by configuration) set dashes has end (ie. @ 10px) specific document. know every document type (and structure) needs manipulated way.

this insanely hard. should think of pdf document container of instructions, rather wysiwyg format. finding out lines (let alone paragraphs) hard.

high level plan:

  1. use ieventlistener process events pdf being parsed
  2. look out textrenderinfo events, store them
  3. sort textrenderinfo events ensure list of events in logical reading order.
  4. merge items in list if appear on same line , less distance apart (for instance distance of 3 spaces in font specified textrenderinfo)
  5. now should have lines
  6. merge lines if appear in close vertical proximity of eachother , overlap horizontally. how close should be, , how overlap you'll have figure out, , might differ page page, , document document.
  7. now should have paragraphs
  8. figure out bounding box of each paragraph. or more accurately, convex hull. there algorithm called gift-wrapping algorithm.
  9. now can insert lines inspecting convex hull. easy step.

if can insert markers, can using itext7. itext7 has implementation of ieventlistener allows regular expressions within pdf document. returns locations regular expression found. if can ensure markers satisfy kind of regular expression, can them, coordinates, , insert line @ calculated position.

of course, need rid of marker text. can use pdfsweep.


Comments

Popular posts from this blog

angular - Ionic slides - dynamically add slides before and after -

minify - Minimizing css files -

Add a dynamic header in angular 2 http provider -