1. JOHN THOMAS
  2. PowerBuilder
  3. Tuesday, 24 November 2020 22:13 PM UTC

Hi gents - we have a weird problem all of a sudden. Current (old) process:

- read .psr files and set file names to datawindow  .dataobject  property (path + file name)

- go through complicated routine to read the .psr contents, set them up in a datastore, and roll them into a pdf file via loop through datastore (print to pdf using older printer driver).

What we're trying to do now is bypass all that stuff (esp since our old printer driver is dead now) and just print via PB Native pdf and SaveAs(), or some similar easy export from the one datawindow array holding the various psr file pointers. However SaveAs() will not save a datawindow array in one shot. If I just do a SaveAs() on one of the array positions (i.e. a single .dataobject set into datawindow), I get a pdf ok with SaveAs(), it picks up the psr data ok, for one psr.

But trying to loop through datawindow array and print each array position to the same pdf file name (i.e. concatenate the psr's into a the single pdf) doesn't fly, it just overwrites the previous array position "print" and you end up with only the final position in the pdf. 

Any magic solutions to this scenario? Thanks in advance, we're stuck!

JOHN THOMAS Accepted Answer Pending Moderation
  1. Wednesday, 13 January 2021 14:52 PM UTC
  2. PowerBuilder
  3. # 1

As I started this whole pile of discussion I would like to add yet another and I believe final record of "total solution" to this pdf printing / orientation problem. In spite of my earlier attempts with other printer-drivers, all of them had something they wouldn't quite do, mostly in the orientation/auto-rotate area. I have since worked out the total solution for use in Powerbuilder in combo with Adobe Acrobat XI Standard. Since this was such a godawful pain to work out I thought I'd share it in case anyone ever needs to do the same thing. It is possible that CutePDF or others have some magic combination of registry keys / settings to enable all this "just right" but I haven't found any (NitroPDF definitely doesn't, they've told me so) except Acrobat XI.  See attached for what was the Final Solution!  And thanks for all the help. 

Attachments (1)
Comment
There are no comments made yet.
JOHN THOMAS Accepted Answer Pending Moderation
  1. Thursday, 10 December 2020 18:51 PM UTC
  2. PowerBuilder
  3. # 2

I wanted to add one last piece of info on this in case anyone else has to do the same setup with CutePDF. Not having the below setting correct drove us crazy as the app would not stop throwing up the SaveAs window no matter if the BypassSaveas=1 reg key was set. On top of that, it would work ok in source/IDE, but the builds would hang. Very important!  (you also need Ghostscript set up with CutePDF, per their instructions).

 

Go to Control Panel -> Device and Printers, right click on CutePDF writer and select "Printer Properties".
In Advanced tab, select "Print directly to the printer” instead of "Spool print document so program finishes printing faster".

Comment
  1. Armeen Mazda @Appeon
  2. Thursday, 10 December 2020 19:05 PM UTC
Thanks for sharing!
  1. Helpful
There are no comments made yet.
JOHN THOMAS Accepted Answer Pending Moderation
  1. Monday, 7 December 2020 19:56 PM UTC
  2. PowerBuilder
  3. # 3

Never mind on the last question gents, logos showed up somehow, it's all magic. Thanks and we can call this thread closed.

Comment
  1. Chris Pollach @Appeon
  2. Monday, 7 December 2020 20:53 PM UTC
That's awesome news John. Yes, CutePDF is another great product. I've used that one before with great results!
  1. Helpful
There are no comments made yet.
JOHN THOMAS Accepted Answer Pending Moderation
  1. Monday, 7 December 2020 19:36 PM UTC
  2. PowerBuilder
  3. # 4

Chris & All - FYI's I have handled the problem on this. CutePDF seems to be the magic pdf utility/driver, works just great if you add the "BypassSaveas" reg key like they instruct, and then the PrintOpen(), PrintDatawindow(), PrintClose().

So that's that. I do have one more Q though:  I am trying to get a .jpg logo to load to a psr that refuses to show up when viewing (or trying to spool to a pdf, as per above stuff) the psr. This logo is loaded via an embedded datawindow+stored proc. It loads just fine in an outer dw, and doing SaveAs Powersoftreport/psr type works fine, all other data loads, including two other embedded-loaded dw's, but the logo refused to (re)load, no matter where I put it. In the psr source I see the logo name clearly, no hardcoded path, just sitting in there by itself. If we could just plop the .jpg on the dw as a control, I'm sure it would show up. But it needs to load via this embedded dw. Thanks! 

Comment
There are no comments made yet.
JOHN THOMAS Accepted Answer Pending Moderation
  1. Friday, 4 December 2020 15:59 PM UTC
  2. PowerBuilder
  3. # 5

Hi again Chris & All - 

I'd like to submit one last question here as a broadcast/request to see if I can get the community's feedback on just what pdf printer/driver anyone is using that will work with the Printopen() command smoothly. As per earlier posts in this thread, I have now tried two different drivers (actually three), all with unsatisfactory performance/interaction with current PB commands:

- "Microsoft Print to PDF" - refuses to suppress print selection popup window on Printopen(), even with TRUE/FALSE argument.

- "Microsoft Print to PDF (redirected)" - does not throw up printer selection popup window; PrintDatawindow() works but sends pdf's relentlessly to the local machine (i.e. pdf's will not land in their dictated folder on network or runtime server...how it gets away with this is beyond me...going completely outside the network to a local machine!). 


