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!
Convert Text Reports to PDFs |
Post Reply |
Author | |
jabaltie
Senior Member Joined: 08 Nov 05 Location: Brazil Status: Offline Points: 138 |
Post Options
Thanks(0)
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 ! |
|
swb1
Debenu Quick PDF Library Expert Joined: 05 Dec 05 Location: United States Status: Offline Points: 100 |
Post Options
Thanks(0)
|
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 sb Edited by swb1 |
|
jabaltie
Senior Member Joined: 08 Nov 05 Location: Brazil Status: Offline Points: 138 |
Post Options
Thanks(0)
|
It could be in Delphi anyway.
All I need is some sort of kick-start code. Thank you for your help ! |
|
swb1
Debenu Quick PDF Library Expert Joined: 05 Dec 05 Location: United States Status: Offline Points: 100 |
Post Options
Thanks(0)
|
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; |
|
Post Reply | |
Tweet
|
Forum Jump | Forum Permissions You cannot post new topics in this forum You cannot reply to topics in this forum You cannot delete your posts in this forum You cannot edit your posts in this forum You cannot create polls in this forum You cannot vote in polls in this forum |
Copyright © 2017 Debenu. Debenu Quick PDF Library is a PDF SDK. All rights reserved. About — Contact — Blog — Support — Online Store