PDF Image converter for PB

2025-12-10 0 857

PDF to Image Converter .NET Library For PowerBuilder

This is a .NET library that converts PDF files to PNG images while maintaining the original PDF dimensions.
The library is specifically designed to be used with PowerBuilder applications.
but other COM or anyway to invoke .NET(C#) DLL invoking way can works

Features

  • Convert PDF files to PNG images
  • Maintains original PDF dimensions
  • Supports multi-page PDFs
  • Configurable DPI settings
  • COM-visible for use in PowerBuilder

Requirements

  • .NET Framework 4.8.1 SDK for Development with build tool(select 1 of 2 options)
    • Visual Studio 2019 or later for building the library
    • .NET 8 SDK for building the library
  • PowerBuilder 2019 R3 or later

Building the Library

  1. Open the solution in Visual Studio
  2. Build the solution in Release mode
  3. if you want to build with dotnet cli(cause of not having visual studio)
    dotnet build PdfToImageConverter.csproj --configuration Release

Usage in PowerBuilder

  1. Use PowerBuilder\’s \”.NET DLL Importer\” tool to import the assembly:

    • Open your PowerBuilder project
    • Select Tools → \”.NET DLL Importer\”
    • Browse to and select \”PdfToImageConverter.dll\”
      • Un-Zip release assets and select \”PdfToImageConverter.dll\”
      • Asset name is \”PdfToImageConverter-Full.zip\”
    • Generate the proxy object
  2. Create an instance of the converter:

    nvo_pdfconverter lnvo_pdfconverter // if you use other name for the proxy object need to change the name in the code
    lnvo_pdfconverter = Create nvo_pdfconverter 

    but PB IDE automatic created proxy object name and function name shown as readme example

  3. Convert PDF to PNG:

    string ls_result
    ls_result = lnvo_pdfconverter.of_convertpdftoimage(\"C:\\input.pdf\", \"C:\\output.png\", 300)
    
    if Left(ls_result, 7) = \"SUCCESS\" then
        MessageBox(\"Success\", ls_result)
    else
        MessageBox(\"Error\", ls_result)
    end if
  4. Convert PDF to PNG with page names:

    string ls_result
    string ls_page_names[]
    ls_page_names[1] = \"Apple\"
    ls_page_names[2] = \"Banana\"
    ls_result = lnvo_pdfconverter.of_ConvertPdfToImageWithPageNames(\"C:\\input.pdf\", \"C:\\output.png\", 300, 2, ls_page_names)
  5. Convert PDF to PNG with page names and custom output paths:

    string ls_result
    string ls_page_names[]
    string ls_output_paths[]
    ls_page_names[1] = \"Apple\"
    ls_page_names[2] = \"Banana\"
    ls_output_paths[1] = \"C:\\output\\folder1\"
    ls_output_paths[2] = \"C:\\output\\folder2\"
    ls_result = lnvo_pdfconverter.of_ConvertPdfToImageWithPageNamesAndOutputPaths(\"C:\\input.pdf\", \"C:\\output.png\", 300, 2, ls_page_names, ls_output_paths)

Parameters

  • pdfPath: Full path to the input PDF file
  • outputPath: Full path for the output PNG file
  • dpi: Optional. DPI value for the output image (default: 300)

for ConvertPdfToImageWithPageNames method required some additional parameters:

  • totalPagesNumber: Total number of pages in the PDF
  • pageNames: Array of page names for the output images

for ConvertPdfToImageWithPageNamesAndOutputPaths method required these parameters:

  • outputPaths: Array of output directory names for each page
  • totalPagesNumber: Total number of pages in the PDF
  • pageNames: Array of page names for the output images

Multi-page PDFs

When converting multi-page PDFs, the library will automatically append page numbers to the output filename:

  • Single page: output.png
  • Multi-page: output_page1.png, output_page2.png, etc.

If you want to use your own page names, you can use ConvertPdfToImageWithPageNames method.

  • Ensure the totalPagesNumber is correct
  • Ensure the pageNames array is the same size as the number of pages in the PDF
  • then you got specific page names for each page like
    • Apple.png
    • Banana.png

If you want to specify custom output paths for each page, you can use ConvertPdfToImageWithPageNamesAndOutputPaths method.

  • Ensure the outputPaths array contains valid directory paths for each page
  • Ensure the pageNames array contains the desired filenames for each page
  • then you got specific page names in specific folders like
    • C:\\output\\folder1\\Apple.png
    • C:\\output\\folder2\\Banana.png

Error Handling

The conversion method returns a string starting with either \”SUCCESS\” or \”ERROR\” followed by additional details. Make sure to handle both cases in your PowerBuilder code as shown in the usage example above.

Acknowledgements

  • PDFtoImage for the PDF conversion library

Certainly! Here’s a COM-based usage example you can add to your README for users who want to use the PDF-Image Converter .NET DLL via COM (e.g., from VBScript, VBA, or other COM-aware environments).


Usage via COM (VBScript Example)

If you want to use the PDF-Image Converter library from a COM-based language (like VBScript, VBA, or classic ASP), make sure the DLL is registered as a COM-visible assembly.
You must register the DLL using regasm.exe and ensure all dependencies are available.

1. Register the DLL for COM

Open a command prompt as Administrator and run:

regasm PdfToImageConverter.dll /codebase

If you need to create a type library (.tlb):

regasm PdfToImageConverter.dll /codebase /tlb:PdfToImageConverter.tlb

Note: On 64-bit Windows, use the 64-bit regasm.exe for 64-bit clients, and the 32-bit version for 32-bit clients.

2. Example Usage in VBScript

Create a file named convert_pdf.vbs with the following contents:

\' Create the COM object
Set converter = CreateObject(\"PdfToImageConverter.PdfConverter\")

\' Convert a PDF to PNG
pdfPath = \"C:\\input.pdf\"
outputPath = \"C:\\output.png\"
dpi = 300

result = converter.ConvertPdfToImage(pdfPath, outputPath, dpi)

If Left(result, 7) = \"SUCCESS\" Then
    MsgBox \"Success: \" & result
Else
    MsgBox \"Error: \" & result
End If

3. Example Usage in VBA (e.g., Excel Macro)

Sub ConvertPDF()
    Dim converter As Object
    Set converter = CreateObject(\"PdfToImageConverter.PdfConverter\")
    
    Dim pdfPath As String
    Dim outputPath As String
    Dim dpi As Integer
    Dim result As String

    pdfPath = \"C:\\input.pdf\"
    outputPath = \"C:\\output.png\"
    dpi = 300

    result = converter.ConvertPdfToImage(pdfPath, outputPath, dpi)

    If Left(result, 7) = \"SUCCESS\" Then
        MsgBox \"Success: \" & result
    Else
        MsgBox \"Error: \" & result
    End If
End Sub

4. Notes

  • The ProgID/class name (PdfToImageConverter.PdfConverter) may differ depending on your assembly’s namespace and class.
    Check your DLL\’s exposed class name or use OLE/COM Object Viewer to confirm.
  • You must ensure the assembly is registered as COM visible and all dependencies are present.
  • For advanced functions (like page names or custom output paths), you may need to pass arrays.
    COM clients like VBScript may not support passing arrays easily—consider using PowerBuilder or .NET clients for those features.

Would you like a sample for another COM-capable language or more details on DLL registration?

下载源码

通过命令行克隆项目:

git clone https://github.com/yuseok-kim-edushare/PDF-Image-converter-for-PB.git

收藏 (0) 打赏

感谢您的支持,我会继续努力的!

打开微信/支付宝扫一扫,即可进行扫码打赏哦,分享从这里开始,精彩与您同在
点赞 (0)

申明:本文由第三方发布,内容仅代表作者观点,与本网站无关。对本文以及其中全部或者部分内容的真实性、完整性、及时性本站不作任何保证或承诺,请读者仅作参考,并请自行核实相关内容。本网发布或转载文章出于传递更多信息之目的,并不意味着赞同其观点或证实其描述,也不代表本网对其真实性负责。

左子网 编程相关 PDF Image converter for PB https://www.zuozi.net/33272.html

TSubclass
上一篇: TSubclass
常见问题
  • 1、自动:拍下后,点击(下载)链接即可下载;2、手动:拍下后,联系卖家发放即可或者联系官方找开发者发货。
查看详情
  • 1、源码默认交易周期:手动发货商品为1-3天,并且用户付款金额将会进入平台担保直到交易完成或者3-7天即可发放,如遇纠纷无限期延长收款金额直至纠纷解决或者退款!;
查看详情
  • 1、描述:源码描述(含标题)与实际源码不一致的(例:货不对板); 2、演示:有演示站时,与实际源码小于95%一致的(但描述中有”不保证完全一样、有变化的可能性”类似显著声明的除外); 3、发货:不发货可无理由退款; 4、安装:免费提供安装服务的源码但卖家不履行的; 5、收费:价格虚标,额外收取其他费用的(但描述中有显著声明或双方交易前有商定的除外); 6、其他:如质量方面的硬性常规问题BUG等。 注:经核实符合上述任一,均支持退款,但卖家予以积极解决问题则除外。
查看详情
  • 1、左子会对双方交易的过程及交易商品的快照进行永久存档,以确保交易的真实、有效、安全! 2、左子无法对如“永久包更新”、“永久技术支持”等类似交易之后的商家承诺做担保,请买家自行鉴别; 3、在源码同时有网站演示与图片演示,且站演与图演不一致时,默认按图演作为纠纷评判依据(特别声明或有商定除外); 4、在没有”无任何正当退款依据”的前提下,商品写有”一旦售出,概不支持退款”等类似的声明,视为无效声明; 5、在未拍下前,双方在QQ上所商定的交易内容,亦可成为纠纷评判依据(商定与描述冲突时,商定为准); 6、因聊天记录可作为纠纷评判依据,故双方联系时,只与对方在左子上所留的QQ、手机号沟通,以防对方不承认自我承诺。 7、虽然交易产生纠纷的几率很小,但一定要保留如聊天记录、手机短信等这样的重要信息,以防产生纠纷时便于左子介入快速处理。
查看详情

相关文章

猜你喜欢
发表评论
暂无评论
官方客服团队

为您解决烦忧 - 24小时在线 专业服务