I need to take one or more files(.txt or .csv format only), convert them, one at a time and sent them to the printer in PostScript format.

The paper will be pre-printed and of A4 size. It is perforated in the middle(Portrait orientation).

For example, taking a file, A.txt, I would need to print it's content starting from the top of the A4 sheet. If the content of the .txt file is more than can fit in the top half (i.e above the perforation) it needs to be ignored. The same content needs to be printed again below the perforation.

What is the best way of doing this?

From my research of this article http://www.adobe.com/print/features/psvspdf/ , it appears that I can make use of PDF format, if PostScript isn't feasible.

If the above is true I might be able to use the code provided here http://www.codeproject.com/Articles/12266/Convert-a-Text-File-to-a-PDF-File for the conversion. But there is no way to divide the page into 2.

Another approach is to create 2 pages of A5(It's half of A4)size and then merge them to an A4 size.

I would like to do this in the fastest and cheapest way.


4 Years
Discussion Span
Last Post by NanaYee


This is my method to convert .TXT to .PDF.

            string text = File.ReadAllText(@"E:\Sample.txt");

            //Create PDF Template
            PdfDocument document = new PdfDocument();
            PdfSection section = document.Sections.Add(); ;
            PdfPageBase page = section.Pages.Add();
            PdfFont font = new PdfFont(PdfFontFamily.Helvetica, 11);
            PdfStringFormat format = new PdfStringFormat();
            format.LineSpacing = 20f;
            float pageWidth = page.Canvas.ClientSize.Width;
            PdfBrush brush = PdfBrushes.Black;
            float y = 30;
            PdfStringLayouter textLayouter = new PdfStringLayouter();
            PdfStringLayoutResult result
                = textLayouter.Layout(text, font,format,new SizeF(pageWidth, 0));

            //Draw String
            foreach (LineInfo line in result.Lines)
                page.Canvas.DrawString(line.Text, font, brush,0, y);
                y = y + result.LineHeight;

            //Save to PDF

If you want to print two pages with A4 size, you can change the PDF template setting to meet your requirement, for example, widening spacing.

I use a .NET PDF component.

Edited by NanaYee

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.