How to convert PDF to image and modify PDF in various programming languages

In this article, you will know how to use SDK to convert PDF to image and modify PDF in support programming languages. If interested, please keep reading it here.

Here, tool we use is VeryDOC PDF Parser & Modify SDK. It supports converting PDF file to image files, e.g., PDF to PNG, PDF to JPG, PDF to BMP, PDF to JP2, etc.. Moreover, it enables you to modify PDF files in text content, edit image resolution/color depth, process password protected PDF files, extract text from source PDF files, etc.. Most import, this tool could be used as a component to design your own tools by integrating supported functions to those tools flexibly, which could be processed in various programming languages, such as VB, VC++, Delphi, ASP, VB.NET, C#, etc..

Want to know more about this tool and this related topic? The following examples unveil more info after you get trial version VeryDOC PDF Parser & Modify SDK:

VB.NET example to show you how to convert PDF file to image file and modify PDF file by text:

Private Sub DiskFile_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles TestSDK.Click

Dim nRet As Integer

Dim strOptions As String

Dim strInPDFFile As String

Dim strOutFile As String

Dim strLogMsg As String

Dim nDPI As Integer = 300

'Render PDF pages to PNG image files first

strInPDFFile = Application.StartupPath() & "\example1.pdf"

strOutFile = Application.StartupPath() & "\out.png"

strOptions = "-r " & CStr(nDPI) & " -$ XXXXXXXXXXXXXXXXXXXX"

nRet = VeryPDF_PDFParserSDK(strInPDFFile, strOutFile, strOptions)

strLogMsg = strInPDFFile & vbCrLf & strOutFile & vbCrLf & strOptions & vbCrLf & "nRet = " & Str(nRet)

MsgBox(strLogMsg)

'default DPI is 72DPI in PDF file, so you need calculate position by 72DPI,

'you can read the text contents and position from output HTML file

Dim x, y, w, h, hPDF, bRet, nPage As Integer

Dim strOldText, strNewText As String

x = 1333 * 72.0 / nDPI

y = 237 * 72.0 / nDPI

w = 151 * 72.0 / nDPI

h = 27 * 72.0 / nDPI

nPage = 1

strOldText = "September"

strNewText = "VeryDOC"

strOutFile = Application.StartupPath() & "\modified.pdf"

hPDF = VeryDOC_ModifyPDF_OpenFile(strInPDFFile, strOutFile)

bRet = VeryDOC_ModifyPDF_ModifyText(hPDF, nPage, x, y, w, h, strOldText, strNewText)

VeryDOC_ModifyPDF_CloseFile(hPDF)

MsgBox("Process completed." & vbCrLf & "VeryDOC_ModifyPDF_ModifyText() return: " & CStr(bRet))

End Sub

VC++ example to illustrate how to modify PDF with text:

int Test_PDFParserSDK_ModifyPDF()

{

char szPDFFile[_MAX_PATH];

GetModulePath(szPDFFile, "example1.pdf");

char szOutPDFFile[_MAX_PATH];

GetModulePath(szOutPDFFile, "_modified.pdf");

VeryPDF_ModifyPDF_SetCode(LICENSE_KEY_PDFMODIFYSDK);

HANDLE hPDF = VeryPDF_ModifyPDF_OpenFile(szPDFFile, szOutPDFFile);

if(hPDF == NULL)

return 0;

int nPage = 1;

//The default DPI for these values is 72DPI

int dpi = 72;

int x = 319*72/dpi;

int y = 56*72/dpi;

int nWidth = 37*72/dpi;

int nHeight = 7*72/dpi;

char *lpOldText = "October";

char *lpNewText = "VeryDOC.COM";

BOOL bRet = VeryPDF_ModifyPDF_ModifyText(hPDF, nPage, x, y, nWidth, nHeight, lpOldText, lpNewText);

VeryPDF_ModifyPDF_CloseFile(hPDF);

return 1;

}

In the end, if you have any questions, please share them with us through comments left here. Welcome to try or buy VeryDOC PDF Parser & Modify SDK. And for all functions are encapsulated in DLL Library, it is of need to purchase developer license if you need to apply all functions for design of new tools.

VN:F [1.9.20_1166]
Rating: 0.0/10 (0 votes cast)
VN:F [1.9.20_1166]
Rating: 0 (from 0 votes)

Related Posts

Leave a Reply

Your email address will not be published. Required fields are marked *


Verify Code   If you cannot see the CheckCode image,please refresh the page again!