I have to export a table with dynamic count of rows to a PDF that must fit on one page.
Currently, I'm generating an HTML document, wrapping the table within a <div> and then using CSS zoom to zoom out; the percentage is calculated with the count of rows. This HTML is then converted to PDF via wkhtmltopdf.
I need a better solution because the zoom calculation is not very reliable. Some rows are displayed higher than others and also wkhtmltopdf has some rendering troubles when using zoom.
I looked in the docs of FOP, iText and some other libraries/tools but couldn't find a solution.
Only requirement: It has to run on a Linux machine.
Thanks!
Related
given that the functionality for exporting graphs to SVG or PNG in the Neo4j server page is broken (see SO article), are there any utilities out there that can export a graph from Neo? something that would produce a PDF perhaps?
With not many changes, you could make it work with http://www.cloudformatter.com/CSS2Pdf to format the SVGs in browser to PDF. That set of pages has some d3 samples like this: http://www.cloudformatter.com/CSS2Pdf.SVGCharts.d3Charts
I took one of the sample charts and rendered to PDF through the Javascript and the remote formatter. The page I selected was here and I took one of those charts:
http://graphgist.neo4j.com/#!/gists/1428842b2170702400451777c2bc813f
The code needs some minor change to ensure that Neo4j puts the svg namespace on the element. The samples on that page do not. But the rendering is near perfect. See the web page on the right and PDF result on the left. I only formatted the SVG and not the whole page (where the silver background exists) and that seems to be the only difference.
In PDF generators you can normally describe a bounding box where if there is overflow it goes to a new page and you can include the content that wrapped it again.
I'm trying to figure out how to elegantly do this in Wicked, since we have a new requirement to allow users to generate their own PDFs from HTML.
The layout is roughly as follows:
[ address / logo ]
[ list of items purchased ]
[ footer ]
All the regions are a fixed size. With a handful of items there is no issue. If there are more than will fit in the region designated for the items purchased it cannot overflow. It needs to generate a new page break and put the overflow items on the following page (with the same header and footer wrapper).
I'm not sure there is a way to get a div's overflow to paginate like that in CSS though. (Prawn can do it, but it doesn't accept HTML). I don't know that something is going to overflow until it's rendered too, just knowing the count of items isn't enough.
Webkit doesn't really have good support for page breaking. I found out from their own page: "The current page breaking algorithm of WebKit leaves much to be desired.
Basically webkit will render everything into one long page, and then cut it up
into pages. This means that if you have two columns of text where one is
vertically shifted by half a line. Then webkit will cut a line into to pieces
display the top half on one page. And the bottom half on another page. It will
also break image in two and so on. If you are using the patched version of QT
you can use the CSS page-break-inside property to remedy this somewhat. There is
no easy solution to this problem, until this is solved try organizing your HTML
documents such that it contains many lines on which pages can be cut cleanly."
I'm using iText 5.4.4 and I want to generate a PDF for a continuous paper ticket printer. My doubt is how to set the new Document to avoid splitting the pdf in several pages:
Rectangle pagesize = new Rectangle(360f, 720f);
Document document = new Document(pagesize, 36f, 72f, 108f, 180f);
There is any posibility to do this ?
PDF is not HTML. PDF is a Page Description Language. At the root of a PDF file, you have an object named the Catalog dictionary. In this Catalog dictionary, there is a reference to a page tree. This page tree is a structure that contains references to every page in the file. A page is an autonomous element in the PDF. Suppose that you have a PDF with 10,000 pages and you only need page 10,000, then you can fetch that page directly without having to render the 9,999 preceding pages. This is a "raison-d'ĂȘtre" of PDF. Hence your question sounds very strange: it is inherent to PDF to have pages.
It seems as if you want to create a PDF with a single page, containing a number of tickets each measuring 10 inches in height. In that case, you have to create a large page on which you print all these tickets (note that this is a bad idea, but I'm merely answering your question).
You need to take into account, that there's a maximum size for a PDF page. This maximum is 14,400 for the width and 14,400 for the height. So if you want to create a single page for a large number of tickets each having a height of 10 inch, you can create a page like this:
Rectangle pagesize = new Rectangle(360f, 14400f);
You will be able to fit 20 tickets with height 10 inch (720 user units) on this page, not more.
I realize that there are several other posts similar to this one, but I have tried every solution found within them and have not had any luck. Basically, I have a ColdFusion generated webpage that consists of a jQuery DataTable. I want to export the contents of the DataTable to PDF, however on certain tables where the table content exceeds the height of the page, the PDF adds my header area and then the rest of the page is blank. The table then shows up on page 2. Has anyone had trouble similar to this?
I've tried setting the page size, margins, #imports for the CSS, standard links for the CSS, inline CSS, and nothing seems to fix it.
Any help is greatly appreciated! Any suggestions are welcome too!
What ended up fixing this problem for me is I wrote a simple javascript function that takes two parameters, the id of the table requested and the max rows per page. My javascript function then grabs the entire table, and breaks it into separate tables using the max rows value as the number of rows per table. I then output the JS variable as the value for the tag and there are no longer incorrect page breaks.
I hope that in the future the cfdocument tag will be more proficient at knowing when it's reached the end of a page and break the content appropriately, but for now this works.
I am grabbing text data from XML files, and want it to display in book page-like format inside a UIWebView on iPad. The XML files are coming out of a .epub, and each one contains a single chapter of a book, divided up only by p tags.
I want to dynamically paginate these files into book-like pages based on the size of the UIWebView, which is a full iPad screen, as well as by user-selected font size. I am currently loading a blank html page with related css into a UIWebView, grabbing paragraphs based on number of characters as Strings from the XML, and printing these into the html using StringByEvaluatingJavaScriptFromString and the innerHTML property.
Obviously, doing this by number of characters creates improperly spaced, oddly formatted pages, but I'm not sure how else to "paginate" the text.
What I am looking to do is something akin to the app "eReader" on iPad:http://www.ereader.com/. They seem to be breaking a single file up into pages dynamically, and loading it into UIWebViews. How is this done?
Most EPUB readers that are based on UIWebView simply use CSS3 Columns to paginate the document.
You can see this in action at http://www.quirksmode.org/css/multicolumn.html
The basic idea is that you 'columnize' the document and then scroll horizontally through it to show a specific page.
Having done this for one popular (Canadian) eReader application on the iPhone and iPad, I can tell you that the technique works but that it is far from ideal.
The code is already made. It is called epubjs. It is Javascript only epub reader.
Use UITextView with PageviewController . (specify your doubts in it , if any )