-
Sep 19th, 2024, 12:13 PM
#41
Thread Starter
Lively Member
Re: PDF Reader ActiveX Control
 Originally Posted by KFrosty
can't make an executable file out of it. Says the .vbp is not a compatible binary file. Anyone else have this problem ?
This issue occurs because the ocx has not been compiled and the interpreted test project is only linked to the uncompiled component.
To fix this:
- Load the PDFReader.vbg project group, close all code and design Windows
- Compile the OrdoPDFReader ocx for the first time
- Then modify the PDF_Reader project properties: Component tab: Version Compatibility: Binary Compatibility: Choose OrdoPDFReader.ocx
- Compile OrdoPDFReader.ocx again for a 2nd time
- SAVE the project group
- Quit VB6 and restart it, load the PDFReader.vbg project group
- It should be possible to compile the TestPDFReader Test project!
I hope this will solve your problem
Best Regards
François
-
Oct 3rd, 2024, 03:33 PM
#42
Re: PDF Reader ActiveX Control
Microsoft has plans to scrap the Windows 7 operating system. In conjunction with Intel, the new CPU does not offer Win7 graphics drivers.
In terms of software and many other aspects, we should actively shut down many excellent software projects or operating systems.
It's like every time the Apple system is updated or forced to push. It is hoped that the old users will feel that the mobile phone is very slow, and then they have to buy a new mobile phone.
There is a programmer in China who can even recompile the XP ie source code into a very small single DLL file.
Just like the tool you use to display PDF pages.
In the past, a web browser kernel was only 3 to 10 MB in size, but now new browsers have reached 500 MB-1gb
Lots of great open source UI components or something like libcurl, lIBMysql. DLL.
Because of the incompatibility of various systems, there may be fewer functions or abnormal operation.
So we also need a good package manager. There are also a large number of various third-party component DLLs.
It needs to show compatibility with various operating systems.
Perhaps this requires that twinbasic provide the server and technology. Realize NPM. Exe and nuget. Exe for VB6 users.
Last edited by xiaoyao; Oct 8th, 2024 at 08:57 AM.
-
Oct 4th, 2024, 08:46 AM
#43
Re: PDF Reader ActiveX Control
This is not really a thread about different OS. If people want to stick with older operating systems, that is up to them, but they do get to contend with the consequences of doing so. That's also up to them, and a good topic for a different thread.
My usual boring signature: Nothing
 
-
Oct 8th, 2024, 07:05 AM
#44
Thread Starter
Lively Member
Re: PDF Reader ActiveX Control
@Xiaoyao
Your off-topic posts that are polluting the discussion threads are becoming unbearable!
You're completely discrediting yourself, and like many others, I've come to ignore all of your contributions (I was forced to read this one since I started this thread!)
Our moderators are very kind and magnanimous!
Please follow their advice and create new threads when an idea comes to mind.
-
Oct 8th, 2024, 09:01 AM
#45
Re: PDF Reader ActiveX Control
sorry A little off topic.
I hope that some source codes developed can indicate whether they support 64-bit VBA/TWINBASC,32 and 32-bit systems, and whether they support XP, Win 10 and Win 11.
It would be better if 64-bit and 32-bit DLLs could be provided at the same time. For example, the COM static editing package of SQLIT3 is only available in 32-bit version at present.
-
Oct 8th, 2024, 09:08 AM
#46
Re: PDF Reader ActiveX Control
 Originally Posted by Nouyana
