Page 3 of 3 FirstFirst 123
Results 81 to 91 of 91

Thread: PDF Reader ActiveX Control

  1. #81

    Thread Starter
    Addicted Member saturnian's Avatar
    Join Date
    Dec 2017
    Location
    France
    Posts
    134

    Re: PDF Reader ActiveX Control

    Quote Originally Posted by DTZlevelei View Post
    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

  2. #82
    New Member
    Join Date
    Mar 2025
    Posts
    6

    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.

  3. #83

    Thread Starter
    Addicted Member saturnian's Avatar
    Join Date
    Dec 2017
    Location
    France
    Posts
    134

    Re: PDF Reader ActiveX Control

    Quote Originally Posted by DTZlevelei View Post
    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.

  4. #84

    Thread Starter
    Addicted Member saturnian's Avatar
    Join Date
    Dec 2017
    Location
    France
    Posts
    134

    Re: PDF Reader ActiveX Control

    Quote Originally Posted by DTZlevelei View Post
    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?

  5. #85
    Lively Member
    Join Date
    Mar 2020
    Posts
    84

    Re: PDF Reader ActiveX Control

    Quote Originally Posted by saturnian View Post
    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.

    Name:  fleches.jpg
Views: 3144
Size:  24.2 KB
    Attached Images Attached Images  
    Last edited by Crapahute; Apr 22nd, 2025 at 12:59 AM.

  6. #86

    Thread Starter
    Addicted Member saturnian's Avatar
    Join Date
    Dec 2017
    Location
    France
    Posts
    134

    Re: PDF Reader ActiveX Control

    Quote Originally Posted by Crapahute View Post
    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

  7. #87
    Lively Member
    Join Date
    Mar 2020
    Posts
    84

    Re: PDF Reader ActiveX Control

    Quote Originally Posted by saturnian View Post
    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é !

  8. #88

    Thread Starter
    Addicted Member saturnian's Avatar
    Join Date
    Dec 2017
    Location
    France
    Posts
    134

    Re: PDF Reader ActiveX Control

    Quote Originally Posted by Crapahute View Post
    Ah merci, je n'y avais pas pensé !

  9. #89
    Addicted Member
    Join Date
    Aug 2023
    Posts
    201

    Re: PDF Reader ActiveX Control

    Quote Originally Posted by saturnian View Post
    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 : 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

    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)
    Last edited by zx81sp; May 2nd, 2025 at 03:14 AM.

  10. #90
    Addicted Member
    Join Date
    Aug 2023
    Posts
    201

    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
    Last edited by zx81sp; May 2nd, 2025 at 04:04 AM.

  11. #91
    PowerPoster
    Join Date
    Jan 2020
    Posts
    5,541

    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
    Last edited by xiaoyao; May 12th, 2025 at 10:06 PM.

Page 3 of 3 FirstFirst 123

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width