1. Christophe Feyte
  2. PowerBuilder
  3. Wednesday, 17 April 2024 14:29 PM UTC

Hello,

I'm using PowerBuilder 2022 build 1892.

I generate a PDF using the code below :

PDFDocument lpdf_doc

long ll_return, ll_return1

lpdf_doc = Create PDFDocument
dw_1.Modify("DataWindow.Export.PDF.Method = NativePDF! ")
dw_1.modify("DataWindow.Export.PDF.NativePDF.PDFStandard =4")
lpdf_doc.importdatawindow( dw_1 )
lpdf_doc.properties.keywords = "my-keywords"
ll_return1 = lpdf_doc.save( "C:\PDF\datawindow.pdf", PDFA_3b!)

destroy lpdf_doc 

Then I try to read the keywords with the code below :

PDFDocument lpdf_doc

long ll_return
string ls_test

lpdf_doc = Create PDFDocument
ll_return = lpdf_doc.importpdf( "C:\PDF\datawindow.pdf")
ls_test = lpdf_doc.properties.keywords

MessageBox("Keywords", ls_test )
destroy lpdf_doc

But unfortunately, my local variable is empty and the IDE crash after that.

So I'm asking just in case, is it possible to read the metadata from an existing pdf ?

Accepted Answer
Andreas Mykonios Accepted Answer Pending Moderation
  1. Thursday, 18 April 2024 08:13 AM UTC
  2. PowerBuilder
  3. # Permalink

Answering to Christophe Feyte question:

Hello, is there really no way of making this code work?

Using pdfdocument in PB 2022 189, unfortunately no. As I said, Appeon stated that this feature would remain as beta for PB 2022 (R1). This means that we were able to submit bugs, but any fix(es) would be available only in R2 and later releases (where PBDocument become an non beta object). By the way, neither pdfsecurity can be read in the beta of pdfdocument (PB 2022 R1)...

Now... You cannot make it work with pdfdocument object! But, you can always experiment getting that information directly from your pdf file. A pdf file is in reality a text file using some techniques to protect it's content. But you can find information provided in properties... Search for: /Keywords. It must be followed by parenthesis which should include the keywords you provided. You can do the same for: "Creator" (/Creator), "Author" (/Author) e.t.c.

Example:

// PB Command to set keywords:

lnv_pdf.properties.keywords = "My Keyword, Another Keyword"

// You save your pdf.
// You open it for read only as a text file (probably using linemode!).
// Searching your pdf as a text you should find somewhere the following:

/Keywords(My Keyword, Another Keyword)

or

<</Keywords(My Keyword, Another Keyword)

As a result, that specific task could be done without using pdfdocument.


Andreas.

Comment
  1. Christophe Feyte
  2. Thursday, 18 April 2024 10:15 AM UTC
It works by reading the file using linemode!

It's not ideal, but it will suffice until we update our version of PB2022.
  1. Helpful
There are no comments made yet.
Andreas Mykonios Accepted Answer Pending Moderation
  1. Wednesday, 17 April 2024 14:39 PM UTC
  2. PowerBuilder
  3. # 1

Hi.

Try to call importpdfdocinformation method of your pdfdocument object. You can even call it without loading the full pdf...

Andreas.

Comment
  1. Andreas Mykonios
  2. Thursday, 18 April 2024 06:00 AM UTC
Also you might have in mind that for PB 2022 (R1) pdfdocument was a beta feature... While it was working well, there have been many enhancements in R2 and R3.

Andreas.
  1. Helpful
  1. Christophe Feyte
  2. Thursday, 18 April 2024 07:28 AM UTC
Hello, is there really no way of making this code work?

We currently don't have the time to change the version of PowerBuilder for several months because we have customer requests to fulfil first.
  1. Helpful
  1. Andreas Mykonios
  2. Thursday, 18 April 2024 07:54 AM UTC
I answer in a new answer, as this won't be a short answer.
  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.