Print Page | Close Window

VBscript .LoadFromFile do nothing

Printed From: Debenu Quick PDF Library - PDF SDK Community Forum
Category: For Users of the Library
Forum Name: I need help - I can help
Forum Description: Problems and solutions while programming with the Debenu Quick PDF Library and Debenu PDF Viewer SDK
URL: http://www.quickpdf.org/forum/forum_posts.asp?TID=3919
Printed Date: 05 May 24 at 6:41PM
Software Version: Web Wiz Forums 11.01 - http://www.webwizforums.com


Topic: VBscript .LoadFromFile do nothing
Posted By: Thierry_B
Subject: VBscript .LoadFromFile do nothing
Date 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)



Replies:
Posted By: Sopracenery
Date 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.



Posted By: Thierry_B
Date Posted: 24 May 21 at 8:41AM
Thanks :-)


Posted By: Thierry_B
Date 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 ?


Posted By: Thierry_B
Date 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


Posted By: Ingo
Date 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



Posted By: Thierry_B
Date Posted: 24 May 21 at 8:07PM
Thanks




Print Page | Close Window

Forum Software by Web Wiz Forums® version 11.01 - http://www.webwizforums.com
Copyright ©2001-2014 Web Wiz Ltd. - http://www.webwiz.co.uk