Do you own a Debenu Quick PDF Library version 7, 8, 9, 10, 11, 12, 13 or iSEDQuickPDF license? Upgrade to Debenu Quick PDF Library 14 today!

Debenu Quick PDF Library - PDF SDK Community Forum Homepage
Forum Home Forum Home > For Users of the Library > General Discussion
  New Posts New Posts RSS Feed - Convert Text Reports to PDFs
  FAQ FAQ  Forum Search   Register Register  Login Login

Convert Text Reports to PDFs

 Post Reply Post Reply
Author
Message
jabaltie View Drop Down
Senior Member
Senior Member
Avatar

Joined: 08 Nov 05
Location: Brazil
Status: Offline
Points: 138
Post Options Post Options   Thanks (0) Thanks(0)   Quote jabaltie Quote  Post ReplyReply Direct Link To This Post Topic: Convert Text Reports to PDFs
    Posted: 25 Apr 06 at 8:12AM
We have here on our installation a whole constelation of Reports which are generated by a Unisys mainframe.

These reports are typically text files, whith these characteristics :

- Lines are separated by CRLF pairs (chr 13/10)
- Pages are separated by a FF (chr 12)
- Lines usually have 80 or 132 characters
- Pages typically have 66 or 88 lines
- They're printed using fixed width font size
- Reports have usually 100 pages, so conversion perfomance is not a problem, at first

My plan is to build a conversion tool, to stuff or wrap those reports onto PDF files, and then, ask my users not to print them anymore. Instead, they should convert their reports to PDF (using this tool) and save the PDF files.

Only when needed, they would print the report from the PDF file.

The report is already available on a plain text file. Although it was generated on a mainframe, it has been downloaded to a text file.

It's also available, that is, I know BEFORE converting :

- The number of characters per line (80 or 132)
- The maximum number of lines on a page (66 or 88)
- The total number of pages

So, finally :

Would someone help me out with a scheleton of a VBScript for this conversion tool ?

Other features I have in mind are :

- At first, I would not care about bookmarks but, adding a bookmark for each page could be a good idea
- Some special reports are intended to be printed on special paper. For instance papers who have a logotype already printed. So, another good idea would be to "merge" the report on a "background paper", that is, put the page "over" an image (of the paper).

After all,

Thank you !
Back to Top
swb1 View Drop Down
Debenu Quick PDF Library Expert
Debenu Quick PDF Library Expert
Avatar

Joined: 05 Dec 05
Location: United States
Status: Offline
Points: 100
Post Options Post Options   Thanks (0) Thanks(0)   Quote swb1 Quote  Post ReplyReply Direct Link To This Post Posted: 25 Apr 06 at 9:53AM

I am currently doing something like this. I start with a blank 8½ x 11 PDFas a template. I load the logo then I draw the text. Page breaks are determined by line count or CHR(12) - which ever comes first. You will need to experiment a little with font and line height. When the page is full, use NewPage to begin the next page then load the logo and text and so on.

 

I could supply some sample source however it would be Delphi as I don’t speak fluent VB.

 

sb



Edited by swb1
Back to Top
jabaltie View Drop Down
Senior Member
Senior Member
Avatar

Joined: 08 Nov 05
Location: Brazil
Status: Offline
Points: 138
Post Options Post Options   Thanks (0) Thanks(0)   Quote jabaltie Quote  Post ReplyReply Direct Link To This Post Posted: 25 Apr 06 at 10:15AM
It could be in Delphi anyway.

All I need is some sort of kick-start code.

Thank you for your help !
Back to Top
swb1 View Drop Down
Debenu Quick PDF Library Expert
Debenu Quick PDF Library Expert
Avatar

Joined: 05 Dec 05
Location: United States
Status: Offline
Points: 100
Post Options Post Options   Thanks (0) Thanks(0)   Quote swb1 Quote  Post ReplyReply Direct Link To This Post Posted: 25 Apr 06 at 10:58AM

This should get you started:

 

procedure TForm1.btnOverlayTextClick(Sender: TObject);

var   sl : TStringList;

      LogoName, pdfName, TextName, OutputName : string;

      i, LineIndex, ImageID : integer;

const

      MAX_LINES = 66;

      LINE_HEIGHT =15;

begin

 

      TextName := ExtractFilePath(Application.ExeName) + 'SampleInvoice.txt';

      pdfName := ExtractFilePath(Application.ExeName) + 'EmptyPage.pdf';

      LogoName := ExtractFilePath(Application.ExeName) + 'logo.jpg';

      OutputName := ExtractFilePath(Application.ExeName) + 'Output.pdf';

 

 

      if (FileExists(pdfName) and FileExists(TextName) and FileExists(LogoName) ) then

            begin

                  try

                  sl := TStringList.Create;

                  sl.LoadFromFile(TextName);

                  qPDF := TiSEDQuickPDF.Create;

                  qPDF.UnlockKey( MY_QDPF_KEY );

                  qPDF.LoadFromFile( pdfName );

                  ImageID := qPDF.AddImageFromFile( LogoName,0 );

                  qPDF.SetOrigin(1); // upper Left

 

                  Lineindex := 0;

                  for i := 0 to sl.Count -1 do

                        begin

                        if LineIndex = 0 then

                              begin

                              qPDF.SelectImage( ImageID );

                              qPDF.DrawImage(10,5,150,100);

                              end;

                        qPDF.DrawText(10, LineIndex  * LINE_HEIGHT, sl[LineIndex]);

                        if (pos(#12,sl[LineIndex]) > 0) or (LineIndex >= MAX_LINES) then

                              begin

                              if LineIndex < (sl.Count - 1) then

                                    qPDF.SelectPage(qPDF.NewPage);

                              LineIndex := 0;

                              end

                        else begin

                              LineIndex := Lineindex + 1;

                              end;

                        end;

                  qPdf.SaveToFile(OutputName);

                  finally

                        qPDF.Free;

                        sl.Free;

                  end;

            end;

 

end;

Back to Top
 Post Reply Post Reply
  Share Topic   

Forum Jump Forum Permissions View Drop Down

Forum Software by Web Wiz Forums® version 11.01
Copyright ©2001-2014 Web Wiz Ltd.

Copyright © 2017 Debenu. Debenu Quick PDF Library is a PDF SDK. All rights reserved. About — Contact — Blog — Support — Online Store