Do you own a Debenu Quick PDF Library version 7, 8, 9, 10, 11, 12, 13 or iSEDQuickPDF license? Upgrade to Debenu Quick PDF Library 14 today!

Debenu Quick PDF Library - PDF SDK Community Forum Homepage
Forum Home Forum Home > For Users of the Library > I need help - I can help
  New Posts New Posts RSS Feed - VBscript .LoadFromFile do nothing
  FAQ FAQ  Forum Search   Register Register  Login Login

VBscript .LoadFromFile do nothing

 Post Reply Post Reply
Author
Message
Thierry_B View Drop Down
Beginner
Beginner


Joined: 23 May 21
Status: Offline
Points: 9
Post Options Post Options   Thanks (0) Thanks(0)   Quote Thierry_B Quote  Post ReplyReply Direct Link To This Post Topic: VBscript .LoadFromFile do nothing
    Posted: 23 May 21 at 11:24AM
Hello,

Sorry for bad enghish, I'm French
I try to load un PDF file with Lite Library but always receive 0 result (file not loaded).
I tried with full path and without, with differents files.  Always same result.
Any ideas ?

Thanks
Thierry


' Debenu Quick PDF Library Lite Sample

WScript.Echo("Debenu Quick PDF Library Lite - Hello World Sample")

Dim ClassName
Dim QP

Dim InFileName
Dim OutFileName
Dim lWidth
Dim lHeight

ClassName = "DebenuPDFLibrary64Lite1114.PDFLibrary"
InFileName = "image.png"
OutFileName = "Testfini.pdf"

Set QP = CreateObject(ClassName)


' Load the PDF that you want to add the image to
if (QP.LoadFromFile("testPDF", "")) = 0 Then WScript.Echo("Erreur chargement PDF")

' Load the image that you'd like to convert to PDF
Call QP.AddImageFromFile(InFileName, 0)

' Get the width and height of the image
lWidth = QP.ImageWidth()
lHeight = QP.ImageHeight()

' Reformat the size of the page in the selected document 
Call QP.SetPageDimensions(lWidth, lHeight)

' Draw the image onto the page using the specified width/height
Call QP.DrawImage(0, lHeight, lWidth, lHeight)

' Save the new PDF to disk
If QP.SaveToFile(OutFileName) = 1 Then
WScript.Echo("File " + OutFileName + " written successfully")
Else
WScript.Echo("Error, file could not be written")
End If

Set QP = Nothing
WScript.Sleep(9000)
Back to Top
Sopracenery View Drop Down
Team Player
Team Player
Avatar

Joined: 31 Aug 20
Location: Germany
Status: Offline
Points: 29
Post Options Post Options   Thanks (0) Thanks(0)   Quote Sopracenery Quote  Post ReplyReply Direct Link To This Post Posted: 23 May 21 at 11:28PM
Hi Thierry,

Please check first your filename.

testPDF

looks not like a PDF file. Try 

test.PDF  

and then read out WScript.Echo(QP.LastErrorCode)

It returns 0 with „testPDF“ and it returns 401 with „test.PDF“ when File Not Found.



Edited by Sopracenery - 24 May 21 at 8:26AM
Back to Top
Thierry_B View Drop Down
Beginner
Beginner


Joined: 23 May 21
Status: Offline
Points: 9
Post Options Post Options   Thanks (0) Thanks(0)   Quote Thierry_B Quote  Post ReplyReply Direct Link To This Post Posted: 24 May 21 at 8:41AM
Thanks :-)
Back to Top
Thierry_B View Drop Down
Beginner
Beginner


Joined: 23 May 21
Status: Offline
Points: 9
Post Options Post Options   Thanks (0) Thanks(0)   Quote Thierry_B Quote  Post ReplyReply Direct Link To This Post Posted: 24 May 21 at 9:12AM
Ok, omit ".pdf" in my example.

Here is the function called by hMailServer (EventHandlers):

Function ImageToPDF(FileName, ExtFileName, SaveFolder)
' Converti les images en PDF
' JPG/JPEG/TIFF/TIF  EPS à tester?
' Retourne True si Ok
' Retourne False si erreur
Dim ClassName
Dim QP
Dim OutFileName
Dim lWidth
Dim lHeight
ClassName = "DebenuPDFLibraryLite1114.PDFLibrary"
Set QP = CreateObject(ClassName)
ImageToPDF = False
' Load the image that you'd like to convert to PDF
If (QP.AddImageFromFile(FileName, 0)) = 1 Then

' Get the width and height of the image
lWidth = QP.ImageWidth()
lHeight = QP.ImageHeight()

' Reformat the size of the page in the selected document 
Call QP.SetPageDimensions(lWidth, lHeight)

' Draw the image onto the page using the specified width/height
Call QP.DrawImage(0, lHeight, lWidth, lHeight)

' Save the new PDF to disk
OutFileName = SaveFolder & GetBaseFile(FileName) & "." & "pdf"
Call QP.SaveToFile(OutFileName)
ImageToPDF = True
End If
Set QP = Nothing
End Function

AddImageFromFile don't load file and retour code error is 0
File name is correct : "C:\MailServerAttachements\XXXXX@XXXX.cc\2021\20210524100511001info@XXXX.be.image.jpg

Any idea ?
Back to Top
Thierry_B View Drop Down
Beginner
Beginner


Joined: 23 May 21
Status: Offline
Points: 9
Post Options Post Options   Thanks (0) Thanks(0)   Quote Thierry_B Quote  Post ReplyReply Direct Link To This Post Posted: 24 May 21 at 9:40AM
Ok it seems running.
I changed main folder (p:\...) to C:\...
P folder is a "space storage" on Windows Server 2012

Thanks for helping
Back to Top
Ingo View Drop Down
Moderator Group
Moderator Group
Avatar

Joined: 29 Oct 05
Status: Offline
Points: 3524
Post Options Post Options   Thanks (0) Thanks(0)   Quote Ingo Quote  Post ReplyReply Direct Link To This Post Posted: 24 May 21 at 1:13PM
Hi Thierry,

the function LastErrorCode always returns with a more detailed error code from the last called function...
https://www.debenu.com/docs/pdf_library_reference/LastErrorCode.php
directly after Load... should have return with error code 401 or 408 and then you would have known ;-)

Cheers and welcome here,
Ingo

Cheers,
Ingo

Back to Top
Thierry_B View Drop Down
Beginner
Beginner


Joined: 23 May 21
Status: Offline
Points: 9
Post Options Post Options   Thanks (0) Thanks(0)   Quote Thierry_B Quote  Post ReplyReply Direct Link To This Post Posted: 24 May 21 at 8:07PM
Thanks

Back to Top
 Post Reply Post Reply
  Share Topic   

Forum Jump Forum Permissions View Drop Down

Forum Software by Web Wiz Forums® version 11.01
Copyright ©2001-2014 Web Wiz Ltd.

Copyright © 2017 Debenu. Debenu Quick PDF Library is a PDF SDK. All rights reserved. AboutContactBlogSupportOnline Store