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 2006

Tip: Looking for answers? Try searching our database.

HTML to PDF with formatting options

Thread view: 
param - 22 Nov 2006 06:12 GMT
Hi

I am converting a HTML file to PDF. I have specified all the styles &
formatting in separate style sheets, whose paths are given in HTML
document itself.

But when I convert HTML file to PDF document, none of the styles,
colors etc appear in my PDF document. Does anybody has idea about the
same that how to get all the formatting options in PDF?

Thanks & Regards,
Param
Andrew Thompson - 22 Nov 2006 07:34 GMT
...
> I am converting a HTML file to PDF.

Why?  PDF's are generally only good for printing, and..

>..I have specified all the styles &
> formatting in separate style sheets, whose paths are given in HTML
> document itself.

..that* can be achieved using HTML with a media='print'
stylesheet attached.

* Most of what could be achieved in formatting a
programmatically generated document.

Andrew T.
Dag Sunde - 22 Nov 2006 09:41 GMT
> ...
>> I am converting a HTML file to PDF.
[quoted text clipped - 10 lines]
> * Most of what could be achieved in formatting a
> programmatically generated document.

There *are* scenarios when you have a nice printable html,
but *still* want to store it as a pdf.

We have a WebApp where the daily report are printed from the
browser with a media='print' stylesheet, but every night that
page is converted to .pdf and archived.

This way, the users can look up old reports and, just as important,
they kan download and store the reports locally.

Signature

Dag.

param - 22 Nov 2006 09:44 GMT
> > ...
> >> I am converting a HTML file to PDF.
[quoted text clipped - 23 lines]
> --
> Dag.

Firstly I am converting HTML object to corresponding XML file & then
this XML file is converted to FO:XSL file. Using FOP I convert this XSL

file into PDF using Tranformer.

I am using FOP alongwith jstl, xerces & avalon.

I have used extrenal stylesheets in my JSP file. I have tried using
inline styles also. Only BOLD text is shown as bold in PDF, rest of the

formatting like table borders, colors, underline etc does not appear in

my PDF document.
Andrew Thompson - 22 Nov 2006 10:49 GMT
....
> I have used extrenal stylesheets in my JSP file.

Did you by any chance try..
a) validating the HTML that resulted from that JSP
<http://validator.w3.org/>
b) validating the external stylesheets
<http://jigsaw.w3.org/css-validator/>
c) attaching an appropriate print stylesheet to the HTML.
d) printing it?

>....I have tried using
> inline styles also. Only BOLD text is shown as bold in PDF, rest of the
>
> formatting like table borders, colors, underline etc does not appear in
>
> my PDF document.

BTW - besides all the stuff you have 'tried',
I am still not clear 'what you are trying to achieve'
(and 'make PDF' is mereley a strategy, not an
end goal, in this sense) by making a PDF.

Why PDF?  What is the purpose of producing these
(horrid) documents?

Andrew T.
Andrew Thompson - 22 Nov 2006 10:43 GMT
> > ...
> >> I am converting a HTML file to PDF.
[quoted text clipped - 7 lines]
> > ..that* can be achieved using HTML with a media='print'
> > stylesheet attached.
...
> There *are* scenarios when you have a nice printable html,
> but *still* want to store it as a pdf.

<sceptical>
Yeah?  Like when?
</sceptical>

> We have a WebApp where the daily report are printed from the
> browser with a media='print' stylesheet, but every night that
> page is converted to .pdf and archived.

'archived'?  How?

> This way, the users can look up old reports and, just as important,
> they kan download and store the reports locally.

But HTML can be 'archived', in the sense of being stored,
and retrieved later, locally or ..elsewhere depending on need.
(My OSComponent offers 'File|Save As' for web pages
(usually complete with stylesheets - though not sure
how that works with print stylesheets - and I am sure
many major user agents offer the same or similar).

Again - I fail to see the thing(s) that can be done
with PDF that cannot be achieved with 'plain old'
HTML/CSS (at least - with a little education of the
end user).

Andrew T.
Dag Sunde - 22 Nov 2006 11:10 GMT
>>> ...
>>>> I am converting a HTML file to PDF.
[quoted text clipped - 20 lines]
>
> 'archived'?  How?

Stored on the web-server, accessible by the users

>> This way, the users can look up old reports and, just as important,
>> they kan download and store the reports locally.
[quoted text clipped - 5 lines]
> how that works with print stylesheets - and I am sure
> many major user agents offer the same or similar).

Now, *that* is a mess!

