I have the Xojo 2017.2 Pro and the DynaPDFMBS Pro - License.
I try to load a PDF with an Webfileuploader to edit it. I think I make something wrong. This is my code:
[code]
dim key as string = DecodeBase64(“this is secret”, encodings.UTF8)
DynaPDFMBS.setLicenseKeyGlobal key
dim pdf as new MyDynapdfMBS
pdf.SetLicenseKey “Pro”
Dim outputFile As FolderItem
outputFile = GetFolderItem(“temp_uploads”)
If Not outputFile.Exists Then
outputFile.CreateAsFolder
End If
Dim output As BinaryStream
For Each file As WebUploadedFile In files
Try
outputFile = outputFile.Child(file.Name)
output = BinaryStream.Create(outputFile, True)
output.Write(file.Data)
call pdf.CreateNewPDF outputFile.Child(file.Name)
output.Close
Catch e As IOException
Continue
End Try
Next[/code]
I think this line is wrong: call pdf.CreateNewPDF outputFile.Child(file.Name)
Please remove the call
pdf.SetLicenseKey "Pro"
as that puts you back to demo mode!
With pdf.CreateNewPDF you create a new PDF and overwrite the one uploaded.
You want to call OpenImportBuffer in DynaPDF object to open existing PDF from memory block (no need for temp file).
maybe do a pdf.CreateNewPDF(nil) before to make new PDF in memory.
I modified the code. Now it looks this way; but the problems aren’t gone. I can’t get the pdf.
dim key as string = DecodeBase64("secret :)", encodings.UTF8)
DynaPDFMBS.setLicenseKeyGlobal key
dim pdf as new MyDynapdfMBS
Dim uploadFolder As FolderItem
uploadFolder = GetFolderItem("temp_uploads")
If Not uploadFolder.Exists Then
uploadFolder.CreateAsFolder
End If
Dim savePDF As FolderItem
For Each uFile As WebUploadedFile In files
Try
savePDF = uploadFolder.Child(uFile.Name)
uFile.Save(savePDF)
call pdf.SetImportFlags(BitwiseOr(pdf.kifImportAll, pdf.kifImportAsPage))
if pdf.OpenImportFile(savePDF, pdf.kptOpen, "")<>0 then
MsgBox "Input file """+ savePDF.name+""" not found!"
end if
dim outfile as FolderItem=uploadFolder.Child(uFile.Name)
call pdf.CreateNewPDF outfile
call pdf.ImportPDFFile(1, 1.0, 1.0)
call pdf.CloseImportFile
Catch err As UnsupportedFormatException
// not a PDF, so skip it
Continue
Catch err As IOException
MsgBox("Upload failed: Insufficient permissions to save files to " + uploadFolder.NativePath)
Exit For
End Try
Next
do you get error message?
Maybe you have a sample test project for me to check?
I send an email with a sample test project.
Does someone have an idea for me?
Seems you not just failed to get the email, you also missed my private messages here on the forum.
I click on the link I got a “Page Not Found
For some reason this conversation cannot be viewed. It may not exist, or you may not have permission to view it.”
Whenever I make private message to Marcel Zimmer, I get the suspended user (#76830), but not the right one (#322389).
Please tell me an alternative email, as your email server blocks me.
Thank you!
Christian helped me: I had some nasty bugs in my code. I’ll tried to change the pdf while uploading.
Now it works fantastic!
I recommend the MBS Xojo DynaPDF Plugin Pro plugin! It is really good!!