I'm using C# .Net and want to generate a random size HTML table into PDF. I have tried ExpertPDF and Essential Objects HTMLtoPDF but they seem to mess up on very wide tables.
Any tools or ideas to fix this?
These tools use html rendering engines like a regular browser. Then they take the rendered content and write it into a pdf. They don't know how to handle wide content (except for scaling it to fit into a pdf page).
You need to change your html (create a printer friendly version of your page that is not that wide) and feed the html to pdf converter something that it can chew.
Related
I have a requirement where I need to write my asp.net page information into pdf file with the css styles(inline/style sheet file). While creating pdf we have to make the textboxes to labels with textbox like border and similar for dropdowns, checkboxes. Can you please help us on how to proceed?
Try DynamicPDF Converter for .NET, it is not a free tool but it can convert several different file types including HTML to PDF. It uses Internet Explorer (IE) to render the HTML and convert that to PDF. The formatting and styles of the resulting PDF will look similar to how your HTML is displayed in the IE’s print preview.
Disclaimer: I work for ceTe Software, the company that develops DynamicPDF libraries.
It's obvious from the title what I want to do. I know it is possible to convert html to PDF document using a very popular library iTextSharp. But what I acknowledged from this post is iTextSharp cannot render HTML5 and CSS3 styles correctly. Is there any free library to achieve this?
Backgroud:
I am using DevExtreme for report generation. It has supported chart export in PDF but my client wants some extra content in PDF apart from charts. It is not supported by DevExtreme, so I took decision to write my own custom PDF exporter.
There are some libraries available but I cannot rely them since I can't predict in advance what issues will it cause in production in future. Correct me if I am wrong, there is no API given by Microsoft for manipulating PDF files. We can create and manipulate excel and doc files using Microsoft.Office.Interop.Excel.dll and Microsoft.Office.Interop.Word.dll but I didn't find anything for PDF manipulation.
Please suggest me what options I have.
Hope this makes sense..!
A few years back I was using iTextSharp to get our html manuals in xhtml/css/wiki to pdf. It was...painful and a lot of work. So, the first news is: You will need quite a few weeks (2,3,4 weeks, depending on the grade of perfection you want) of time if what you have is not only a few html pages.
If you only have a very limited amount of pages, the quickest and dirtiest way is to make screenshots from your rendered pages and add those images to the pdf. Not very high-tech but quickly done.
If your style sheets can be sacrificed and you do not care about the formatting of the content to be identical, you can convert your html5 pages to xhtml so you can load them as XmlDocuments. Then you simply create a program which does some mapping from xml elements, such as <h1>MyTitle</h1> to some section of code which creates a pdf entity using iTextSharp. Basically that was the way I did it in my case. I also did some mapping from css style classes to some specific pdf formatting, but not to the extreme.
Also worth trying is converters from html (or xml) to tex/latex. If you are lucky you find one which does a good enough job. Then you can use pdftex and get your pdf.
Also, it is possible that you can print your documents to an xps printer and then convert the xps to pdf. Or you simply convince your customer that xps is what they want.
I am building a large scale web application with many "print" requests a minute. We have dynamic content from an editor that I print out with other HTML elements. What is more efficient, rendering that html and then printing the html page or rendering a PDF server side and displaying that in an iframe to be printed?
With the multiple server side calls for rendering the images plus authenticating the user (and we also have a dynamic image header and footer dependent on the logged in user) would it be more efficient to render native PDF controls and then put a pdf in an iframe to print?
I was planning on using itext sharp or http://www.websupergoo.com/ for the rendering.
the app is a c# Web forms application.
As I see it in order to generate the PDF you need to generate the HTML. So by generating the PDF you are adding to the processing required not reducing it.
Is there a markup language that can be used in conjunction with a well supported .net open source project to generate PDF or HTML documents with very fine control on the output in terms of style and anchoring for both ?
Documents will part be static and part auto generated from the xml comments of some class libraries.
To Clarify the question, I Know html is a markup language, The reason I don't want to use it to directly store the content is because all of the HTML to PDF tools and libraries I have looked at contain patchy support for creating tables of contents, indexes and turning hyperlinks in to PDF document anchors.
I would opt for HTML documents. Markdown comes to mind. But as far as 'very fine' control goes arbitrarily, you can always just use HTML.. it is THE HyperText Markup Language after all.
There were many questions like this before on stackoverflow. I think the consensus is that you should have one markup language, rather than two.
HTML is - by definition (hypertext MARKUP LANGUAGE) - the markup language of choice and all you need to do is convert that to PDF. The other way around, from PDF to HTML is quite a bit tougher.
In order to convert HTML to PDF there's a truckload of tools, depending on what exact needs you have for the resulting PDF and what kind of CSS you need to support.
I'd always go for a rendering engine that's used in browsers (instead of something like iText or Prince), because you want to make sure your docs look like they do in a browser. You'd end up with Winnovative or something based on WebKit like the API by htm2pdf.
XSL-FO is the recommended solution. It provides a great level of control over the document layout and there are several tools for XSL-FO to PDF comversion.
What's the best way to render a chunk of HTML in an application? We have a rich text editor control (from Karamasoft) in a web page, and need to generate a PDF with records saved from the control (with custom page headers, page footers, and record headers) so I need to be able to render the html so it can be "drawn" onto the page to be saved as a pdf.... is there any staright forward simple way to do this?
HTML Renderer is a library of 100% managed code that draws beautifully formatted HTML.
Without using any libraries, you can use the Literal control that allows you to inject the HTML you wish to display to the user.
You may try PURE to render JSON data in HTML: http://beebole.com/pure/
Although this may be out of topic.
But then I'm interested on how do you convert the HTML in PDF.
What technical steps are involved?