Thank you, saturnian!
So I need someone who can rebuild the project and remove the dependencies on "ieshims.dll" and "wer.dll". It seems too complicated task for me.
ieshims.dll is an artefact of Vista/7 where a shim DLL is used to proxy certain calls (such as CreateProcess) to handle protected mode IE, which doesn't exist on XP, so it is unnecessary. wer.dll is related to Windows Error Reporting and again is probably unused on Windows XP which has a slightly different error reporting system than Vista and above.
VeryPDF PDFView OCX v2.1.0.1
http://www.verydoc.com/pdf-viewer-ocx.html
VeryDOC PDF Viewer OCX Control (ActiveX) is a PDF file viewer component. PDF Viewer OCX Control provides a standalone embeddable PDF Viewer for windows application developers. Using Visual Basic, VC, Delphi, C#, HTML (Internet Explorer) or any other programming languages or tools been able to handle ActiveX controls, developers can build a customer interface for viewing PDF documents. PDF documents can be loaded from disk files easily. PDF Viewer OCX Control is usually used to quickly display PDF files created by any PDF creation software. If you need to embed a PDF viewer into your application without depend on Adobe Reader, VeryDOC PDF Viewer OCX control will be your best choice.
Features:
View PDF Documents quickly, without depend on Adobe Reader
Provide the developer with full control over the PDF viewer, you can add PDF viewing capability to your applications easily
Search a PDF document for a specific text
Jump to an outline object destination
Display document outlines
Scroll/Zoom the viewer window (Actual Page, Fit Page, Fit Width, ..)
View PDF pages in different layout modes (Single Page, Facing, Continuous, Continuous Facing)
Select text on the PDF pages, copy text to clipboard
Support for PDF hyperlinks
Region highlighting for text search
Work with Visual Basic, Delphi, Internet Explorer, and any other ActiveX-compatible development environment
Support all version of Acrobat PDF files
Support 2000/XP/Vista, 32bit and 64bit, Windows platforms
-
Dec 6th, 2024, 12:49 PM
#47
Addicted Member
Re: PDF Reader ActiveX Control
@saturnian, do you think it's so complicated to create a Merge/ split pdf function ?
i'm trying to do it but.. :-(
Edit: and.. updating to a new pdfium.dll (https://github.com/bblanchon/pdfium-binaries/releases) will be hard to do i think, isn't it ?
Last edited by Calcu; Dec 6th, 2024 at 01:49 PM.
-
Dec 7th, 2024, 10:35 AM
#48
Thread Starter
Lively Member
Re: PDF Reader ActiveX Control
 Originally Posted by Calcu
I will try to take a look at this as soon as I have a free moment.
-
Dec 7th, 2024, 12:16 PM
#49
Re: PDF Reader ActiveX Control
 Originally Posted by Calcu
I made such a program in twinBASIC. The most recent version uses newer bblanchon pdfium builds; then if you get the old version it uses the 8 year old outdated pvginkel builds which the only advantage is using stdcall, however to do this in VB6 instead you'd need The trick's VBCdeclFix anyway even with the older pdfium builds because the write callback must be CDecl. All the more reason to just use tB ...or at very least the new pdfium builds since you can't avoid _cdecl if you're going to use the FPDF_SaveAsCopy function.
[twinBASIC] gPdfMerge - A GUI-based PDF merger
https://github.com/fafalone/gPdfMerge
As mentioned, the first version of the project, which doesn't have the search for pages function and a couple other enhancements, uses the same pvginkel builds as this project: https://github.com/fafalone/gPdfMerg...a3a92fea52361f
--
I've been meaning to port saturnian's wonderful project here to tB/64bit too but haven't had time yet.
Last edited by fafalone; Dec 7th, 2024 at 12:29 PM.
-
Dec 8th, 2024, 11:04 AM
#50
Addicted Member
Re: PDF Reader ActiveX Control
I tried to do by myself, but my knowlegde is not enough.
I didn't knew about trick's VBCdeclFix, let's see if i can implement it.
I will take a look at twinbasic too, just downloaded it and executed... seems pretty "VB6" to me xD, i hope the learning curve will be easy for me
-
Dec 8th, 2024, 12:28 PM
#51
Re: PDF Reader ActiveX Control
twinBASIC is meant to be fully backwards compatible with VB6. Essentially a real VB7. That's why I answer with code from it or links to projects for it; it's the same language, and usually backporting to VB6 when new features are used is very simple .
VBCDeclFix is an addin for VB6 that lets you use CDecl in API declares and functions. All you have to do is enable it and then you can use the CDecl keyword in VB6, e.g. Private Declare Function FPDF_SaveAsCopy CDecl Lib "pdfium" ... and Private Function WriteBlock CDecl(.... In twinBASIC no addin is needed; that's supported natively with the same syntax.
-
Dec 19th, 2024, 09:13 AM
#52
Re: PDF Reader ActiveX Control
Hey so I've been working on a 64-bit compatible twinBASIC port, which also uses the newer pdfium builds from https://github.com/bblanchon/pdfium-binaries/releases
I'm actually having a bit of trouble getting the VB6 version to work for comparison; I was wondering if someone could provide some feedback about glitches so I know if they're tB bugs or general rendering bugs...
https://github.com/fafalone/OrdoPdfReader64
The test project ports in the win32 and win64 folders will need to remove the old control/reference and re-place it if you use them; I set everything to be an entirely new control before posting (this means it won't interfere with the original if you have it).
-
Dec 19th, 2024, 02:18 PM
#53
Thread Starter
Lively Member
Re: PDF Reader ActiveX Control
I made a new version of PDF Reader that uses the new compilations of Pdfium by Benoit Blanchon.
This version includes the improvement of the printing of post 29 and the display by bitblt proposed by jtw400 post 35
For this to work, it is imperative to load in the VB6 IDE the complement of "The Trick" VBCdeclFix
The source is downloadable here
I will try to take the example of Fafalone's TwinBasic gPdfMerge code to integrate a MergePDF function.
I need to install TwinBasic to try to understand the problems that Fafalone encounters during his porting test.
Best wishes to all!
François
NB: The first post has been updated with these new features.
Last edited by saturnian; Dec 20th, 2024 at 08:11 AM.
-
Dec 19th, 2024, 03:14 PM
#54
Addicted Member
Re: PDF Reader ActiveX Control
Thanks both
i will try to use the new version and try to beta-test the fafalone version ! (this way i will begin with TB)
-
Mar 4th, 2025, 11:44 AM
#55
New Member
Re: PDF Reader ActiveX Control
Hi everyone! This PDF project is really great, and when I integrated into my own program, it basically works well... except for one thing. The PrintPDFWithDialog function brings up the print dialog, I select the printer and then press "Print" but nothing happens. What could be the reason for this? The regular PrintPDF prints just fine.
Another question/idea: Would it be possible to add options for duplex printing and color/b&w selection to the PrintPDF function?
And one more thing: The PrintPDFWithDialog function mentioned above is not documented in the Help section here: https://freeware.ordoconcept.net/help/OrdoPDFReader3/
-
Mar 5th, 2025, 12:36 PM
#56
Thread Starter
Lively Member
Re: PDF Reader ActiveX Control
 Originally Posted by DTZlevelei
Hi everyone! This PDF project is really great, and when I integrated into my own program, it basically works well... except for one thing. The PrintPDFWithDialog function brings up the print dialog, I select the printer and then press "Print" but nothing happens. What could be the reason for this? The regular PrintPDF prints just fine.
I can't reproduce this issue on Windows 10. What printer do you select and on what OS? What version of OrdoPDFReader are you using?
Another question/idea: Would it be possible to add options for duplex printing and color/b&w selection to the PrintPDF function?
In the next version a PrintPDFEx method will allow you to select duplex mode and monochrome or color printing in addition to the already available settings
Best regards
François
-
Mar 6th, 2025, 11:28 AM
#57
Addicted Member
Re: PDF Reader ActiveX Control
Hi!
Found some time finally to test the new version, i couldn't compile it, and neither execute it.
Then i created a new project from scratch, added your usercontrol, all the classes and bas modules and it worked like a charm. I compiled this project and worked too.
BUT
i tried to use the new usercontrol in my big project (the one that was using your previous version) and .... in IDE it works perfect, but when i compile it, it fails doing FPDF_InitLibrary
any idea why it works in a new project, but no in an old one (that was using your last version of the usercontrol) ?
Thanks for everything!
Ah.. is this a mistake? i can see:
Private Declare Sub FPDF_DestroyLibary CDecl Lib "pdfium.dll" ()
Maybe it has to be FPDP_DestroyLibRary ?
Last edited by Calcu; Mar 6th, 2025 at 11:31 AM.
-
Mar 6th, 2025, 01:06 PM
#58
Thread Starter
Lively Member
Re: PDF Reader ActiveX Control
 Originally Posted by Calcu
Hi!
Found some time finally to test the new version, i couldn't compile it, and neither execute it.
Then i created a new project from scratch, added your usercontrol, all the classes and bas modules and it worked like a charm. I compiled this project and worked too.
BUT
i tried to use the new usercontrol in my big project (the one that was using your previous version) and .... in IDE it works perfect, but when i compile it, it fails doing FPDF_InitLibrary
any idea why it works in a new project, but no in an old one (that was using your last version of the usercontrol) ?
Thanks for everything!
Hi Calcu,
Are you sure which version of pdfium.dll you are loading in your old updated project? To avoid confusion I renamed the new dlll Pdfium_X86.dll, which allows you to have both versions on the same system without any risk of confusion.
Is the VB6 CDeclFix add-in from The Trick active in your IDE when you use the code of the new version?
Ah.. is this a mistake? i can see:
Private Declare Sub FPDF_DestroyLibary CDecl Lib "pdfium.dll" ()
Maybe it has to be FPDP_DestroyLibRary ?
That's a typo, indeed.
Best regards
François
-
Mar 6th, 2025, 01:22 PM
#59
Addicted Member
Re: PDF Reader ActiveX Control
Hi!
Tried everything and found the problem/solution!
I was compiling to P-Code, just changed to Native code, optimized to fast code, and now it works !
It was a nonsense if it was working on IDE, but not compiled...
Waiting for your merge function xD
-
Mar 7th, 2025, 07:11 AM
#60
Re: PDF Reader ActiveX Control
I've posted an updated x64 compatible tB version with the new changes merged in. The BitBlt rendering got rid of the glitches I noticed last time, but consider this a BETA for testing only while I try to figure out an issue I'm having with MouseDown; it's making Windows UI freak out; causing flashing/redrawing of all windows while the mouse lags. Unknown if the VB6 version does this to and it's a me issue, but I won't get a chance to investigate til tomorrow and wanted to go ahead and post it.
https://github.com/fafalone/OrdoPdfReader64
OrdoPDFReader64v2.twinproj
NOTE: It's configured to compile as an entirely separate control; it doesn't interfere with the VB6 version or my previous tB version. If you want to change this behavior, you'll have to put back the project and class names, project guid, typelib version, and class id/interface id/event interface id to the old one. I left the old file up.
-
Mar 7th, 2025, 11:50 AM
#61
Thread Starter
Lively Member
Re: PDF Reader ActiveX Control
 Originally Posted by Calcu
...
Waiting for your merge function xD
Hi,
Just ask ! 
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
-
Mar 7th, 2025, 02:52 PM
#62
Re: PDF Reader ActiveX Control
 Originally Posted by saturnian
Hi,
Just ask ! 
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
Last edited by fafalone; Mar 7th, 2025 at 03:02 PM.
-
Mar 12th, 2025, 01:58 PM
#63
Addicted Member
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 !
Last edited by Calcu; Mar 12th, 2025 at 02:04 PM.
-
Mar 12th, 2025, 03:16 PM
#64
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.
Last edited by fafalone; Mar 12th, 2025 at 03:26 PM.
-
Mar 12th, 2025, 03:37 PM
#65
Addicted Member
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.
-
Mar 18th, 2025, 09:08 AM
#66
Addicted Member
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.
-
Apr 15th, 2025, 12:43 PM
#67
Thread Starter
Lively Member
Re: PDF Reader ActiveX Control
 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
-
Apr 16th, 2025, 01:18 PM
#68
Addicted Member
Re: PDF Reader ActiveX Control
 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.
-
Apr 16th, 2025, 01:49 PM
#69
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
-
Apr 16th, 2025, 02:18 PM
#70
Re: PDF Reader ActiveX Control
I have written some code (PDFAssist) years ago and check in my signature code to split/merge PDF
-
Apr 17th, 2025, 04:51 AM
#71
Addicted Member
Re: PDF Reader ActiveX Control
 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.
-
Apr 17th, 2025, 12:26 PM
#72
Thread Starter
Lively Member
Re: PDF Reader ActiveX Control
 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. 
To simplify your life, I've added my SaveAs function code from the OrdoPDFReader OCX in this new version : PdfReader.bb2.zip
Best regards,
François
-
Apr 18th, 2025, 02:41 AM
#73
Member
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 ?
-
Apr 18th, 2025, 05:58 AM
#74
New Member
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.

The frame borders and labels should be gray instead of solid black.
-
Apr 18th, 2025, 06:07 AM
#75
New Member
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?
Last edited by DTZlevelei; Apr 18th, 2025 at 06:18 AM.
-
Apr 18th, 2025, 06:17 AM
#76
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.
-
Apr 18th, 2025, 01:33 PM
#77
New Member
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?
-
Apr 19th, 2025, 08:41 AM
#78
Thread Starter
Lively Member
Re: PDF Reader ActiveX Control
 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??? 
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!
-
Apr 20th, 2025, 04:40 AM
#79
Thread Starter
Lively Member
Re: PDF Reader ActiveX Control
 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
-
Apr 20th, 2025, 09:32 AM
#80
New Member
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?
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|