PDF Line

Discussion about printing issues and techniques.

Moderators: Susan Smith, admin, Gabriel

Post Reply
John
Posts: 555
Joined: Sun Apr 26, 2009 8:27 am

PDF Line

Post by John »

What is the best and/or simplest way to draw a line on a PDF? Ideally, I'll make myself a function that accepts X, Y, length, height, box_instead_of_line - or something like that. I've looked at PDF.sys but it sure isn't jumping out at me.
John Bowman
Gabriel
Posts: 412
Joined: Sun Aug 10, 2008 7:37 am
Location: Arlington, TX
Contact:

Re: PDF Line

Post by Gabriel »

What is PDF.sys?

Are you using BR's built in ability to print pdfs, where you print using NWP commands and specify a PDF file as the printer?

Or are you using the PDF overlay stuff, printing a line on a preexisting PDF?

Gabriel
John
Posts: 555
Joined: Sun Apr 26, 2009 8:27 am

Re: PDF Line

Post by John »

PDF.sys is an NWP component for PSF printing - it contains a good bit of syntax that is useful for me. I am using BR's native PDF creation stuff (PDF Printer). And yes, in some cases I am using PDFs as a background image, but that's already working for me. I'm hoping to just draw a few lines and change some fonts and font sizes and make another instance of it other than w-2s.
John Bowman
Gabriel
Posts: 412
Joined: Sun Aug 10, 2008 7:37 am
Location: Arlington, TX
Contact:

Re: PDF Line

Post by Gabriel »

If you're using NWP then your question is about NWP.

In other words, just print an NWP line. You can do that easily enough using the Boxing features.

If you want a line that isn't horizontal nor vertical, then you'll have to use an image. But if its straight horizontal or straight vertical its very easy to do using NWP syntax for Boxing.

Also, don't forget about [PUSH] and [POP] ... those will help you save the printers cursor position before drawing your line so you can continue where you left off.

Gabriel
John
Posts: 555
Joined: Sun Apr 26, 2009 8:27 am

Re: PDF Line

Post by John »

I am not using NWP. I was using that file for reference. I am sending escape sequences directly from my code to an open #x:name=pdf: file. I was just wondering if anyone had a command to draw a line at X and Y coordinates on a PDF made in BR.
John Bowman
Gabriel
Posts: 412
Joined: Sun Aug 10, 2008 7:37 am
Location: Arlington, TX
Contact:

Re: PDF Line

Post by Gabriel »

I'm guessing you mean you're not using "printer.sys" which is different from NWP.

When I said NWP i was referring to the language that BR uses internally to turn your esc sequences into images. Even if you're not using Printer.sys, the BR PDF generating facility ALWAYS uses/understands NWP commands.

So, without printer.sys, the commands you want to use to make a horizontal line (example 80 characters wide), would be as follows:

Code: Select all

PRINT #255: Chr$(27)&"begin_boxtop"&rpt$(" ",80)&chr$(27)&"end_box"
With printer.sys, the commands would change to this:

Code: Select all

PRINT #255: "[BOXTOP]"&rpt$(" ",80)&"[/BOX]"
In other words, printer.sys saves you from having to specify Chr$(27) but otherwise, it doesn't do much. Under PDF and NWP, the Escape Sequence codes are identical to PCL whenever possible, and they're in english whenever it wasn't possible to match PCL syntax.

gabriel
John
Posts: 555
Joined: Sun Apr 26, 2009 8:27 am

Re: PDF Line

Post by John »

great! I've combined that with the decipos stuff and got what I need for horizontal lines.

How do I draw a vertical line? I'm guessing something like

PRINT #255: Chr$(27)&"begin_boxvertical"&rpt$(" ",80)&chr$(27)&"end_box"

repeatedly moveing down a little for each increase in length but it isn't working. Got a quick tip for me on vertical lines too?
John Bowman
Gabriel
Posts: 412
Joined: Sun Aug 10, 2008 7:37 am
Location: Arlington, TX
Contact:

Re: PDF Line

Post by Gabriel »

For Vertical lines, you turn "boxsides" on like you did (although the syntax is "begin_verticals", not boxverticals), but then you specify the position of the lines with | signs.

To make a vertical line 10 chars from the left, and 4 rows tall you would do like this:

Code: Select all

PRINT #255, using "Form C,Skip 0" : Chr$(27)&"begin_verticals"
PRINT #255: rpt$(" ",10)&"|"
PRINT #255: rpt$(" ",10)&"|"
PRINT #255: rpt$(" ",10)&"|"
PRINT #255: rpt$(" ",10)&"|"&chr$(27)&"end_box"
You can use Push and Pop (

Code: Select all

Chr$(27)&"&f0S" ! Push
Chr$(27)&"&f1S" ! Pop 
) to preserve the cursor position as you draw multiple lines. You can also draw both horizontal and vertical lines at the same time by combining various boxing methods and | symbols. And you can make boxes with a shaded background, including one of any color.

It is primarily designed for drawing tables, for example, around line items on an invoice, or boxes around a shipping address to make it stand out. So its pretty easy to use when you want to draw boxes around words. In fact, its easier then a "line drawing function" would be. But its not specifically designed for drawing arbitrary lines on a page, as you can see. For arbitrary lines, a "line drawing function" would be better.

Gabriel
John
Posts: 555
Joined: Sun Apr 26, 2009 8:27 am

Re: PDF Line

Post by John »

I'm trying this code:

Code: Select all

15000   open #255: 'Name=PDF:,PrintFile=test.pdf,Replace,RecL=5000',display,output 
16520   print #255, using "Form C,Skip 0" : chr$(27)&"begin_verticals"
16540   print #255: rpt$(" ",10)&"|"
16560   print #255: rpt$(" ",10)&"|"
16580   print #255: rpt$(" ",10)&"|"
16600   print #255: rpt$(" ",10)&"|"&chr$(27)&"end_box"
17800   print #255: ''
17900   close #255: 
17940   execute 'sy -C test.pdf'
but which is basically what you said above (unless I messed it up) but I get an error 6254 :!: ( http://brwiki2.brulescorp.com/index.php?title=6254 )

Any ideas :?:
John Bowman
bluesfannoz
Posts: 291
Joined: Fri Jun 19, 2009 9:01 am
Location: Lawrence, Kansas
Contact:

Re: PDF Line

Post by bluesfannoz »

You have test.pdf open in another application, so it cannot create another copy of it.
Steve Koger
Computer Specialist
SEKESC-MACS Division
John
Posts: 555
Joined: Sun Apr 26, 2009 8:27 am

Re: PDF Line

Post by John »

:oops: oh dear - yep. :oops: :roll:
John Bowman
Post Reply