It is currently Fri Jan 24, 2020 2:21 am

All times are UTC + 1 hour




Post new topic Reply to topic  [ 19 posts ]  Go to page 1, 2  Next
Author Message
 Post subject: CD Print And Preview
PostPosted: Sat Feb 04, 2017 8:27 am 
Offline
Addict
Addict

Joined: Fri Aug 28, 2015 6:10 pm
Posts: 1050
Location: Portugal
Hi All

After learning a little more about PB and printing decided to recreate the print and preview module.

I needed a couple of things.

1. The ability to print in landscape and\or portrait depending on what I wish to print and whatever the user selects from the print requester on a page by page basis.

2. The ability to print whatever on whatever the user selected.

3. To give the user the ability to choose which pages to print after a preview or not.

This new module is based on the printrequester() and after selection the printer information is stored and is available in the main programme.

New pages are added as required with a flag to indicate the required orientation of the printed page.

Vector drawing commands are used throughout to do the actual printing to maintain quality.

This works by creating a Printjob directory and file, then each command used to print is stored in the file. After all print operations are complete the user is shown a preview of the print if selected when opening the print job. On the preview window is a Print button. Clicking this displays the Print Which pages dialog where All pages can be selected or a range entered or a list of individual pages can be entered. Clicking the Ok button will then print the selected pages.

Opening a print job with no preview does exactly the same but no preview window is displayed and the module runs straight into the print which pages dialog.

The test programme in cluded simply prints three pages. Page 1 a box and a line, Page 2 some text and Page 3 an image. To test run the programme select your printer and print. Whichever orientation you choose on the printer the output will be the same this is deliberate. The chosen orientation is only used for the preview window and shows how the pages will be printed.

All native Purebasic commands used throughout just need a little help getting the printer info for all operating systems, Windows is done.

The code and test programme can be found here:-https://github.com/collectordave/PureBasic-Print-And-Preview

If anyone can test and suggest improvements at this stage I will be gratefull.

I will be adding more commands as I go along and develop some little test programmes such as printing a text file, grids or photos.

Update: 6 Feb 2017

Courtesy of infratec there is now a single file which holds the module and a simple test programme so rather than visiting github to download it all you can download the single file from dropbox herehttps://www.dropbox.com/s/m42wkcmk0s7o3rl/CDPrint%20Tester.pb?dl=0

Update: 10 Feb 2017

In some circumstances printing images could get a little confused depedant on the calling programme. All image printing routines now updated.

Small PDF manual now part of the download. Also available here :- https://www.dropbox.com/s/b3lbilsp10fd5ob/CDPrint.pdf?dl=0 If anyone can offer suggestions for improvement they will be gratefully recieved.

Kind Regards

cd

_________________
Any intelligent fool can make things bigger and more complex. It takes a touch of genius — and a lot of courage to move in the opposite direction.


Last edited by collectordave on Fri Feb 10, 2017 7:16 am, edited 2 times in total.

Top
 Profile  
Reply with quote  
 Post subject: Re: CD Print And Preview
PostPosted: Sat Feb 04, 2017 2:06 pm 
Offline
Addict
Addict

Joined: Sun Sep 07, 2008 12:45 pm
Posts: 4492
Location: Germany
Hi,

why you don't use the posibility to hold the sqlite database in memory :?:

