Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsWhite Papers
Discussion GroupsFirst AidDatabasesJavaBeansGUIJava 3DVirtual MachineCORBASecurityToolsGeneral
Java DirectoryOpen Source ProjectsSample Book ChaptersUser GroupsWeb Resources
Related Topics
Databases.NETMore Topics ...

Java Forum / General / November 2007

Tip: Looking for answers? Try searching our database.

How to convert pdf to xml

Thread view: 
fancyerii - 12 Nov 2007 07:44 GMT
Hi, all.
   I want to convert a pdf file to a xml which has not only the text
of the pdf file but also the layout information (e.g. font). There are
dozens of open source libraries--pdfbox, itext,.....  Which one is
better for me? Thank you.
Andrew Thompson - 12 Nov 2007 11:51 GMT
...
>    I want to convert a pdf file to a xml which has not only the text
>of the pdf file but also the layout information (e.g. font).

Note that XML was originally designed to hold data and
objects *as opposed to* representation/rendering of that
data - 'how it will look'.  Rendering instructions for the data
in XML might be encoded into an XSLT File.

Trying to shove a WYSIWYG document into 'XML' seems
contrary to what XML is for.

What is it exactly you want to do with the converted data?
What does this ability offer to the end user?

Signature

Andrew Thompson
http://www.athompson.info/andrew/

Pavel Lepin - 12 Nov 2007 12:33 GMT
Andrew Thompson <u32984@uwe> wrote in <7b19c9fce68f6@uwe>:
>>    I want to convert a pdf file to a xml which has not
>>    only the text
[quoted text clipped - 4 lines]
> objects *as opposed to* representation/rendering of that
> data - 'how it will look'.

Um, I believe that's incorrect. One of XML design goals as
stated in XML 1.0 4E, 1.1 is:

 XML shall support a wide variety of applications.

XML, essentially, is pure syntax with no semantics. What
semantics of a particular XML application are aimed at
expressing is up to the people who designed that
application. It might be semantic document markup
(DocBook), presentational document markup (XSL-FO),
something that would take a Semantic Web zealot[*] to
describe properly (RDF/XML), a program in Turing-complete
programming language (XSLT), remote method invocation
(SOAP), vector graphics (SVG) or pretty much anything else
that could be represented as a tree.

> Rendering instructions for the data in XML might be
> encoded into an XSLT File.

You're probably thinking of XSL-FO (which is an XML
application itself). XSLT problem domain is a bit wider,
it's a fairly powerful document transformation language, -
although, indeed, one of the primary use cases considered
when the spec was being developed was transformation of
random XML documents to XSL-FO. Oh, and XSLT is an XML
application as well. *shrug*

> Trying to shove a WYSIWYG document into 'XML' seems
> contrary to what XML is for.

XSL-FO is an XML application that is, in short,
presentational markup for paged media. Apache FOP is a FOSS
XSL-FO processor oft-used to convert XSL-FO documents
(usually generated from something else) to PDF documents. I
haven't heard of anyone doing it the other way 'round
(PDF -> XSL-FO), but Google might have.

[*] meaning no disrespect to Semantic Web zealots

Signature

...also, I submit that we all must honourably commit seppuku
right now rather than serve the Dark Side by producing the
HTML 5 spec.

fancyerii - 12 Nov 2007 13:43 GMT
I want to get the text's layout information to analyse the pdf
file. The xml is just a way of express it.
 for example, I want to extract the text of a pdf file like this.
 <line fontname="..." fontsize="  " startx=" " starty=" " endx
endy ....>
        a line.
</line>
Andrew Thompson    
> ..
> >    I want to convert a pdf file to a xml which has not only the text
[quoted text clipped - 17 lines]
> Message posted via JavaKB.com
> http://www.javakb.com/Uwe/Forums.aspx/java-general/200711/1
Andrew Thompson - 12 Nov 2007 14:14 GMT
>I want ..

Please refrain fom top-posting.

Signature

Andrew Thompson
http://www.athompson.info/andrew/

Wildemar Wildenburger - 12 Nov 2007 16:05 GMT
>    I want to get the text's layout information to analyse the pdf
> file. The xml is just a way of express it.
[quoted text clipped - 3 lines]
>          a line.
>  </line>

If that is all you want to do, I would suggest you don't bother with the
XML at all. You can do an analysis of the properties of the text just as
well (heck, better?) using direct java data structures. Right?

/W
fancyerii - 12 Nov 2007 14:45 GMT
> ..
>
[quoted text clipped - 7 lines]
>
>I just want to get the text of a pdf file and the layout information. The xml file is just a way of storing it.
A possible result may be:
<line number="1"fontname="" fontsize="" startx=""  ....>
 a line
</line>
Joshua Cranmer - 12 Nov 2007 21:40 GMT
> Hi, all.
>     I want to convert a pdf file to a xml which has not only the text
> of the pdf file but also the layout information (e.g. font). There are
> dozens of open source libraries--pdfbox, itext,.....  Which one is
> better for me? Thank you.

Adobe has a version of PDF that is essentially a zip file of several XML
documents called the Mars format. Is that sufficient for you?

Signature

Beware of bugs in the above code; I have only proved it correct, not
tried it. -- Donald E. Knuth



Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.