Modify your PDF file contents by PDF Modify SDK product

Hello,
We have attempted to work with your code. I have few questions.
4. Why do we need the png file in the code below?
'Render PDF pages to PNG image files first strInPDFFile = Application.StartupPath() & "\F_COC.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)
    
5. I’ve used F_COC.pdf file in my testing (see attached). Coordinates for text "Voucher"  (as marked on attached  jpg file) returned by PDFParser (Phase I) are:
X1=226; Y1=404; W1=75; H1=18 OldString was "Voucher" and NewString was "ABC":
I’ve used the following calculation in my code:
       Dim x, y, w, h, hPDF, bRet, nPage As Integer
        Dim x1, y1, w1, h1 As Integer
        Dim strOldText, strNewText As String
        x = x1 * 72.0 / nDPI
        y = y1 * 72.0 / nDPI
        w = w1 * 72.0 / nDPI
        h = h1 * 72.0 / nDPI

        'x = 1333 * 72.0 / nDPI
        'y = 237 * 72.0 / nDPI
        'w = 151 * 72.0 / nDPI
        'h = 27 * 72.0 / nDPI
        nPage = 1
        strOldText = txtOld.Text
        strNewText = txtNew.Text

        strOutFile = Application.StartupPath() & "\modified.pdf"
        hPDF = VeryPDF_ModifyPDF_OpenFile(strInPDFFile, strOutFile)
        bRet = VeryPDF_ModifyPDF_ModifyText(hPDF, nPage, x, y, w, h, strOldText, strNewText)
        VeryPDF_ModifyPDF_CloseFile(hPDF) The resulting \modified.pdf file was not changed.
d) What did I do wrong?
e) Please, provide me with a vb.net example which works following my pdf sample.
f) What DPI is used in PDFParser Phase I code? I see no options there to control it. Do I need to?

6. But, probably the most critical question is:
How will these two dlls (Phase I and Phase II) co-exist efficiently.
It looks like I have to open and process the pdf file and their pages twice.
c) First time I need to open the pdf file and ask for text and page images to get text with coordinates.
d) I need to open the file for the second time to update the text and images.
Clearly, opening and processing file twice has a potential for unworkable solution.
Please, provide me with a vb.net code example which will show the architecture of these two DLLs, so process will be very efficient as promised.
Thanks.
==============================================
Hi,

We have attempted to work with your code. I have few questions.
1. Why do we need the png file in the code below?
'Render PDF pages to PNG image files first strInPDFFile = Application.StartupPath() & "\F_COC.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)

This code is used to get the position for a special word, if you have already known the X, Y, Width, Height position for a word, you needn’t call VeryPDF_PDFParserSDK() to generate a PNG image first.
2. I’ve used F_COC.pdf file in my testing (see attached). Coordinates for text "Voucher"  (as marked on attached  jpg file) returned by PDFParser (Phase I) are:
X1=226; Y1=404; W1=75; H1=18 OldString was "Voucher" and NewString was "ABC":
I’ve used the following calculation in my code:
       Dim x, y, w, h, hPDF, bRet, nPage As Integer
        Dim x1, y1, w1, h1 As Integer
        Dim strOldText, strNewText As String
        x = x1 * 72.0 / nDPI
        y = y1 * 72.0 / nDPI
        w = w1 * 72.0 / nDPI
        h = h1 * 72.0 / nDPI

        'x = 1333 * 72.0 / nDPI
        'y = 237 * 72.0 / nDPI
        'w = 151 * 72.0 / nDPI
        'h = 27 * 72.0 / nDPI
        nPage = 1
        strOldText = txtOld.Text
        strNewText = txtNew.Text

        strOutFile = Application.StartupPath() & "\modified.pdf"
        hPDF = VeryPDF_ModifyPDF_OpenFile(strInPDFFile, strOutFile)
        bRet = VeryPDF_ModifyPDF_ModifyText(hPDF, nPage, x, y, w, h, strOldText, strNewText)
        VeryPDF_ModifyPDF_CloseFile(hPDF) The resulting \modified.pdf file was not changed.
