Highlighted
Trusted Contributor.
Trusted Contributor.
244 views

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).

Labels (2)
0 Likes
6 Replies
Highlighted
Micro Focus Expert
Micro Focus Expert

Re: COBOL reports converting to PDF - Form Feed issue

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?

 

0 Likes
Highlighted
Trusted Contributor.
Trusted Contributor.

Re: COBOL reports converting to PDF - Form Feed issue

Thx for the reply @Chris Glazier .  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.

0 Likes
Highlighted
Outstanding Contributor.
Outstanding Contributor.

Betreff: COBOL reports converting to PDF - Form Feed issue

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.
Highlighted
Micro Focus Expert
Micro Focus Expert

Re: COBOL reports converting to PDF - Form Feed issue

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.

 

Highlighted
Respected Contributor.
Respected Contributor.

Re: COBOL reports converting to PDF - Form Feed issue

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.

Highlighted
Super Contributor.
Super Contributor.

Re: COBOL reports converting to PDF - Form Feed issue

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

 

The opinions expressed above are the personal opinions of the authors, not of Micro Focus. By using this site, you accept the Terms of Use and Rules of Participation. Certain versions of content ("Material") accessible here may contain branding from Hewlett-Packard Company (now HP Inc.) and Hewlett Packard Enterprise Company. As of September 1, 2017, the Material is now offered by Micro Focus, a separately owned and operated company. Any reference to the HP and Hewlett Packard Enterprise/HPE marks is historical in nature, and the HP and Hewlett Packard Enterprise/HPE marks are the property of their respective owners.