Code:
DB = OpenDatabase(#PB_Any, ":memory:", "", "", #PB_Database_SQLite)


It's faster, you don't have to delete or check for the file ...

After CloseDatabase() everything is released.

Bernd


Top
 Profile  
Reply with quote  
 Post subject: Re: CD Print And Preview
PostPosted: Sat Feb 04, 2017 2:19 pm 
Offline
Addict
Addict

Joined: Fri Aug 28, 2015 6:10 pm
Posts: 1050
Location: Portugal
Hi infratec

Honestly did not think about holding it in memory, however i am also looking at the possibility of sceheduled printing to allow a document to be printed at one time to be sent to the printer later. However I will add the memory database now.

Could have another switch in place if the user wants to schedule a print operation. Like the idea of memory though easier on the programming skills.

Thanks for the suggestion and code.

Regards

cd

_________________
Any intelligent fool can make things bigger and more complex. It takes a touch of genius — and a lot of courage to move in the opposite direction.


Top
 Profile  
Reply with quote  
 Post subject: Re: CD Print And Preview
PostPosted: Sat Feb 04, 2017 2:32 pm 
Offline
Addict
Addict

Joined: Fri Aug 28, 2015 6:10 pm
Posts: 1050
Location: Portugal
Hi All

Code updated with infratec's suggestion above same link as above.

Seems to work one heck of a lot faster!

Regards

cd

_________________
Any intelligent fool can make things bigger and more complex. It takes a touch of genius — and a lot of courage to move in the opposite direction.


Top
 Profile  
Reply with quote  
 Post subject: Re: CD Print And Preview
PostPosted: Sat Feb 04, 2017 3:19 pm 
Offline
Addict
Addict

Joined: Sun Sep 07, 2008 12:45 pm
Posts: 4492
Location: Germany
Hm....

with SQLite you have the chance to write it simply to disk.

http://www.forums.purebasic.com/english ... p?p=368143

But after I look a bit deeper in the code...
why you didn't use 2 lists and/or maps?
Maybe a map with the pagenumber as key and the page data in a structure plus a list inside with the content.
So it's possible to search for the page and then run through the content.

This would reduce the exe size by 250kb.
Ok, a bit old school to try to keep the code small.

I think this would be even more faster then the DB in memory.

But that's only an idea.

Bernd


Top
 Profile  
Reply with quote  
 Post subject: Re: CD Print And Preview
PostPosted: Sat Feb 04, 2017 4:18 pm 
Offline
Addict
Addict

Joined: Sun Sep 07, 2008 12:45 pm
Posts: 4492
Location: Germany
Hi,

you can comment out line 572-574 in CDPrint.pbi

But .... you'll run into trouble:

You ignored the golden rule: only one eventloop per program.
Sooner or later you'll run into big problems.

Try to use the bind stuff to eliminate the eventloop in ShowPreview.

Bernd


Top
 Profile  
Reply with quote  
 Post subject: Re: CD Print And Preview
PostPosted: Sun Feb 05, 2017 7:57 am 
Offline
Addict
Addict

Joined: Fri Aug 28, 2015 6:10 pm
Posts: 1050
Location: Portugal
Hi All

Just a little news.

All infratec's improvements have now been included. Thanks to infratec for just about reprogramming the whole thing. Not in the link yet as I wish to give infratec credit in the code header etc so once infratec approves I will update github and post here.

Thanks for your improvements infratec! 8)

Also added print and preview to the photoDB here http://www.purebasic.fr/english/viewtopic.php?f=27&t=67375 again not updated on github but will do ASAP. This only took about fifteen minutes!

Kind Regards To All

cd

_________________
Any intelligent fool can make things bigger and more complex. It takes a touch of genius — and a lot of courage to move in the opposite direction.


Top
 Profile  
Reply with quote  
 Post subject: Re: CD Print And Preview
PostPosted: Sun Feb 05, 2017 4:42 pm 
Offline
Addict
Addict

Joined: Fri Aug 28, 2015 6:10 pm
Posts: 1050
Location: Portugal
Lots more improvements courtesy of infratec all included no database now, all in memory printimagefromfile() added and print canvas(). Colour now supported as well.

Both new procedures included in test programme.

The main link in the first post now updated.

Only tested on windows 7 so far, so if anybody does download and test please let us know here.

Thanks to infratec

Kind Regards

cd

_________________
Any intelligent fool can make things bigger and more complex. It takes a touch of genius — and a lot of courage to move in the opposite direction.


Top
 Profile  
Reply with quote  
 Post subject: Re: CD Print And Preview
PostPosted: Sun Feb 05, 2017 5:49 pm 
Offline
Addict
Addict

Joined: Fri Aug 28, 2015 6:10 pm
Posts: 1050
Location: Portugal
Print functionality added to two apps;

Basic text editor here http://www.purebasic.fr/english/posting.php?mode=reply&f=22&t=66577

and the photo database available here http://www.purebasic.fr/english/viewtopic.php?f=27&t=67375

Both using the CDPrint module. Should be good examples of usage.

I am still printerless so if anyone can download and test these then please let me know how you get on.

Kind Regards