- Nitropdf  - our company's standard PDF driver (as opposed to Adobe Acrobat, for vulnerabilities)  - Printopen() intermittently throws up printer selection window but on top of that throws up a spooler window that cannot be suppressed (per their helpdesk) and default filename and path also cannot be altered. .psr files do spool ok into a .pdf via Printdatawindow() / PrintClose() commands as desired, but other quirks nullify this success.


So, any input as to workable pdf printer/drivers that
a) will not continue to throw up printer selection window,
b) will allow pdf to be renamed/placed programmatically or otherwise?   

Thanks much.

Comment
  1. Armeen Mazda @Appeon
  2. Friday, 4 December 2020 16:18 PM UTC
Amyuni is very popular among our customers. It is expensive, but perhaps that is your best shot.
  1. Helpful
  1. Chris Pollach @Appeon
  2. Friday, 4 December 2020 16:34 PM UTC
Hi Armeen ... Unfortunately, the Amyuni product (AFAIK) will not do PDF concatenation - which I believe is what John's App requires. Works great though on Nested and Composite DWO's. However, so does PB's NativePDF feature. From what I have read (maybe I am wrong here) John's App needs a PDF "assembly" feature ( which PB does not have currently ). The other alternative (I think) would be redesign John's App's PDF part to use a Nested or Composite "parent" DWO approach. I am not sure though if that is feasible for John. So he is looking for a quick and easy Postscript to PDF driver product as a quick fix.

Regards ... Chris
  1. Helpful
  1. Armeen Mazda @Appeon
  2. Friday, 4 December 2020 16:52 PM UTC
Hmm... if Amyuni also doesn't solve is problem on top of all the other options he tried, then he might need to be looking at how to redesign his code rather than searing for yet another PDF library.
  1. Helpful
There are no comments made yet.
JOHN THOMAS Accepted Answer Pending Moderation
  1. Monday, 30 November 2020 23:46 PM UTC
  2. PowerBuilder
  3. # 6

Chris - addendum:

- I can get a print job number out of the Nitro if I let it open the printer selection window, choose Nitro, and let it sit there ready to spool, but

- I can get nothing but -1 out of PrintDatawindow() even when using this (valid) job number

Yikes.  

Comment
There are no comments made yet.
JOHN THOMAS Accepted Answer Pending Moderation
  1. Monday, 30 November 2020 23:34 PM UTC
  2. PowerBuilder
  3. # 7

Hi again Chris  - writing with some other attempts here as I'm getting further and further against the wall. I couldn't get any joy out of the Microsoft Print to PDF printer/drivers, so our guy put Nitropdf on the box, which creates a printer named "Nitro PDF Creator".  This is pretty widely used in our shop and elsewhere, not sure if you've used it. But the results are still flaky, as follows:

PrintSetPrinter()  - works, I get a 1 back setting the Nitro printer

PrintOpen()  -  using FALSE, it indeed doesn't open the printer selection window (like the MS PDF printer did, true or false), but I can't get anything but  -1 out of it. Terrible. Can't get by this to get a print job to spool psr's into a pdf, etc. 

My guys are reluctant to use Adobe Acro Pro and I can't make them. I did try the PDFToolkit which does work very well for stitching together existing pdf's, but I gotta get the pdf's first.  Any other clever ideas? I can't get why PB is so picky about this stuff.  Thanks in advance,  jt

