Tech Articles


PDF Enhancements in PowerBuilder 2017 R3


With the release of PowerBuilder 2017 a new native method of exporting DataWindows to PDF became available.  There were some enhancements to that functionality added in R2 and in R3 that we're going to look at in this article.

The R2 enhancements were more minor, but one of them (PDFStandard) becomes important when looking at the R3 enhancements.  R2 added the following new DataWindow properties.

Export.PDF.NativePDF.ImageFormat 0 - (Default) BMP
1 - JPG
2 - PNG
3 - GIF
Export.PDF.NativePDF.PDFStandard 0 - None
1 - PDF/A-1a
2 - PDF/A-1b
3 - PDF/A-3a
4 - PDF/A-3b
5 - PDF/A-3u
Export.PDF.NativePDF.UsePrintSpec Yes - Use the settings in the Print Specifications page or in the Print.Orientation and Print.Paper.Size properties.No - (Default) Use the settings in the Data Export page or in the Export.PDF.NativePDF.CustomOrientation and Export.PDF.NativePDF.CustomSize properties.

At the time, I wasn't impressed enough with those features to create a blog post for them. However, with R3, the following additional enhancements have also been added, and these I did find interesting enough to write up.

Export.PDF.NativePDF.UserPassword Set a password for opening the generated PDF file
Export.PDF.NativePDF.MasterPassword Set a password for the administration permissions -- print, copy, edit, etc. -- to the generated PDF file
Export.PDF.NativePDF.Restrictions Set the permissions (including copying/printing/editing) of the generated PDF file. One more more of the following separated by commasnoprint! - Acrobat will prevent printing the file.nohiresprint! - Acrobat will prevent high-resolution printing. If noprint isn't set, printing is restricted to the print as image feature which prints a low-resolution rendition of the page.nomodify! - Acrobat will prevent editing or cropping pages and creating or changing form fields.noassemble! - Acrobat will prevent inserting, deleting, or rotating pages and creating bookmarks and thumbnails.noannots! - Acrobat will prevent creating or changing annotations and form fields.noforms! - Acrobat will prevent form field filling (implies nomodify and noannots).nocopy! - Acrobat will prevent copying and extracting text or graphics; the accessibility interface will be controlled by noaccessible.noaccessible! - Acrobat will prevent extracting text or graphics for accessibility (Deprecated in PDF 2.0; not allowed in PDF/UA-1).plainmetadata! - Keep XMP document metadata unencrypted even in an encrypted document (PDF 1.5).
SaveNativePDFToBlob function Saves the PDF source into a blob variable

Passwords

If you set a user password you must set a master password as well, and they can't be the same.  If you set a user password the user will be prompted to enter a password when they attempt to open the document.  For example, in Adobe Acrobat you see this:

And if you used the Firefox browser you would see this:

Restrictions

A master password is also required if you want to set restrictions on what the user can do with the document, regardless of whether or not you apply a user password.  When the restrictions are in place, the options needed to perform those actions are disabled in the PDF viewer.  In Adobe Acrobat, you can view the security settings on a document to see what has been disabled.

Note that in order to use the new R3 features the print specification must be left at the default of None or set to it.  The other print specifications (PDF/A) are s subset of the full PDF standard and don't support these options.

SaveNativePDFToBlob

The SaveNativePDFToBlob method allows you to get the PDF source without writing it out to a file and then reading the file.  The primary use would be in a service that streams the PDF content to a web client.

Summary

2017 R2 and R3 add a number of important options to PDF generation, in particular allow you to protect documents and stream documents without having to save to an intermediate file.

 

Comments (0)
There are no comments posted here yet

Find Articles by Tag

Deployment DataWindow RibbonBar Builder PowerBuilder Compiler Messagging Linux OS Platform DragDrop Service Event CI/CD JSONGenerator Export JSON PostgreSQL ODBC driver TreeView iOS OLE External Functions Text Web API Installation Menu Database Table Schema Event Handling Graph Azure JSON PowerBuilder (Appeon) NativePDF .NET Std Framework Automated Testing DataType Web Service Proxy Bug RichTextEdit Control Database Table JSONParser COM Import MessageBox Sort CoderObject Open Source Database Table Data TLS/SSL Syntax RibbonBar Source Control Variable Debug DataWindow JSON 64-bit SQL Database ActiveX PowerBuilder Expression SVN HTTPClient WinAPI Git TFS PDFlib Error API PBDOM Event Handler Excel BLOB Interface Import JSON PDF Oracle File PowerScript (PS) IDE Testing Validation UI Modernization Windows OS Source Code SnapDevelop SDK C# SQL Server Window Database Connection Database Profile Windows 10 Icons UI OAuth 2.0 Icon InfoMaker Encryption Android Array UI Themes WebBrowser Performance ODBC GhostScript Authentication CrypterObject SnapObjects PostgreSQL Repository .NET Assembly SOAP PowerServer Mobile PFC Encoding Filter Database Object XML Model Class Transaction Debugger OrcaScript Data Branch & Merge Export Charts RESTClient SqlExecutor Elevate Conference Jenkins Trial DLL TortoiseGit 32-bit SqlModelMapper Debugging Mobile Configuration Design REST Authorization OAuth Outlook Migration Script Database Painter PowerServer Web License .NET DataStore Stored Procedure Resize DevOps Application