-
Re: PDF Reader ActiveX Control
Quote:
Originally Posted by
Calcu
...
Waiting for your merge function xD
Hi,
Just ask ! :D
Using Pdfium.dll to merge PDF files is not possible in VB6, as Fafalone stated.
However, I was largely inspired by Fafalone's TwinBasic code to create a 32-bit ActiveX DLL in TwinBasic, which can be referenced in VB6 and adds a function to merge PDF files.
You can find this DLL here: https://freeware.ordoconcept.net/dow...oPDFsMerge.zip
Best regards,
François
-
Re: PDF Reader ActiveX Control
Quote:
Originally Posted by
saturnian
Hi,
Just ask ! :D
Using Pdfium.dll to merge PDF files is not possible in VB6, as Fafalone stated.
However, I was largely inspired by Fafalone's TwinBasic code to create a 32-bit ActiveX DLL in TwinBasic, which can be referenced in VB6 and adds a function to merge PDF files.
You can find this DLL here:
https://freeware.ordoconcept.net/dow...oPDFsMerge.zip
Best regards,
François
It's possible in VB6 with The trick's VBCDeclFix addin; his addin also allows creating the required CDecl callback function, you just add the CDecl keyword like the tB version, and change the Return syntax:
Code:
Private Function WriteBlock CDecl(ByVal pThis As LongPtr, ByVal pData As LongPtr, ByVal size As Long) As Long
If hFileOut Then
Dim cbRet As Long
WriteBlock = WriteFile(hFileOut, ByVal pData, size, cbRet, vbNullPtr)
End If
End Function
-
Re: PDF Reader ActiveX Control
HI all, i tried to implement the function merge in Vb6, but it's not working fine :-(
I put the code here just to see if someone (@saturnian xD) can help me, and implement it in this magnific usercontrol.
I call it this way:
Code:
Dim TT(1) As String
Dim sMergePages(1) As String
TT(0) = "c:\temp\Tarifa_080103030.pdf"
TT(1) = "c:\temp\63.pdf"
' Asumimos que queremos fusionar todas las páginas de los PDFs
sMergePages(0) = ""
sMergePages(1) = ""
PDFReader1.MergePdfs "C:\temp\prueba5.pdf", TT, sMergePages
Inside your usercontrol, I declared this:
Code:
Private Type FPDF_FILEWRITE
version As Long
WriteBlock As Long ' Almacena el puntero a la función callback
End Type
Private Type tPdfFile
sFullPath As String
sName As String
sMergePages As String
End Type
Private Declare Function FPDF_CreateNewDocument CDecl Lib "PDFium.dll" () As Long
Private Declare Function FPDF_ImportPages CDecl Lib "PDFium.dll" (ByVal dest_doc As Long, ByVal src_doc As Long, ByVal pagerange As String, ByVal index As Long) As Long
Private Declare Function FPDF_SaveAsCopy CDecl Lib "PDFium.dll" (ByVal document As Long, ByRef pFileWrite As FPDF_FILEWRITE, ByVal flags As PdfiumSaveCopyFlags) As Long
Private Declare Function FPDF_GetLastError CDecl Lib "PDFium.dll" () As Long
Private Declare Function CopyMemory Lib "kernel32" Alias "RtlMoveMemory" (ByRef dest As Any, ByRef src As Any, ByVal cb As Long) As Long
Private Declare Function CreateFile Lib "kernel32" Alias "CreateFileA" (ByVal lpFileName As String, ByVal dwDesiredAccess As Long, ByVal dwShareMode As Long, ByVal lpSecurityAttributes As Long, ByVal dwCreationDisposition As Long, ByVal dwFlagsAndAttributes As Long, ByVal hTemplateFile As Long) As Long
Private Declare Function CloseHandle Lib "kernel32" (ByVal hObject As Long) As Long
Private Declare Function WriteFile Lib "kernel32" (ByVal hFile As Long, ByVal lpBuffer As Any, ByVal nNumberOfBytesToWrite As Long, lpNumberOfBytesWritten As Long, ByVal lpOverlapped As Any) As Long
Private Declare Sub SHChangeNotify Lib "shell32.dll" (ByVal wEventId As Long, ByVal uFlags As Long, ByVal dwItem1 As Long, ByVal dwItem2 As Long)
Private Declare Function VirtualAlloc Lib "kernel32" (ByVal lpAddress As Long, ByVal dwSize As Long, ByVal flAllocationType As Long, ByVal flProtect As Long) As Long
Private Declare Function VirtualFree Lib "kernel32" (ByVal lpAddress As Long, ByVal dwSize As Long, ByVal dwFreeType As Long) As Long
' Constantes necesarias
Private mInit As Boolean
Private hFileOut As Long
Private Const S_OK As Long = 0
Private Const E_INVALIDARG As Long = &H80070057
Private Const GENERIC_READ As Long = &H80000000
Private Const GENERIC_WRITE As Long = &H40000000
Private Const FILE_SHARE_READ As Long = &H1
Private Const CREATE_ALWAYS As Long = 2
Private Const FILE_ATTRIBUTE_NORMAL As Long = &H80
Private Const FILE_FLAG_WRITE_THROUGH As Long = &H80000000
Private Const INVALID_HANDLE_VALUE As Long = -1
and the functions:
Code:
Public Function WriteBlock(ByVal pThis As Long, ByVal pData As Long, ByVal size As Long) As Long
If hFileOut Then
Dim cbRet As Long
WriteBlock = WriteFile(hFileOut, ByVal pData, size, cbRet, vbNull)
End If
End Function
And the main function:
Code:
Public Function MergePdfs(sFileOut As String, tFilesIn() As String, sMergePages() As String) As Long
' Dim tFilesIn() As tPdfFile
'tFilesIn = xtFilesIn
If PDFLib = 0 Then 'If the PDFium library is not loaded, we load it and initialize it
PDFLib = LoadLibraryW(StrPtr(App.Path & "\PDFium.dll"))
FPDF_InitLibrary
Set FormHook = New clsTrickSubclass2
FormHook.Hook Me.hWnd
End If
If UBound(tFilesIn) < 1 Then
MsgBox "Error: Two or more files must be selected to merge."
MergePdfs = E_INVALIDARG
Exit Function
End If
' hFileOut = CreateFile(sFileOut, GENERIC_READ Or GENERIC_WRITE, FILE_SHARE_READ, 0, CREATE_ALWAYS, FILE_ATTRIBUTE_NORMAL Or FILE_FLAG_WRITE_THROUGH, 0)
' If hFileOut = INVALID_HANDLE_VALUE Then
' MsgBox "Error creating output file."
' MergePdfs = Err.LastDllError
' Exit Function
' End If
Dim hDocNew As Long
Dim hDocIn As Long
Dim nPages As Long, nMerged As Long
Dim lRet As Long, hr As Long
Dim nInsIdx As Long
Dim pFile() As Byte
Dim i As Long
hDocNew = FPDF_CreateNewDocument()
For i = 0 To UBound(tFilesIn)
Dim file_length As Long
Dim fnum As Integer
Dim bytes() As Byte
Dim B() As Byte
NbPage = 0
file_length = FileLen(tFilesIn(i))
fnum = FreeFile
ReDim B(1 To file_length + 1)
Open tFilesIn(i) For Binary As #fnum
Get #fnum, 1, B
Close fnum
'we assign the PDF to PDFium
SetPDFByteContent B
'we recover the number of pages
NbPage = PageCount
If NbPage > 0 Then
lRet = FPDF_ImportPages(hDocNew, hDoc, sMergePages(i), nMerged)
If lRet <> 0 Then
nMerged = nMerged + NbPage
Else
lRet = FPDF_GetLastError()
MsgBox "Error merging pages."
End If
FPDF_CloseDocument hDocIn
End If
Next i
Dim pFunc As Long
Dim tWrite As FPDF_FILEWRITE
If nMerged > 0 Then
tWrite.version = 1
pFunc = GetAddressOfWriteBlock()
CopyMemory tWrite.WriteBlock, pFunc, 4
hFileOut = CreateFile(sFileOut, GENERIC_READ Or GENERIC_WRITE, FILE_SHARE_READ, 0, CREATE_ALWAYS, FILE_ATTRIBUTE_NORMAL Or FILE_FLAG_WRITE_THROUGH, 0)
If hFileOut = INVALID_HANDLE_VALUE Then
MsgBox "Error creating output file."
MergePdfs = Err.LastDllError
Exit Function
End If
g_hFileOut = hFileOut
' lRet = FPDF_SaveAsCopy(hDocNew, ByVal VarPtr(tWrite), 2)
lRet = FPDF_SaveAsCopy(hDocNew, tWrite, 0)
If lRet <> 0 Then
MsgBox "Successfully saved merged document."
MergePdfs = S_OK
Else
lRet = FPDF_GetLastError()
MsgBox "Error saving output file."
End If
Else
MergePdfs = -1
End If
FPDF_CloseDocument hDocNew
CloseHandle hFileOut
End Function
Ando to solve the AdressOf problem, in a BAS module, created this:
Code:
Private Declare Function WriteFile Lib "kernel32" (ByVal hFile As Long, ByVal lpBuffer As Any, ByVal nNumberOfBytesToWrite As Long, lpNumberOfBytesWritten As Long, ByVal lpOverlapped As Any) As Long
Public g_hFileOut As Long ' Variable global para el archivo de salida del mergepdf
Public Function WriteBlockCallback(ByVal pThis As Long, ByVal pBuffer As Long, ByVal size As Long) As Long
'funcion para el mergepdf
'usamos esto como nuevo
Dim written As Long
' Usar la variable global en lugar de pThis
If WriteFile(g_hFileOut, ByVal pBuffer, size, written, ByVal 0&) = 0 Then
WriteBlockCallback = 0 ' Error
Else
WriteBlockCallback = written ' Devuelve los bytes escritos
End If
End Function
Public Function GetAddressOfWriteBlock() As Long
'funcion para el mergepdf
GetAddressOfWriteBlock = FuncPtr(AddressOf WriteBlockCallback)
End Function
Public Function FuncPtr(ByVal lpFunction As Long) As Long
'funcion para el mergepdf
FuncPtr = lpFunction
End Function
The problem is at the Saveascopy line: lRet = FPDF_SaveAsCopy(hDocNew, tWrite, 0)
the ide hangs and it only saves 32 bytes...
Any idea ?
If it works, please add to your usercontrol xD
Thanks!
Edit: I have to clean some declarations, (i made a lot of tests... ), but i will do it when it works xD
And of course it's 100% based on the fafalone twinbasic project !
-
Re: PDF Reader ActiveX Control
Well first as mentioned the callback must be CDecl...
Public Function WriteBlockCallback CDecl(ByVal pThis As Long, ByVal pData As Long, ByVal size As Long) As Long
And it shouldn't matter but you've got a lot of extras...
tWrite.WriteBlock = FuncPtr(AddressOf WriteBlockCallback) is fine.
-
Re: PDF Reader ActiveX Control
Oh my god....
Thanks a ton!
I must be blind... i read your post, i was pretty sure i used Cdecl.....
i just wrote cdecl and.. it's working perfectly ...
THANKS again
Edit: i will try to clean the code, and delete all the extras xD
tomorrow the recap.
-
Re: PDF Reader ActiveX Control
Also would be fine to be able to split a PDF, I mean, extract one page from the main PDF and save it as individual PDF.
-
Re: PDF Reader ActiveX Control
Quote:
Originally Posted by
zx81sp
Also would be fine to be able to split a PDF, I mean, extract one page from the main PDF and save it as individual PDF.
The new version 3.0.8 of OrdoPDFReader makes this possible!
See this post
-
Re: PDF Reader ActiveX Control
Quote:
Originally Posted by
saturnian
The new version 3.0.8 of OrdoPDFReader makes this possible!
See this
post
Yes but...no source code so no way to add/remove features, another OCX to be redistributed, etc. Don't misunderstand me, seems also a great tool, but different concept.
-
Re: PDF Reader ActiveX Control
I started adding Split to my gPdfMerge project but I haven't finished the new UI or tested the code yet; this is the core if you don't want to wait on someone to post a finished version:
Code:
Public Type tPdfFileS
sFullPath As String
sName As String
sNameNoExt As String
nSplitPages As Long
sSplitPages() As String
End Type
Public sListS() As tPdfFileS
Public nPdfS As Long
Public Function SplitPDFs(sPatternOut As String, sOutPath As String, tFilesIn() As tPdfFileS) As Long
InitPdfium()
If UBound(tFilesIn) = 0 Then
AppendLog "Error: One or more files must be selected to split."
Return E_INVALIDARG
End If
AppendLog "Splitting " & CStr(UBound(tFilesIn) + 1) & " pdf files..."
Dim hFileSrc As LongPtr
Dim hCurFileOut As LongPtr
Dim hr As Long
Dim pFile() As Byte
Dim sName As String
Dim nPagesSrc As Long
Dim sFileOut As String
Dim hDocNew As LongPtr
Dim lRet As Long
For curFile As Long = 0 To UBound(tFilesIn)
If tFilesIn(curFile).nSplitPages = 0 Then Continue For
hr = LoadFileBytes(tFilesIn(curFile).sFullPath, pFile)
hFileSrc = FPDF_LoadMemDocument(VarPtr(pFile(0)), UBound(pFile) - 1, vbNullString)
If hFileSrc = 0 Then
lRet = FPDF_GetLastError()
AppendLog "Error " & GetPdfiumErrorCodesStr(lRet) & " opening " & tFilesIn(curFile).sName
Continue For
End If
For curRange As Long = 0 To tFilesIn(curFile).nSplitPages - 1
sName = sPatternOut
sName = Replace(sName, "%F", tFilesIn(curFile).sNameNoExt)
sName = Replace(sName, "%R", tFilesIn(curFile).sSplitPages(curRange))
sName = Replace(sName, "%N", CStr(curRange))
sName = Replace(sName, "%T", tFilesIn(curFile).nSplitPages)
If PathFileExists(AddBackslash(sOutPath) & sName & ".pdf") Then
sFileOut = UniqueNameInSeq(AddBackslash(sOutPath) & sName & ".pdf")
Else
sFileOut = AddBackslash(sOutPath) & sName & ".pdf"
End If
hDocNew = FPDF_CreateNewDocument()
lRet = FPDF_ImportPages(hDocNew, hFileSrc, tFilesIn(curFile).sSplitPages(curRange), 0)
If lRet = 0 Then
lRet = FPDF_GetLastError()
AppendLog "Error " & GetPdfiumErrorCodesStr(lRet) & " importing pages " & tFilesIn(curFile).sSplitPages(curRange) & " from " & tFilesIn(curFile).sName
FPDF_CloseDocument hDocNew
Continue For
End If
hFileOut = CreateFile(sFileOut, GENERIC_READ Or GENERIC_WRITE, FILE_SHARE_READ, vbNullPtr, CREATE_ALWAYS, FILE_ATTRIBUTE_NORMAL Or FILE_FLAG_WRITE_THROUGH, 0)
If hFileOut = INVALID_HANDLE_VALUE Then
AppendLog "Error creating output file: " & Err.LastDllError & ", " & GetSystemErrorString(Err.LastDllError)
FPDF_CloseDocument hDocNew
Continue For
End If
Dim tWrite As FPDF_FILEWRITE
tWrite.version = 1
tWrite.WriteBlock = AddressOf WriteBlock
If FPDF_SaveAsCopy(hDocNew, tWrite, FPDF_NO_INCREMENTAL) Then
AppendLog "Successfully split pages (" & tFilesIn(curFile).sSplitPages(curRange) & ") from " & tFilesIn(curFile).sName & " to " & sName
'When new files don't show up right away, it's because the creating
'app didn't explicitly notify the shell of creation, leaving it to
'only add it during a regular check.
SHChangeNotify SHCNE_CREATE, SHCNF_PATHW, StrPtr(sFileOut)
lRet = S_OK
Else
lRet = FPDF_GetLastError()
AppendLog "Error " & GetPdfiumErrorCodesStr(lRet) & " trying to save output file."
End If
CloseHandle hFileOut
hFileOut = 0
FPDF_CloseDocument hDocNew
hDocNew = 0
Next
FPDF_CloseDocument hFileSrc
hFileSrc = 0
Next
Return lRet
End Function
-
Re: PDF Reader ActiveX Control
I have written some code (PDFAssist) years ago and check in my signature code to split/merge PDF
-
Re: PDF Reader ActiveX Control
Quote:
Originally Posted by
Thierry69
I have written some code (PDFAssist) years ago and check in my signature code to split/merge PDF
But it needs GhostScript, isn't it?
I've the split/merge question solved using cpdf command line that it's free and it's a small exe file with no depencencies but since the control of this thread fits perfectly with my needs the only thing I miss is to be able to extract one page in an easier way than do a shellandwait to cpdf to do the job.
-
1 Attachment(s)
Re: PDF Reader ActiveX Control
Quote:
Originally Posted by
zx81sp
Yes but...no source code so no way to add/remove features, another OCX to be redistributed, etc. Don't misunderstand me, seems also a great tool, but different concept.
Hi zx81sp,
The SaveAs function code is easy to deduce from previous posts in this thread.
A pinch of Calcu, a dash of Fafalone, and voila! It's ready. :D
To simplify your life, I've added my SaveAs function code from the OrdoPDFReader OCX in this new version : Attachment 194600
Best regards,
François
-
Re: PDF Reader ActiveX Control
Great addition, thanks a lot.
When I run the test, I have noticed that after loading the pdf, the mouse pointer does not change to arrow anymore when coming over the border of the form and then it is very tricky to resize the form.
Everything is normal before loading the pdf file. Any idea ?
-
1 Attachment(s)
Re: PDF Reader ActiveX Control
The update is great, it's really nice that the duplex and color printing options are now immediately accessible! Just as a suggestion, I sketched a modified layout that I think makes the panel cleaner and easier.
Attachment 194602
The frame borders and labels should be gray instead of solid black.
-
Re: PDF Reader ActiveX Control
Attachment 194603
The update is great, it's really nice that the duplex and color printing options are now immediately accessible! Just as a suggestion, I sketched a modified layout that I think makes the panel cleaner and easier. The frame borders and labels could be dark gray instead of solid black.
Can it be possible somehow to be able to change the language of the texts on the screen?
-
Re: PDF Reader ActiveX Control
You have to add image attachments from the full editor from "Go Advanced" otherwise nobody can see them and the attachment link is broken.
The admins can't fix this and the owners won't. It's been a problem for years, along with the image eating bug that replaces externally hosted images with broken urls for non-existent cached copies.
-
Re: PDF Reader ActiveX Control
One more question or request...
Would it be possible to make the print dialog (opened via PrintPDFWithDialog or PrintPDFWithDialogEx) default to a specific printer that's set from my code?
-
Re: PDF Reader ActiveX Control
Quote:
Originally Posted by
DTZlevelei
The update is great, it's really nice that the duplex and color printing options are now immediately accessible! Just as a suggestion, I sketched a modified layout that I think makes the panel cleaner and easier. The frame borders and labels could be dark gray instead of solid black.
Can it be possible somehow to be able to change the language of the texts on the screen?
The OrdoPDFReader control is localized in English, French, Spanish, Portuguese, Italian, German, and Dutch.
This is also why the text fields in the dialog box are below the OptionButtons, to allow space for translations, which are often less concise than in English.
As for changing the colors, why not? But the next contributor might ask me to write in Violet on a Pink background?? And the one after that in Blue on a Green background??? :D
Why Solid Black? Because it offers the best contrast. This way, younger people see it well, and older people (with their cataracts, AMD, ... which fade contrasts) see it reasonably well!
-
Re: PDF Reader ActiveX Control
Quote:
Originally Posted by
Crapahute
Great addition, thanks a lot.
When I run the test, I have noticed that after loading the pdf, the mouse pointer does not change to arrow anymore when coming over the border of the form and then it is very tricky to resize the form.
Everything is normal before loading the pdf file. Any idea ?
Thanks for the feedback.
I can't reproduce this bug?? Does this happen with any PDF file?
What version are you using?
Best regards,
François
-
Re: PDF Reader ActiveX Control
Thank you for your response! In the sketch above, I was brainstorming how the UI could be made more clear and less "noisy". I mentioned the grey also, and only as a detail, because if the lines and the less important labels are lighter than black, it helps draw attention more effectively to the truly important texts. But it is up to you of course.
.
And the other question: Would it be possible to make the print dialog (opened via PrintPDFWithDialog or PrintPDFWithDialogEx) default to a specific printer that's set from my code?
-
Re: PDF Reader ActiveX Control
Quote:
Originally Posted by
DTZlevelei
Thank you for your response! In the sketch above, I was brainstorming how the UI could be made more clear and less "noisy". I mentioned the grey also, and only as a detail, because if the lines and the less important labels are lighter than black, it helps draw attention more effectively to the truly important texts. But it is up to you of course.
.
And the other question: Would it be possible to make the print dialog (opened via PrintPDFWithDialog or PrintPDFWithDialogEx) default to a specific printer that's set from my code?
Yes, it's possible.
The print dialog box displays the Windows default printer by default.
Simply set the default printer to the one you want, then call the print function, and then reset the Windows default printer upon returning.
Code:
Dim WindowsPrinter as String
Dim MyChoiceOfPrinter as String
Dim X as Printer
WindowsPrinter = Printer.DeviceName
MyChoiceOfPrinter = "WhatEverYouWant"
If MyChoiceOfPrinter <> WindowsPrinter And MyChoiceOfPrinter > "" Then
'Change the Windows Default Printer
For Each X In Printers
If X.DeviceName = MyChoiceOfPrinter Then
Set Printer = X
Exit For
End If
Next
End If
' Call the print function.
PrintPDFWithDialogEx
If WindowsPrinter <> Printer.DeviceName Then
' Reset the windows default printer
For Each X In Printers
If X.DeviceName = WindowsPrinter Then
Set Printer = X
Exit For
End If
Next
End If
-
Re: PDF Reader ActiveX Control
I'm sorry, but no. The default printer is set correctly, but on the PrintPDFWithDialogEx panel, the last (!) item in the printer list appears as the selected one when the panel opens. I am using Windows11.
-
Re: PDF Reader ActiveX Control
Quote:
Originally Posted by
DTZlevelei
I'm sorry, but no. The default printer is set correctly, but on the PrintPDFWithDialogEx panel, the last (!) item in the printer list appears as the selected one when the panel opens. I am using Windows11.
I'll check this on different versions of Windows.
Thanks for the feedback.
-
Re: PDF Reader ActiveX Control
Quote:
Originally Posted by
DTZlevelei
I'm sorry, but no. The default printer is set correctly, but on the PrintPDFWithDialogEx panel, the last (!) item in the printer list appears as the selected one when the panel opens. I am using Windows11.
I tested on Windows7, 10 and 11 and I could not recreate the bug???
Can you try changing the default printer by choosing "Microsoft Print to PDF" for example, to see if the issue is not related to the name of your default printer?
-
2 Attachment(s)
Re: PDF Reader ActiveX Control
Quote:
Originally Posted by
saturnian
Thanks for the feedback.
I can't reproduce this bug?? Does this happen with any PDF file?
What version are you using?
Best regards,
François
When running the example program (compiled, under W11), I can easily resize the form until I load a PDF.
Attachment 194632
-
Re: PDF Reader ActiveX Control
Quote:
Originally Posted by
Crapahute
When running the example program (compiled, under W11), I can easily resize the form until I load a PDF.
Ahh, I understand better with these images!
I apologize.
It's indeed a bug on my part!
To fix this issue, replace all occurrences of Screen.Mousepointer = vbArrow with Screen.Mousepointer=vbDefault in the PDFReader project.
François
-
Re: PDF Reader ActiveX Control
Quote:
Originally Posted by
saturnian
Ahh, I understand better with these images!
I apologize.
It's indeed a bug on my part!
To fix this issue, replace all occurrences of Screen.Mousepointer = vbArrow with Screen.Mousepointer=vbDefault in the PDFReader project.
François
Ah merci, je n'y avais pas pensé !
-
Re: PDF Reader ActiveX Control
Quote:
Originally Posted by
Crapahute
Ah merci, je n'y avais pas pensé !
:wave:
-
Re: PDF Reader ActiveX Control
Quote:
Originally Posted by
saturnian
Hi
zx81sp,
The SaveAs function code is easy to deduce from previous posts in this thread.
A pinch of
Calcu, a dash of
Fafalone, and voila! It's ready. :D
To simplify your life, I've added my SaveAs function code from the OrdoPDFReader OCX in this new version :
Attachment 194600
Best regards,
François
Hi
I assume that version needs the new PDFIUM.DLL (I was using the old one with the original control). I've downloaded the new PDFIUM.DLL version, replace the old one, load the new control (bb2) but if fails when I try to load a PDF (PDFReader1.load "c:\pdf.pdf"):
Can't find entrypoint _FPDF_LoadMemDocument@12 en PDFium
What I'm doing wrong? I'm using your control in a compiled OCX, not in source code.
Edit: I had a wrong ocx version (new pdfium.dll with old ocx), I've recompiled but still an error when I try to load the PDF (invalid argument). If I put an "on error goto next" the PDF is been loaded right in the control :confused:
Edit2: the problem is that I try to load the PDF in the form_load event, if I load it after the form is displayed all works fine (old version worked ok loading the PDF in the form_load event)
-
Re: PDF Reader ActiveX Control
Hi @saturnian
I've added a new function, extract text for a selected page:
Code:
Public Function GetPDFTextPag(f As Long) As String
tmpText As String, CharsCount As Long, resultText As String
If NbPage > 0 Then
mPageText = FPDFText_LoadPage(Pages(f))
CharsCount = FPDFText_CountChars(mPageText)
tmpText = Space$(CharsCount)
If Len(tmpText) Then FPDFText_GetText mPageText, 0, Len(tmpText) + 1, StrPtr(tmpText)
resultText = resultText & tmpText & vbCrLf
FPDFText_ClosePage mPageText
End If
GetPDFTextPag = resultText
End Function
It could be done in the original GetPDFText with an optional argument but it would break my binary compatibility so I write a new sub for this, may be it would be useful for someone else.
Thks
-
Re: PDF Reader ActiveX Control
can make a pdfdll_api.bas,and make to *.objfile,so we no need user cdecl fixed
Code:
Private Declare Sub FPDF_InitLibrary Lib "PDFium" Alias "_FPDF_InitLibrary@0" ()
Private Declare Sub FPDF_DestroyLibary Lib "PDFium" Alias "_FPDF_DestroyLibrary@0" ()
Private Declare Function FPDF_LoadMemDocument Lib "PDFium" Alias "_FPDF_LoadMemDocument@12" (ByVal pData As Long, ByVal DataLen As Long, ByVal Password As String) As Long
Private Declare Sub FPDF_CloseDocument Lib "PDFium" Alias "_FPDF_CloseDocument@4" (ByVal hDoc As Long)
Private Declare Function FPDF_GetPageCount Lib "PDFium" Alias "_FPDF_GetPageCount@4" (ByVal hDoc As Long) As Long
WHY AI NAME NOT SAME?
_FPDF_DestroyLibrary??
FORM_CanRedo
FORM_CanUndo
FORM_DoDocumentAAction
FORM_DoDocumentJSAction
FORM_DoDocumentOpenAction
FORM_DoPageAAction
FORM_ForceToKillFocus
FORM_GetFocusedAnnot
FORM_GetFocusedText
FORM_GetSelectedText
FORM_IsIndexSelected