Comment
  1. Chris Pollach @Appeon
  2. Tuesday, 1 December 2020 15:34 PM UTC
Hi John;

Yes, I have found for a long time that the PDF Toolkit utility to be the way to go if you cannot use either a Composite or Nested DWO to do the entire PDF rendering job.

I am not sure why you cannot get the individual PDF file names though since you are going through a Loop. Thus for example DWO1.pbf, DWO2.pdf ... DWO99.pdf and then sticth them together based on the Loop count.

Regards ... Chris
  1. Helpful
  1. JOHN THOMAS
  2. Tuesday, 1 December 2020 19:06 PM UTC
Hey Chris - well believe it or not I have some success, with NitroPDF. It spools the psr files into a pdf just fine, but there some odd defaults that Nitro does that need to be handled. I posted the below questions in their forum in case anyone's interest in PB-with-NitroPDF interaction. I can update this on further successes with below if desired. Thanks.



https://community.gonitro.com/topic/11761-powerbuilder-with-nitropro-unwanted-defaults/

Hi Nitro - just started using Nitropdf with latest Appeon Powerbuilder. I got it to make a spooled file ok, which was a major breakthrough for us on Windows 10 (upgrading some older OS's). However there's some behavior I need to be able to modify/suppress. I have a screenshot but I can't upload a .jpg here it looks like; I don't have it on a url anywhere so descriptions will have to suffice:



1- as soon as it hits the Powerbuilder "PrintOpen()" command, it throws up the Nitro spooling window. PrintOpen() takes an argument TRUE/FALSE that is supposed to be able to suppress a printer selection window, and feeding it like so PrintOpen("jobname", FALSE), it does suppress the Windows printer selection window, but still throws up the Nitro spooler. As this is all run from an automated batch job, we can't have a spooler window popping up and hanging up the job. How to bypass?



2- along with spooler window, a default file ("powerbuilder.pdf") is set up in the spooler window which I take it Nitro is grabbing from the app name. This is no good as a) we need our own specific file names and b) it is auto-saving the above default file name to the c:\windows folder. Can't have this either. We need to be able to feed Nitro our filename and location programmatically and have it take it.



Please advise on how I can remedy 1 & 2 above. Note that I am having to run Powerbuilder as administrator in this test box (Windows Server 2019 in this case, other boxes will be Win 10 or Win 2016), which makes a diff. When I don't run PB as admin, Nitro spooler window on save gives me "file locked" error. So I've solved that at least. Thanks much!
  1. Helpful
There are no comments made yet.
JOHN THOMAS Accepted Answer Pending Moderation
  1. Friday, 27 November 2020 20:31 PM UTC
  2. PowerBuilder
  3. # 8

Thanks much Chris. Afraid that didn't do it, not sure if I have all the values right, see attached shot. Still getting the popup / save.  Below is the printer I'm using, which sets without error in PrintSetPrinter(). It's just the dang PrintOpen() that doesn't like it.

STRING is_printer = 'Microsoft Print to PDF'
STRING is_driver = 'winspool'
STRING is_port = 'Ne01:'

Attachments (1)
Comment
  1. JOHN THOMAS
  2. Friday, 27 November 2020 22:01 PM UTC
Yep, sigh. So typical. I am hoping that the Adobe Pro print driver will not cram that sort of thing down our throats, and my management will just have to go for it. Thanks for your replies, really appreciate it, this will be ample evidence for them. Cheers, jt
  1. Helpful
  1. Chris Pollach @Appeon
  2. Friday, 27 November 2020 22:28 PM UTC
I just tried the PrimoPDF print driver and it is also in the App user's face on the PrintOpen() command. :-(

That is no problem if the App user is given the flexibility to direct & name the PDF file. However, a real PIA if you want the App to do all that.
  1. Helpful
  1. JOHN THOMAS
  2. Tuesday, 26 January 2021 21:23 PM UTC
And I must add one further thing to this to make sure that this whole thing about Adobe Acrobat XI Standard is complete. After screwing around for hours, it was finally discovered that the datawindow settings MUST be this:



Print Specifications

"Override Print Job" flag must be set ON. This is the absolutely critical setting that finally allowed the different

psr's to rotate properly independent of their buddies within the spooled pdf.



Paper Orientation - (Land/Portrait) whatever desired



Data Export:

Method - Distil!

"Distill Custom Postscript" checkbox = ON



