Jump to content

Recommended Posts

Posted

Is there  reliable way to validate pdf file beside do it by manually opening it in some reader and inspecting it by eyes?

I tried to use popler dll, but in most cases it open even crippled files...

Posted
  On 7/26/2020 at 11:52 AM, Iczer said:

Is there  reliable way to validate pdf file beside do it by manually opening it in some reader and inspecting it by eyes?

Expand  

I am not sure if this method is 100% reliable, but I would verify it as follows:

; The initial 8 bytes of a PDF-File usually indicates its version :
; %PDF-1.X or %PDF-2.X (where X is a number)
; Valid version indicators :
; %PDF-1.0, %PDF-1.1, %PDF-1.2, %PDF-1.3, %PDF-1.4, %PDF-1.5, %PDF-1.6, %PDF-1.7 and %PDF-1.8 , meanwhile also %PDF-2.x
#include <WinAPIFiles.au3>
Local $sFilePath = @ScriptDir & '\Test.pdf'
Local $sFileRead
Local $hFileOpen = FileOpen($sFilePath, BitOR($FO_READ, $FO_BINARY))
If $hFileOpen = -1 Then
    MsgBox(0, "", "An error occurred when reading the file.")
    Exit
EndIf

$sFileRead = FileRead($hFileOpen, 8)
If StringRegExp(BinaryToString($sFileRead),'(?i)^\%PDF-\d\.\d') Then
    MsgBox(0, "", "PDF-File detected")
Else
    MsgBox(0, "", "No PDF-File detected")
EndIf
FileClose($hFileOpen)

 

Musashi-C64.png

"In the beginning the Universe was created. This has made a lot of people very angry and been widely regarded as a bad move."

Posted

What you mean... validate . 

Signature beginning:
Please remember: "AutoIt"..... *  Wondering who uses AutoIt and what it can be used for ? * Forum Rules *
ADO.au3 UDF * POP3.au3 UDF * XML.au3 UDF * IE on Windows 11 * How to ask ChatGPT for AutoIt Codefor other useful stuff click the following button:

  Reveal hidden contents

Signature last update: 2023-04-24

Posted

If you need to validate exact layout for something like mailers, then not that I know of.

 

If you just need to validate some specific text was included in the PDF, then yes there are some apps I've used in the past that will pull out the text that you can then verify with AutoIt code.

 

Posted
  On 7/27/2020 at 2:53 PM, mLipok said:

What you mean... validate . 

Expand  

I would have a working solutions depending on your answer.

Signature beginning:
Please remember: "AutoIt"..... *  Wondering who uses AutoIt and what it can be used for ? * Forum Rules *
ADO.au3 UDF * POP3.au3 UDF * XML.au3 UDF * IE on Windows 11 * How to ask ChatGPT for AutoIt Codefor other useful stuff click the following button:

  Reveal hidden contents

Signature last update: 2023-04-24

  • 2 weeks later...
Posted
  On 7/27/2020 at 2:53 PM, mLipok said:

What you mean... validate . 

Expand  

 

  On 7/27/2020 at 3:12 PM, mLipok said:

I would have a working solutions depending on your answer.

Expand  

@Iczer Are you going to reply

Signature beginning:
Please remember: "AutoIt"..... *  Wondering who uses AutoIt and what it can be used for ? * Forum Rules *
ADO.au3 UDF * POP3.au3 UDF * XML.au3 UDF * IE on Windows 11 * How to ask ChatGPT for AutoIt Codefor other useful stuff click the following button:

  Reveal hidden contents

Signature last update: 2023-04-24

  • 2 years later...

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...