I have a dynamic PDF report which gives monthly report of our database. I am using Prawn to generate the PDF report.
The monthly report can contain maximum of 90 rows (maximum 3 per day). There can also be days with no record. So, the number of rows in a monthly report is highly dynamic.
The client needs the report in a single page PDF. They dont care if the font size becomes very small or the row height is really small. But the contents should fit in a single page.
They have shown examples of PDF that are generated using their previous application. In those, it seems that they are creating the table with a fixed font size and row height etc. and they are somehow zooming out so that the PDF has some whitespace in the right side of the page, but it fits in a single page.
Something like this:
Is there a way to achieve this in Prawn?
The needed page layout can be easily achieved with PD4ML's fitPageVertically() API call - but PD4ML approach differs from Prawn quite significantly.
With PD4ML you have to generate an HTML document with report data/table (not that tricky to do) and after that pass it to PD4ML for a converting to PDF.
PD4ML in Ruby scenario can be launched as a standalone converter application.
You can build a fixed size table for print with option:
overflow: :shrink_to_fit
in table cells. That will shrink to a smaller font automatically.
given the number of rows to be print, you can dynamically adjust tables row heights
see: http://prawnpdf.org/prawn-table-manual.pdf
Related
I am Using RubyXL gem in my rails application to generate the workbook with 4-5 sheets.We are generating excel with large number of cells(more than 5000(146*26)). It takes more than 20 minutes to write that file and consume a lot of memory. One of the sheet is having dynamic data which has some styles like border back ground color, font color, bold text etc.I am using this code snippet.
workbook = RubyXL::Workbook.new()
sheet = workbook.worksheets[0]
cell = sheet.add_cell(row, col, text)
cell.change_fill('#fff')
cell.change_font_color('#000')
cell.change_font_bold(true)
I tried to reduce the time by removing some style like borders by which it reduce some time in writing but it still taking long time. So I've removed the remaining styling mentioned above. After which it is now taking 1 minute approx.
can you please suggest me the way to apply the styling to the cells so that it will take less time and will not affect the performance.
I will be happy to answer any question/query regarding this or if I miss anything.
You can change columns and rows in a whole instead of cell per cell.
This will be a lot faster.
I suppose there is a glitch in this feature because the column width after the change is set to 0 so not visible, but you can reset the width after the operation.
sheet.change_column_fill(0, '0ba500')
sheet.change_column_font_color(1, '0ba53d')
sheet.change_column_width(0 ,10)
sheet.change_column_width(1 ,10)
Want to create complete report in pdf. i successfully draw text and images in PDF by using Apple documentation but i am unable to find any solution to create table in PDF with rowspan and colspan functionality, also if table size greater than pdf page size then it displays remaining table to the next page. Any solution,API or library which helped me for this Problem?
PDF has no builtin notion of tables. In fact, the only PDF primitives are Glyphs, Shapes and Images. If you want to generate a table, you have to stroke all the lines of the table yourself, using, for example, CGContextStrokePath (after you have built a path with the lines in the table).
I am printing some custom drawn charts on a fast Reports 4 databand.
The band has one text component and one picture component which I manipulate in the OnBeforePrint event to draw my charts using its canvas.
The problem is that the width of the charts may change drastically and go far beyond the page width and scaling/streching the charts to fit the page limits is not an option for the user.
I tried to make the page width grow to accommodate the graphics and it worked very well while visualizing, but I cannot print it since the user's printer only accepts A4 paper size.
So how can I split the report in smaller A4 pieces like the following image?
PS: the first image is the actual report output and the second one is the desired result.
I'm using PHP to generate docx documents from a database. The generated document contains column charts which have labels attached (i.e. user shapes containing textboxes). In an attempt to get the textboxes to accommodate and display all of the text (i.e. it shouldn't be necessary for the user to resize a textbox to see all the text) my code calculates how many characters will fit into 3cm, adds linefeeds to the string as required and tells me how many lines of text are needed. I have:
<a:xfrm xmlns:a="http://schemas.openxmlformats.org/drawingml/2006/main">
<a:off x="1638276" y="1676399"/>
<a:ext cx="1257325" cy="'.(252000 * $labelLeftLines).'"/>
</a:xfrm>
which I believe should give me a text box around 3.5cm wide (extra .5 for the internal padding) and a height of .7cm multiplied by whatever is the value of $labelLeftLines. However, the text box always turns up as 3.cm wide by .86cm high, which only ever displays one line of text.
If I add in 'autofit':
<a:bodyPr xmlns:a="http://schemas.openxmlformats.org/drawingml/2006/main" vertOverflow="clip" wrap="square" rtlCol="0">
<a:spAutoFit/>
</a:bodyPr>
the generated file looks just the same, though, when I right click on the textbox to inspect the properties, 'autofit' is indeed applied. I have to uncheck it and recheck it to make it affect the textbox.
Any openXML gurus out there?
Hmm, some random floundering around revealed that the values I need to manipulate are here:
<cdr:relSizeAnchor xmlns:cdr="http://schemas.openxmlformats.org/drawingml/2006/chartDrawing">
<cdr:from>
<cdr:x>0.47</cdr:x>
<cdr:y>0.75</cdr:y>
</cdr:from>
<cdr:to>
<cdr:x>0.67</cdr:x>
<cdr:y>1</cdr:y>
</cdr:to>
Changing those values does actually change the size of the texbox, though I haven't a clue what units are being used. From 0.75 to 1 produces a height of 1.43cm.
One day I'll maybe be able to find my way around the doucmentation.
Description of Application:
I have an application that allows a user to output a report to a document. The data that is written to the document is in the form of a table. The number of columns in the table and the width of the strings contained in each cell in the table are unknown until runtime (it depends on what query the user runs, what they want to see in the report etc.).
I'm using Delphi XE and Gnostice's eDocEngine to create a PDF document, and then creating a table in the document and writing the report data into it.
Problem:
The problem that I'm having is that you can only write a certain number of columns (6 or 7) into the document before they disappear off the right hand side of the document. It isn't unknown for a user to produce a report with 30 or 40 columns in the table (as they correspond to fields in a database, which they run a query over), so I need to be able to get the table to fit entirely into the document, no matter how many columns it contains.
As a PDF can be zoomed, I suppose I could shrink the font size and column widths down and fit everything in that way, as the user could then zoom in and scroll around the table using their PDF reader. What I need to know is:
Is there a better way of getting the entire table to fit onto a page?
If shrinking/zooming is the best/only way of doing this, what is the most efficient way of ensuring that everything fits without making the document look strange (i.e. the table should ideally stretch across the page, rather than be bunched up to the left hand side because of some random scaling algorithm).
Edit
I've just done some more digging around and I've found "inputXRes" and "inputYRes" properties that change the scale of the canvas in the document, which looks promising, but I can't get it to work properly at the moment. Can anyone shed any light on how those properties are used? The text itself is scaling, but the size of the table stays the same, meaning that I've now got a tiny piece of text in the middle of a huge table cell, and the table is still only displaying 7 columns in the report.
Don't mess with scaling and font size.
Your customers will use PDF Reader and there are some options that will help to read the informations e.g. 1:1. But when you change the scaling or font size you cannot read the information, because it is too small.
Get a font size that fits perfect the needs of your customers and extend the page size to fit the table size.
With PDF Reader your customers will have the choice to view and print (shrink to fit) as they like and which paper size their print can handle.
BTW:
If you change the resolution and draw a line with a length of 2 inch on the canvas it will be 2 inch long, but a text with font size 12 (pixels) will grow or shrink.