COBOL reports converting to PDF - Form Feed issue

I have a need to convert  COBOL-produced text-based reports into PDF format.  The Form Feed character results from “AFTER ADVANCING PAGE” in the COBOL code and causes superfluous blank pages in the PDF output.  Is there a pattern to follow for producing  reports in Visual COBOL that are destined for conversion to PDF?  (using Visual COBOL 5.0 Eclipse).

Tags:

  • I think that this is more an issue with the tool that is converting the text file to PDF.

    What tool are you using?

    By default, Visual COBOL print files use a CRLF (X"0D0A) for line spacing on Windows and LF (X"0A") on Linux/Unix systems. The only other character used for positioning is the FF (X"0C"). 

    Perhaps somebody with more experience with this conversion process can chime in here to recommend a tool?

     

  • Thx for the reply  .  We're hoping to  store COBOL output in Hyland's OnBase Product.  A straight import of the COBOL-produced report text file into OnBase resulted in the report having a leading blank page, believed due to the FF character.  A similar PDF conversion attempt with Apache's PDFBox yielded the same result.  It looks like we can tweak the PDFBox settings/code to replace the FF character during conversion. We can, also, consider changing the COBOL that produces the reports to replace "AFTER ADVANCING PAGE” but there are 100 reports that would need to change.  I just wondered if there was a better solution to the problem.

  • I use List&Label 25 from combit.net for all graphical print documents and here it is possible to give the ouptut on Screen or save in different Format (also pdf) or send fax or mail, etc.
    There are also any Cobol examples to convert an document into pdf, also valid for netexpress as for vc.
  • Hi StompinBob,

    Rather than having to change your existing code to remove the form feeds an alternative could be to have a separate program to do it. Here is a very simple managed COBOL program which uses .NET methods to remove formfeeds from a file.

    $set ilusing "System.IO" $set ilusing "System.Text.RegularExpressions". program-id. Program1 as "fftest.Program1". data division. working-storage section. 01 cmdline pic x(255). procedure division. accept cmdline from command-line *> Get the filename if cmdline not = spaces declare fileName as string = cmdline set fileName to fileName::TrimEnd() *> Remove any trailing spaces if type File::Exists(fileName) declare inputText as string = type File::ReadAllText(fileName) *> Read content into a string declare outputText as string = type Regex::Replace(inputText, x"0c", type String::Empty) *> Remove formfeeds invoke type File::WriteAllText(fileName, outputText) *> Write the updated content end-if end-if goback. end program Program1.

     

  • Did you try to send your final pdf file to PDFSplit from Apache PDFBox ?

    If you use

    PDFSplit -startPage 2 my_report.pdf

    It will provide a new pdf containing all pages of the source pdf starting at page 2. The blank page in first position has gone.

  • From what you've been describing I suppose that the output to PDF works as expected.

    You need to consider that a FORM FEED character usually is not displayed by text editors ‒ because there simply is no form to feed. So, what you see in the PDF is actually exactly what you have programmed it to be. Quote:

    "resulted in the report having a leading blank page, believed due to the FF character"
    "COBOL that produces the reports to replace 'AFTER ADVANCING PAGE'"

    I guess your expectations may have been mislead by looking at the preliminary text output using a text editor that's discarding the FORM FEED character or displaying it in a different way:

    Form Feed.png