MigraDoc : big table divided into 2 parts in one page - c#

I am working on creating a report with MigraDoc that would be able to have table with 2 columns divided in the same page. It's possible with any settings of Table object?
Draft image

MigraDoc cannot do that on its own.
You can get a PDF with such a table if you create a MigraDoc document with just 50% page width (and the height of your page body) and then use PDFsharp to draw two pages from the MigraDoc document onto one page of the final PDF.
This sample draws 9 large pages as thumbnails on one page and cane be used to get started:
http://pdfsharp.net/wiki/MixMigraDocAndPdfSharp-sample.ashx

Related

Continuous Labelling using iTextSharp PDF

I have working iTextsharp code for printing labels. Now the problem is, I have a requirement to print the labels in Continuous paper which i am not able to select in iTextsharp configuration (iTextSharp.text.PageSize.A4). Please advice how can i select the page size according to my current scenario.
Thanks
Your problem is related to PDF as a document format. In PDF, the content is distributed over different pages. You can define the size of such a page yourself. You mention iTextSharp.text.PageSize.A4, but you can define the page size as a Rectangle object yourself. See iTextsharp landscape document
If you want a long, narrow page, you could define the page size like this:
Document Doc = new Document(new Rectangle(595f, 14400f));
There are some implementation limits though. The maximum height or width of a page is 14,400 user units. See the blog post Help, I only see blank pages in my PDF!
However, I am pretty sure that you don't want to create a long narrow page. If you want to print labels on "continuous paper", you want to create a PDF document in which every page has the size of exactly one label. Your PDF will have as many pages as there are labels.
Suppose that the size of one label is 5 by 2 inch (width: 12.7cm; height: 5.08cm), then you should create a document like this:
Document Doc = new Document(new Rectangle(360, 144));
And you should make sure that all the content of a label fits on a single page. Your label printer should know that each page in the PDF should be printed on a separate label.
(Thank you #amedeeVanGasse for correcting my initial answer.)

iTextSharp automatically shrinking images

I'm using iTextSharp to display graph images in a pdf report. Previously we've only had three graphs on one page at a 30% scale. Now I'm adding a 4th image and for some reason it doesn't automatically add it to the next page. Instead it shrinks the image to fit it onto the same page. I'm not very familiar with iTextSharp. Is there a parameter I can set it to print all images at the same size?
If it makes any difference all images are the same size, 720 wide and 380 high.
My code:
Image imageChart = Image.GetInstance(st);
imageChart.ScalePercent(35);
PdfPCell cell = new PdfPCell();
cell.AddElement(imageChart);
Report in its current state (the tiny block highlighted in the bottom left is the 4th image):

Report file Print (Multiple objects) c#

I've been working on a project in C# which uses a RDLC report with an Excel file as its source.
My problem is that I have made a single rectangle on the report, and I want it to be printed multiple times on the page (i.e. On an A4 size paper, when I print it, I want 10 prints of the rectangle on the page [5 on left and 5 on right side of the page]).
I am getting 5 prints of the rectangle on the left side only. What should I do to get 10 prints (as described above)?
How can I use the Page Break functionality in the RDLC to accomplish this?

How to add bookmark using MigraDoc?

I want to add Bookmark in my PDF using MigraDoc.
For example: two images on a single page.
1. Images1
2. Images2**
and the same name bookmark will generate.
If I click on image1 bookmark that image will be shown to me. Remember both images are on single page.
MigraDoc creates bookmarks automatically for headings.
To create bookmarks without visible text on the page, you can create headings with a font size of e.g. 0.0001 and white colour.
There is one drawback: up to PDFsharp 1.50 beta 1, these bookmarks jump to the correct page, but not the correct area on the page. So with two images on one page, the bookmarks will not work as intended by the OP.

Get text width from font migradoc / pdsharp for table columns

I want to create a table in a PDF document which would have variable width of columns depending on the width of its contents.
I am using PDFSharp, MigraDoc
Maybe getting the paragraph width from the individual cells will help. Is there a way to get text width depending on the font / styles?
Any clues?
Thanks.
Using PDFsharp functions, you can get the width of any text.
MigraDoc is not limited to PDF, it creates documents for PDF, RTF, print. No chance to determine the exact width (unless you restrict yourself to PDF and use PDFsharp to get the width).
MigraDoc will break text in columns to the next line when needed.
Create a dummy PdfDocument, create a page, get an XGraphics object (gfx) for that page, then use gfx.MeasureString() to find the width.

Categories

Resources