If you set up your datawindows per the above, your psr's should spool and output to the correct orientation. We didn't need to do any registry or Adobe driver settings to make the independent rotation happen after all.
  1. Helpful
There are no comments made yet.
JOHN THOMAS Accepted Answer Pending Moderation
  1. Friday, 27 November 2020 18:46 PM UTC
  2. PowerBuilder
  3. # 9

Chris  - maybe you can help with what looks like the last hurdle. I have my code finding the onboard Windows 10 (actually Winserver 2019 in this dev box, but production will be Win 10) PDF printers, but I have a problem with the SaveAs popup continuing to come up. See below red stuff please and tell me what you can, thanks!

//  ---- up to now all printer/driver setup was done hardcoded into the Registry
//RegistrySet &
// ("HKEY_CURRENT_USER\Software\CUSTPDF Writer", 'BypassSaveAs', RegString!, '1')  <<< PREVIOUS TECHNIQUE
//RegistrySet &
// ("HKEY_CURRENT_USER\Software\CUSTPDF Writer", 'OutputFile', RegString!,a_FileName)
//

--- current active

ll_count = UpperBound(a_dw)
IF ll_count > 1 THEN ll_print = PrintOpen()    <<<<< THS IS THROWING UP THE SAVEAS POPUP WINDOW, I JUST WANT THE FILE TO PRINT DIRECTLY TO FILENAME ASSIGNED IN THE DATAWINDOW. HOW TO SUPPRESS THIS POPUP?

 

Comment
  1. Chris Pollach @Appeon
  2. Friday, 27 November 2020 19:40 PM UTC
Hi John;

You will need to control the PrintOpen command as follows:

ulong li_job

li_job = PrintOpen("<PDF Creattion>", FALSE)

1) You will need the print job number for the PrintDataWindow() commands to use

2) The 2nd Argument should stop the printer pop-up.

HTH

Regards... Chris
  1. Helpful
There are no comments made yet.
Chris Pollach @Appeon Accepted Answer Pending Moderation
  1. Wednesday, 25 November 2020 00:49 AM UTC
  2. PowerBuilder
  3. # 10

Hi John;

   The old technic would work if your App was using the PrintDataWindow() command. That's because this command can be done many times in one print job. If the printer your print job was directed to was a postscript PDF printer, then the one print job (including all your DWOs) then produced one PDF file. Basically like a concatenated output.

  When using the new NativePDF feature, it only works on one DWO's primary buffer at at time. Thus, one PDF file per DWO occurrence.

  The only way forward using the new NativePDF feature that I have found (actually a trick I used from way back in the EAServer days) is to use the PDFToolKit to "stitch" the separate PDF files into one PDF after the end of the DWO array processing.

PDKTK

HTH

Regards... Chris

 

Comment
  1. JOHN THOMAS
  2. Wednesday, 25 November 2020 17:00 PM UTC
PS - Chris - would Printdatawindow() function work with the stock Adobe Acrobat Pro printer driver? Below is link with discussion about AAPro driver. If all we need is a decent printer driver to get a pdf then we can go back to Printdatawindow() and abandon the NativePDF. Thanks.



https://community.adobe.com/t5/acrobat/how-do-i-install-the-pdf-printer-driver/td-p/9518994?page=1
  1. Helpful
  1. Chris Pollach @Appeon
  2. Wednesday, 25 November 2020 17:13 PM UTC
Hi John;

Yes, as long as the PDF print driver supports "PostScript" then the PrintDataWindow() command in a loop will work great. I personally use the printers "MicroSoft Print to PDF" (included now with W10) and "PrimoPDF" (free) printer to PDF solution software all the time and they work great for me.

I cannot advise you about the older Adobe printer to PDF product as I have never used it. Defaulting instead to using the free PrimoPDF driver. However, the new free W10 MS driver works well ( limited testing on my part ) in the testing that I have done.

FYI: https://www.primopdf.com

HTH

Regards ... Chris
  1. Helpful
  1. JOHN THOMAS
  2. Wednesday, 25 November 2020 22:34 PM UTC
Thank you sir! I will try it all as my hardware team doles it out, I have no power to set up anything myself, sniff.
  1. Helpful
There are no comments made yet.
  • Page :
  • 1


There are no replies made for this question yet.
However, you are not allowed to reply to this question.
We use cookies which are necessary for the proper functioning of our websites. We also use cookies to analyze our traffic, improve your experience and provide social media features. If you continue to use this site, you consent to our use of cookies.