I just found MigraDoc and PdfSharp this morning and am grateful such sw exist. I have a list of files that I am parsing through and adding to a PDF. When I add an existing pdf, it only displays the first page of the imported PDF, and adds margins, etc so what is displayed is way off center and missing half of the page that is displayed. I know I'm missing a few things but cannot find what I need, so I thought I would ask directly.
Code:
Document doc = new Document();
foreach (string path in archives)
{
string r = GetFileExtension(path);
Section sec = doc.AddSection();
Paragraph para = sec.AddParagraph();
switch (r)
{
case "txt":
case "css":
TextReader sr = new StreamReader(path);
string _fileString = sr.ReadToEnd();
sr.Close();
sr.Dispose();
para.AddText(_fileString);
break;
case "png":
case "pdf":
sec.AddImage(path);
break;
...
PdfDocumentRenderer pdfRenderer = new PdfDocumentRenderer(false, PdfFontEmbedding.Always);
pdfRenderer.Document = doc;
pdfRenderer.RenderDocument();
pdfRenderer.PdfDocument.Save(fullFileName);
Again, this code "kinda" works, but not really. I also decided to go with MigraDoc after running into issues with importing text files being clipped after one page. MigraDoc handled that beautifully.
Please advise and thanx in advance.
I was also just informed the PDF's to merge may contain special fields, so I wonder id adding them as images will work, if not, what is the alternative to combining pdf and images and text?