a) What did I do wrong?
The default DPI is 150, so your "X1=226; Y1=404; W1=75; H1=18" position is calculated by 150, in the VB.NET_2 example, we are using 300DPI to parse this PDF file. The default position for "Voucher" is [452, 809, 150, 35] when we parse F_COC.pdf file at 300DPI, please refer to following information in output HTML file, ~~~~~~~~~~~~~~~~~ <div style="position:absolute;left:452;top:809;width:150;height:35"><span style="font-style:normal;font-weight:700;font-size:36px;font-family:Helvetica-Bold;color:#000000;">Voucher</span></div>
~~~~~~~~~~~~~~~~~
b) Please, provide me with a vb.net example which works following my pdf sample.

Yes, no problem, please download a new test package from following URL,

XXXXXXXXXXXXXXXXXXXXXX

The new version can change from "Voucher" to "VeryPDF" properly, please refer to following screenshot,

c) What DPI is used in PDFParser Phase I code? I see no options there to control it. Do I need to?

Default DPI is 150 in PDFParser Phase I, however, you can use "-r" parameter to change the default DPI, for example,

nRet = VeryPDF_PDFParserSDK(strInPDFFile, strOutFile, "-r 300 -html -$ XXXXXXXXXXXXXXXXXXXX")

3. But, probably the most critical question is:
How will these two dlls (Phase I and Phase II) co-exist efficiently.
It looks like I have to open and process the pdf file and their pages twice.
a) First time I need to open the pdf file and ask for text and page images to get text with coordinates.
b) I need to open the file for the second time to update the text and images.
Clearly, opening and processing file twice has a potential for unworkable solution.
Please, provide me with a vb.net code example which will show the architecture of these two DLLs, so process will be very efficient as promised.

Phase I and Phase II have been integrated into one pdfparsersdk2.dll library, there hasn’t two DLL files, if you wish modify the PDF file, you need call VeryPDF_ModifyPDF_OpenFile() function to open an output PDF file for writing, and then call VeryPDF_ModifyPDF_ModifyText() to modify each text words.

VeryPDF
=============================================
Thanks. We will test the cases described.
=============================================
Hello,
I had tested the Modify SDK today. I will do more testing later today.
The Modify SDK seems to be working as designed on a "file based" operations, but:
My application has two modes:
1. Design Mode: When user interacts with our UI to determine the changes need to the PDF pages.
2. Batch Mode: When documents are process automatically based on rule definitions user defined in a Design Mode.
Current Modify SDK seem to be adequate for the Batch Mode. In a Design Mode, user expects immediate response from our application.
I don’t think we can achieve the performance goals with the current “file based” operations and I think we need to add a memory based calls.

I am guessing that current Modify SDK works like:
hPDF = VeryPDF_ModifyPDF_OpenFile(PDFFile, strOutFile) – input and output files are open.
bRet = VeryPDF_ModifyPDF_ModifyText(hPDF, nPage, x, y, w, h, strOldText, strNewText) – input pages are read, modifications are performed and output file written.
VeryPDF_ModifyPDF_CloseFile(hPDF) – input and output files are closed.

As indicated above, in Design Mode performance need to be very, very high, so I think I need something like:
newPageImage = VeryPDF_ModifyPDF_GetImageModifyText(oldPageImage, x, y, w, h, strOldText, strNewText)
where:
- oldPageImage is the image I receive from Phase I SDK.
- newPageImage is a modified oldPageImage.
If needed and improve the speed, I could also pass the Text coordinates for a page which is also available to me at the time of this call from Phase I SDK.
So, the function may look like:
newPageImage = VeryPDF_ModifyPDF_ModifyText(oldPageImage, oldTextCoordinateArray, iRowID, strOldText, strNewText) What do you think?
Thanks.
=============================================
Thanks for your new version of PDF Modify SDK product, everything is work fine now.

=============================================
we will include folloiwng new functions in the PDF Modify SDK Phase II,

//This function will place image included in "NewImage" on a PDF page in rectangle defined by x,y,w,h.
BOOL VeryPDF_ModifyPDF_ModifyImage(hPDF, nPage, x, y, w, h, NewImage)

//This function will place text included in "strNewText" on a PDF page in rectangle defined by x,y,w,h and according to Font Definition.
//FontEnhacement is Bold, Italic, Underline, etc.
//You can use any Windows Font to render the new text
BOOL VeryPDF_ModifyPDF_ModifyTextRich(hPDF, nPage, x, y, w, h, strNewText, FontType, FontSize, FontColor, FontEnhacement)

VeryPDF

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!