I am new to PowerBuilder. I got an assignment to create a PDF file using PowerBuilder. How can I do that?
Our organization used to use Ghostscript, but has instead moved to Amyuni.
as suggested by Alberto Megia, download PDF creator, but dont use SAVE AS.
After you install pdf creator it will install a printer, use that printer to save the
datawindow with the print function.
after call print function, you will see a "Save as" dialog.
If you use "saveas" function, the pdf will not have the format that the datawindow shows.
What version of PowerBuilder are you using? The most recent versions have PDF capability built in (using Ghostscript).
Install Ghostscript.
Get PDFCreator for free there and install it.
Then you can save as PDF any datawindow or datastore with the statement:
dw_1.saveAs(path_where_to_save_with_name_of_file.pdf, PDF!, true)
Third parameter is for override if the file exists with that name. I hope it works for you.
Regards,
Alberto
We just use Ghostscript. I wrote Ghostscript setup instructions earlier. We also print Word documents we've filled in to PDF from our app by printing them to 'Sybase DataWindow PS' printer then running Ghostscript to make the PDF.
Good Question - There really isn't an easy way other than finding a third party tool. I've tried the prior method mentioned and it does work but not without headaches and you are left with deployment headaches, deploying ghost script and having to make sure Post Script drivers are on the client.
I ended up trying many PDF converters, both free and paid, the one that worked most seamlessly was one that installed as a "printer" such as if you have Adobe installed on the PC, but you need to dynamically verify existence of the printer via RegistryGet and if it doesn't exist ask user to install or install it dynamically via code, and registry entries (not fun).
After several headaches mostly related to deployment issues I ended up going with a server solution, but it requires having a server that you can have a process (distiller) running that grabs post script files and distills them to PDF. I used a response window with progress bar, the PB app printed post script file to server location upon which the distiller grabs and converts. My PB app polls the server until it finds the PDF, or the user cancels whichever comes first. With a good distiller the process is fast (< 5 seconds) which was acceptable to our users.
Upon existence of the PDF, we'd attach it to an email and send via Oracle (mapi). This solution limits the requirements on client to post script driver which in most corporate environments is there, but you need to check it via Registry. Maybe there is a better solution out there since I did this last, around 2008.
fyi- I usually don't make vendor recommendations but will in this case because there was one that stood out in ease of use and quality, it was called PDFCreator which installs as a windows printer. It looks to be open-source right now but I recall that we would have had to pay to use it in corporate environment.
Good Luck.
Use the tutorial How to use PowerBuilder to create PDF file?.
Related
I am hoping to get some help with a work problem I recently "inherited"... The company I am working for has rendered my services to help them get their information system application migrated from Windows XP machines to Windows 10 machines. The core components of the program were developed in Visual Basic 6, Crystal Reports 8, and Adobe Acrobat 5. I already know 99% of peoples answers are along the lines of "You need to upgrade" or "Why are you using that?!". For those people, the answer is simply because my immediate need is to use what I was given, and the eventual plan is to migrate everything over to newer versions of these core components.
I have made some code adjustments already and found some other updated drivers for other dependencies, and so far through initial testing, it seems the application is performing as expected.
Unfortunately, yesterday, I hit a major snag where the application is trying to print to the "Adobe PDFWriter" printer, which doesn't seem to be installed on Windows 10, even though I installed Adobe Acrobat 5.0, as administrator, with the "Include PDFWriter files" option checked during install.
I can't find the printer in the list of printers.
I can't find any specific ports or drivers for Adobe when trying to
manually add the printer.
The main PDFWriter dll, "pdfddui.dll", and supporting dlls,
("pdfdd.dll", "pdfkd.dll") do not exist under the
"Windows\System32\spool\drivers" location, which is where they are
found on a working Windows XP machines.
The main dlls and supporting dlls mentioned above DO exist under
"Windows\System32\spool\drivers\x64"
When searching the registry for the main dll or supporting dlls,
nothing is found, suggesting the dlls weren't able to successfully
register.
When trying to manually register the dlls using
"\Windows\SysWoW64\regsvr32.exe" it fails.
When trying to manually register the dlls using
"\Windows\System32\regsvr32.exe" it fails.
The code that is executing is doing the following:
It dynamically builds a crystal report from a SQL query based on
parameters from a form.
It uses the crystal reports "SelectPrinter" function to specify the
Printer.DriverName, Printer.DeviceName, Printer.Port
It uses the crystal reports "PrintOut" function to specify not to
prompt the user for any input, i.e. "silent print".
The end result, what I need to replicate, and what I need the communities help with is that Crystal Reports:
Prints the file as a PDF SILENTLY with NO user action required.
Prints the file with a specific filename.
Prints the file to a specific location.
I have tried using Microsofts built-in Print to PDF, and that works, BUT it prompts the user to save the file, it also has the wrong default filename and location, and I see no way to programmatically change that from VB6.
I would imagine newer versions of Adobe Acrobat ARE NOT compatible with Visual Basic 6, additionally, the licenses for Adobe Acrobat are kind of pricey when the ONLY functionality I need is the ability to programmatically print to PDF.
Any useful comments, suggestions, resolutions will be very much appreciated!
Why don't you add an intermediate, behind-the-scenes, step to export the Crystal Report to a PDF file and then print the PDF file using ShellExecute or another method.
pid = ShellExecute(0&, "print", DocFile, vbNullString, vbNullString, vbNormalFocus) is what I use to print PDF files automatically from VB6.
If that doesn't work, I have used a printer driver called CutePDF. It is free and Windows 10 ready.
Problem: Need to convert local html (with local images etc) to pdf from an AIX box running Universe 11.2.5 with System Builder
Current solution: FTP over html file to a Windows server which converts in batches and sends the e-mail to the destination
Proposed Solution: Do everything on the AIX box, from converting html to pdf and sending the e-mail.
Current problem: Unable to find a way to convert local html to PDF on the AIX box. I have been trying many different ways from trying to install Python3, but to no avail.
The only really difficult part of the process is getting the HTML to render into a format will properly display your html into pages that are suitable for printing. There is a fair amount of magic that goes on between HTTP:GET and clicking print on a browser window that needs to be accounted for.
I was trying accomplish something similar many moons ago on AIX but kind of ran into a skill level/time wall because I was going to have essentially create a headless browser to render the html. It looks like there are now some utilities that you might be able to leverage. I found this recent updated article on Super User that actually got me somewhat excited, especially since I don't use AIX anymore so precompiled binaries and well understood and easily attainable dependencies are something I can actually have in my life.
https://superuser.com/questions/280552/how-can-i-render-a-website-as-an-image-from-the-shell
Good Luck.
There seems to be several questions rolled into this one item.
Converting HTML to PDF, while that is just a data manipulation that you could do in basic, writing such code would be a large task. The option you use sending it to another system is valid, but put more points of failure into the system. I would think you could find code to do it on the AIX box.
Rocket plans on getting the MV Python to work on AIX, this will make the converting of html to PDF much easier since there are a lot of open source modules.
As for my suggestion of using sockets, that would be if you intend to send it to a service that will take the htms, and return the pdf document.
i.e. Is there a web service for converting HTML to PDF?
Once you have the pdf document, you can either store it in a UniVerse type-19 file, or do the base64 encoding and store it in UniVerse hash file.
Hope this helps,
Mike
I created a protocol generation tool that reads some data from a websource, allows the user to filter some of the fields an generate a protocol based on given filterdata. The protocol is generated as a word document that is edited multiple times, on multiple layers, before shown to the user.
For some users the line:
Process.Start(pathtowordfile)
does not open Word, for others it works fine.
Even more strange: if the useres try to generate the protocol the first time it opens. if they change one of the filters and generate again, the file does not open. But it is generated correctly, you are able to open it manually.
We are using Windows 7 on all machines and, in general, the User has no administrativ privileges on the machine.
Are there any alternatives to
Process.Start()
?
Not sure how the code can sometimes work, but the critical bit I think would be to make sure you set UseShellExecute=true when you are trying to Process.Start a file that is not an executable.
https://msdn.microsoft.com/en-us/library/system.diagnostics.processstartinfo.useshellexecute%28v=vs.110%29.aspx
I haven't looked into it in quite awhile, but last I checked shell execute relies on the Word application to be properly registered with DDE so Windows knows what to do with a .doc(x) file. Word may not be installed "properly".
after trying varios things, including Wonko's hint, I dicided to use the interop.Word.Wordapplication to display the document. It doesn't explain why process.start not does the job but anyway, now everybody of the users is happy^^
I am running a Citrix-driven environment, and I have a vital piece of software that creates a PDF repository of all reports as they run. The problem I have is that the users' printers must populate into the environment (Not just the default printers- ALL of them), and a number of the computers have Acrobat 9 or X on them. The software that creates the reports REQUIRES that the Rely On System Fonts is turned off, but some users have it turned on when it comes to the PDF printer on their computers. Sometimes, when user x goes to create a report, it will grab the printer from user y's session that may not have the option properly unset- Then user x's irreplaceable report is lost. The application is a Dexterity application, and I don't have access to the source. Is there a way, in Citrix or in AD, to script this one option to be unset properly? Any idea if there is a registry key or some kind of hook I can activate with a powershell script to fix this headache? I appreciate any help.
I have been researching for weeks to figure this out for myself, and I was looking for one more answer and found your question. To fix your problem I was able to find that the registry key found here:
[HKEY_CURRENT_USER\Printers\DevModePerUser]
Contains all of the current printer properties. If you export it, you can run a script to add the reg key during login. Just make sure that you restart the spooler after words, just to make sure that the changes apply. Also the settings will only apply to the printer with the same name, so you have to have a different reg key for each different printer name, if you have several. I just esported the key after I had changed the printer settings to how I liked them, and then edit the .reg file to remove any data about other installed printers to make sure that the .reg file wouldn't affect any other printers.
Apparently, this problem is a common problem. Microsoft has acknowledged that the PDF creation issue I am trying to avoid is an issue in GP, starting in (Think it was version) 7. The Microsoft-recommended workaround is to open the PDF Printer properties and uncheck the Use System Fonts box. Adobe does not support this configuration, so they will not provide a clear way to implement it at a network level with clients in many locations and 4 different major versions of Acrobat. The closest I came was a post that identified an incredibly long string I have to hexedit that seems to change in specific minor versions of Acrobat. Way to go M$ and Adobe. So, in other words, no support on major product lines from two major companies. I have nowhere else to go at this point. If anyone else has a solution to this problem, I'd love to hear it. Thanks!
We have a process at our company that processes TIFF images. I have a project where I want to be able to capture emails that people have received and let them pass it on to our imaging process. Right now forwarding an email isn't really an option but our initial thought was that we could create an Outlook addin that would create and send an image of the email to our internal webservice and it would just work.
I'm developing on Windows 7 with VS2010 and Outlook 2007.
I have the basic addin framework setup - that seems to work OK. The addin is there, popping a regular Windows form where I can do my stuff. But now I'm running into problems. First I was going leverage the built-in Microsoft Office Document Image Writer which can write to TIFFs. However, this doesn't appear to be installed as part of Office 2007 on Windows 7. Then I found some references that it didn't work on Win7 64bit in the first place, and that Microsoft was phasing it out in favor of their XPS printer anyway.
Then I moved on to thinking I could maybe use PDFCreator. This sort of works, except it looks like I have to actually have PDFCreator installed on the client machine, too. I was really hoping I could just bundle the dll and PDFCreator could natively "print", but it seems rely on you setting the active printer to "PDFCreator" and still printing to that. I was already maybe going to run into problems pushing a custom addin out to users in the first place; I don't know if I could get a new printer rolled out as a requirement, too.
On top of that, you apparently can't set the active/default printer in Outlook once it's running. So my plan to run the addin, change the default printer to PDFCreator, print it, then change it back isn't going to work after all anyway.
We really wanted to be able to capture emails as if the user had printed them out and scanned them, which is what they have to do now. I would really not like to rely on copying/pasting into another application if I can help with it.
Sooooooo, what other options might I have? Is there any close to native functionality in Windows or Office that would let me print to something and eventually get a TIFF? Does it look like I'm going to have to try and string together a bunch of 3rd party tools or something? It looks like the only way to "print" an email is to do the MailItem.PrintOut() command, which is just going to go to whatever the current default printer is. Are there any other TIFF-printing things available that wouldn't involve installing a new virtual printer on the end user's machine? Any other ideas? Thanks for any help!
Although you ruled it out at the start of the question...
Assuming you need those tiffs at a central location and not at the employee desktop.... I'd still advise you to have your addin forward the respective mail to a central location (as an attachment to a automated mail, or perhaps just write it to a queue folder on some network location), then have a central process pick it up and print it out to tiff files.
Unless you have exact control over the client machines at your company (which from the sound of it, you don't), you really want to move some fickle as 'switching printers in Outlook' away from the clients.
That doesn't mean this approach doesn't require hacks as well, because that central process will be running outlook to do the work.
I assume it is important that your tiffs look like they were actually printed from Outlook, if not please add that as extra information to your question, as it opens new routes. Like capturing the email-screen rendering and putting that inside a tiff file, which can all be done on any desktop machine.