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

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