C# PDF work with tables - c#

I have a pdf file with some table inside.
I want to read this document and change some existing row and add new rows too.
Is there a way do do this?

I'm afraid you won't have any luck.
Unfortunately you don't get 'rows' in a PDF - there is no concept of a table in PDF - only text and vector graphics.
This means you will have to manually add the vectors and the text in the right places to give the illusion of a table.

Related

PDFsharp MigraDoc set height of element

Is there a way to set fixed height of an element? Could be a table, row or section. This element is dynamically generated from database and it can have a variable number of rows. I need to do that, because the section below needs to be in a fixed position for print out. I am using WPF v1.31. I know it is not the latest, but it's an addition to a quite old application.
You can set the height of a Paragraph or a table Row.
I think you cannot set the height of a Table - but that will be the sum of the heights of all rows. Automatic page breaks will make things complicated if a table does not fit a single page.
A Section always starts on a new page.
TextFrame can be used to place text at a fixed position. Depending on the requirements, this could be simple or complicated.
You can prepare a document to let MigraDoc determine sizes and positions. Then you code can decide whether the items with the fixed position will be on the same page or on a new page.
Here is sample code that shows how to show the progress while creating a PDF:
http://forum.pdfsharp.net/viewtopic.php?f=8&t=3172
The same technique can be used to stitch several MigraDoc documents together to create a single PDF. If I understand your requirements correctly, this could be the way to go - without setting the height of any elements.

Add Fixed Width file to PDF

I have a client that is asking me to add a fixed width (510 character) header record to a PDF file. They have asked that I create a new page (not problem) in which I write this fixed width header record on.
I can do this, and see the header record as page 1, followed by the original PDF. The problem is white space. The 510 character fixed width header is about 60% white space and all the ways I've tried generating the PDF cause this to be truncated. There are also line breaks where the text wraps. The client want to be able to use some OCR software they have purchased in order to read this header file from page 1.
I know very little about PDF file format. I've tried using ABCpdf, PDFsharp, and also created an RDLC and bound it to this header string and then generated a PDF from that. All 3 resulted in the same outcome.
Let me say I know how crazy this sounds, but it's what a client is requesting. I proposed several other ways in which we could solve their problem, but this (right now) is the only one they are comfortable with. They are not comfortable with me just appending the 510 characters onto the byte array, and having them separate it out programatically.
Are you looking to have a page displaying the long header? You can create a PDF page of any size (Print to PDF with a custom pages size of 20" wide by 6" tall. Weird but possible.)
Once that page is created, it can be inserted into another document of regular letter size pages.
Are you looking for consecutive pages displaying chunks of the header?
Using an OCR to read content that you put in is an overkill. Instead of rendering the 500-character header as text. Render it as single-character form fields. This way it will be easy to access those form-fields by name and retrieve the values using the same PDF library which you created the PDFs.

MigraDoc Columns not wrapping to new page

I'm producing a PDF Export document for a project i'm working on using MigraDoc; the document can contain many rows spans multiple pages, the document can have a user specified number of columns also, this is where i'm having an issue if there are more columns than can fit onto the page it just gets cut off; what i'm after achieving is to get it to wrap round to a new page.
The current implementation of MigraDoc cannot split tables vertically. All columns have to fit on one page or they will be cut off.
For use with PDF files, you can increase the width of the page in order to get all columns. Could this be a solution?

How to print a table of generated images in C#

I need to print a set of generated images in a table like structure with headings. These heading and images are never displayed on the screen. The images are generate QR codes for a series of URLS so they can easier be read in by a scanner. There need to be a header on each column and a text id field on each row but apart from that the rows would be 4-6 columns of QR codes (2d barcode).
I have found samples for printing images and samples for printing text and even a sample to print a datagrid shown on the screen but nothing for printing text and images in a table like structure. Could anyone help me out with a basic example. The table is expected to go over multiple pages vertically so I would also need to put the heading row on each page.
Even pointing me in the right direction would be useful.
This is for a windows application where I want to have code kick off a print job with no user interaction. Using dotnet 4.0.
See my method for creating and printing FixedDocument here including source code. This method will easily allow you to generate aligned tables with images and text and save them as XPS or print them to a printer.

Dynamically add image to powerpoint openxml

I am creating power point 2007 files using the openxml. I am able to add slides, shapes, text and manipulate them to create custom reports. However, I can not find an example on how to dynamically load an image into my power points. In principle I imagine that it would involve adding the image as a resource and then adding a reference to that resource. Any example code would be great help.
Thank you.
You will first need to add an ImagePart to your SlidePart like this:
ImagePart imagePart = slidePart.AddImagePart(ImagePartType.Png, "rId3");
The "rId3" needs to be the relationshipId that corresponds to your image that you are adding to the presentation. You could also leave that parameter blank and a default relationship id will be created for you. Next you need to feed that image part the actual image:
imagePart.FeedData(new MemoryStream(photo.ToArray()));
If you are still having trouble take a look at these two blog posts. They both show some code mid way down about adding photos to a presentation.
Creating a report presentation based on data
Adding repeating data to PowerPoint

Categories