cd

_________________
Any intelligent fool can make things bigger and more complex. It takes a touch of genius — and a lot of courage to move in the opposite direction.


Top
 Profile  
Reply with quote  
 Post subject: Re: CD Print And Preview
PostPosted: Sun Feb 05, 2017 6:18 pm 
Offline
Addict
Addict
User avatar

Joined: Thu Jun 04, 2015 7:10 am
Posts: 1673
collectordave wrote:
I am still printerless so if anyone can download and test these then please let me know how you get on.
you can get printer drivers that print to image files like bmp instead of physical printer, but i dont know any offhand so your google is as good as mine

_________________
Thankyou to all the coders who generously helped & encouraged me in the nearly 2yrs when i was welcome here,
it was a tremendous privilege. I learned a lot. I wish you and your families all the best and success for the future.


Top
 Profile  
Reply with quote  
 Post subject: Re: CD Print And Preview
PostPosted: Mon Feb 06, 2017 8:32 am 
Offline
Addict
Addict

Joined: Fri Aug 28, 2015 6:10 pm
Posts: 1050
Location: Portugal
Thanks keya.

Had one responce that it works ok to FreePDF on windows 10. So will look further into this and find one until I achieve the ability to print again.

Thanks again

Regards

cd

_________________
Any intelligent fool can make things bigger and more complex. It takes a touch of genius — and a lot of courage to move in the opposite direction.


Top
 Profile  
Reply with quote  
 Post subject: Re: CD Print And Preview
PostPosted: Mon Feb 06, 2017 9:10 am 
Offline
Addict
Addict
User avatar

Joined: Thu Jun 04, 2015 7:10 am
Posts: 1673
let us know if you find a good one! wouldn't mind saving some A4 myself hehe. its just a lot quicker for testing too

_________________
Thankyou to all the coders who generously helped & encouraged me in the nearly 2yrs when i was welcome here,
it was a tremendous privilege. I learned a lot. I wish you and your families all the best and success for the future.


Top
 Profile  
Reply with quote  
 Post subject: Re: CD Print And Preview
PostPosted: Mon Feb 06, 2017 9:25 am 
Offline
PureBasic Protozoa
PureBasic Protozoa
User avatar

Joined: Fri Apr 25, 2003 3:08 pm
Posts: 4521
Location: Not Sydney!!! (Bad water, no goats)
I'm using Foxit PDF reader/printer rather than wasting paper. So far, I have generated 58 documents adjusting the printing for one project. Could not have afforded to waste that much in real paper!

_________________
Amateur Radio, D-STAR/VK3HAF


Top
 Profile  
Reply with quote  
 Post subject: Re: CD Print And Preview
PostPosted: Mon Feb 06, 2017 9:34 am 
Offline
Addict
Addict
User avatar

Joined: Thu Jun 04, 2015 7:10 am
Posts: 1673
Fangbeast wrote:
Could not have afforded to waste that much in real paper!
ink's a bit of a ripoff too :P

_________________
Thankyou to all the coders who generously helped & encouraged me in the nearly 2yrs when i was welcome here,
it was a tremendous privilege. I learned a lot. I wish you and your families all the best and success for the future.


Top
 Profile  
Reply with quote  
 Post subject: Re: CD Print And Preview
PostPosted: Mon Feb 06, 2017 10:03 am 
Offline
Addict
Addict
User avatar

Joined: Sat Feb 19, 2011 3:47 am
Posts: 2216
Location: Singapore
Keya wrote:
Fangbeast wrote:
ink's a bit of a ripoff too :P

For the times when we do need hardcopy testing, get a cheap, or even second hand inkjet, and stock up on third-party refills. Big savings. :wink:

_________________
Texas Instruments TI-99/4A Home Computer: the first home computer with a 16bit processor, crammed into an 8bit architecture. Great hardware - Poor design - Wonderful BASIC engine. And it could talk too!


Top
 Profile  
Reply with quote  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 19 posts ]  Go to page 1, 2  Next

All times are UTC + 1 hour


Who is online

Users browsing this forum: No registered users and 31 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
Jump to:  

 


Powered by phpBB © 2008 phpBB Group
subSilver+ theme by Canver Software, sponsor Sanal Modifiye