> Again - I fail to see the thing(s) that can be done
> with PDF that cannot be achieved with 'plain old'
> HTML/CSS (at least - with a little education of the
> end user).

"...with a little education of the end user."

I see volumes of trouble with that path, since most user-agents
(browsers) do this "Save AS..." in vastly different ways.

And another thing is, that a pdf document are for all practical
purposes a read-only document, so its perfect for ie. official
market reports, et.c.

I know you don't like pdf Andrew, but it have its uses. And the OP
had a practical problem generating one. It is always valuable to
inform about alternative solutions, but...

:-)

Signature

Dag.

Chris Uppal - 22 Nov 2006 13:46 GMT
> Again - I fail to see the thing(s) that can be done
> with PDF that cannot be achieved with 'plain old'
> HTML/CSS (at least - with a little education of the
> end user).

HTML is /lousy/ way of representing formatted text.  Uncotrollable,
browser-dependent, limited...  Just horrible.

I does have its place, I quite agree, but that place is the Web, /not/ my
filesystems, thank you very much!

(I am, of course, overstating.  A more rational evaluation would be something
like: HTML is useful when cross-linking is important, and layout and formatting
are not.  PDF is useful in the reverse situation.  But most worthwhile
documents, IMO, fall into the latter camp.)

   -- chris
Andrew Thompson - 22 Nov 2006 14:06 GMT
> > Again - I fail to see the thing(s) that can be done
> > with PDF that cannot be achieved with 'plain old'
[quoted text clipped - 3 lines]
> HTML is /lousy/ way of representing formatted text.  Uncotrollable,
> browser-dependent,

I prefer to think of it as 'user enabled'.

If that lovely PDF uses such faint contrast between
text and background that it is illegible - the user is
stuffed.

OTOH - Any half decent UA will allow an end user to
override the author's 'dezigner' colors and provide instead
- high contrast colors (useful for their color blindness)
..and with..
- text at twice normal size (to assist with that
 carpal tunnel syndrome - ?).

>...limited...

Yes, the PDF is very limited, when you think of it like that.. *

>... Just horrible.

There, there.  I'll zip some HTML and send it
to you forthwith.     *  ;-)

Andrew T.
param - 23 Nov 2006 06:58 GMT
Guys,

My problem is left in between the discussion of HTML & PDF:-(.

If anyone has any idea regarding how to convert html to PDF with all
formatting using fop, please reply.

Regards,
Param

> > > Again - I fail to see the thing(s) that can be done
> > > with PDF that cannot be achieved with 'plain old'
[quoted text clipped - 27 lines]
>
> Andrew T.
Andrew Thompson - 23 Nov 2006 07:44 GMT
> Guys,

Please refraqine from top-posting.

> My problem is left in between the discussion of HTML & PDF:-(.

Rubbish! There are a number of questions open on this
thread - all of which you have chosen to ignore.

> If anyone has any idea regarding how to convert html to PDF with all
> formatting using fop, please reply.

Perhaps *you* could progress the technical problem by
*answering* the questions I have asked you, rather than
just treating this like a help desk that answers *your*
questions.   :-/

Andrew T.
param - 23 Nov 2006 08:38 GMT
> > Guys,
>
[quoted text clipped - 14 lines]
>
> Andrew T.

Hi Andrew,

I am really sorry if I offended you in anyways. Thanks alot for all the
help.

Regards,
Param
Andrew Thompson - 23 Nov 2006 09:50 GMT
....
> I am really sorry if I offended you in anyways.

You have not offended me - people that *try* to
offend me usually fail.

>...Thanks alot for all the help.

Whoa up!  We have, as you pointed out, gone off into a
little side-track discussing the benefits of HTML over PDF.

Well, it's partly a side-track, and partly a legitimate
*question* which has still not been answered.  Perhaps,
if you answer the simple questions above, we can
a) establish that a PDF (ick) is actually *required* here
(yes, yes - you keep saying - but please provide us with
a few words to *convince* us.)
b) (which might then encourage) those who actually
*know* how to resolve the issue of producing a PDF
(ick) to break into the thread - they seem to be shy
creatures, and need some encouragement.

( And as an aside - I am hoping you resolve the
technical issue, whichever way it goes.. )

Andrew T.
param - 23 Nov 2006 11:06 GMT
> ....
> > I am really sorry if I offended you in anyways.
[quoted text clipped - 22 lines]
>
> Andrew T.

I am trying to solve the issue. Not solved yet :(.

Regarding PDF & HTML debate, I must say both have their own advantages.
Its just the matter of place where they are used.

Param


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



©2009 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.