Hi,
Please find modified sample attached with this post. After investigation we have come to know that replacing text is causing problems, so as workaround we had to add the text 'XXXXX...' as image in the file. You can find below the code snippet used in the sample. The image is also attached.
//Set the file names of the input and output PDF files
string imageName = @"d:\pdftest\XXXX.bmp";
string inputFile = @"D:\pdftest\creditCardSample_Extracted.pdf";
string outputFile = @"D:\pdftest\creditCardSample_Extracted_Replaced.pdf";
//Create the streams of input and output PDF files
FileStream inPdfStream = new FileStream(inputFile, FileMode.Open);
FileStream outputStream = new FileStream(outputFile, FileMode.Create);
//Create the stream of the image to be added
FileStream inImgStream = new FileStream(imageName, FileMode.Open);
//Set the current position of input PDF file stream to the beginning of the stream
inPdfStream.Seek(0, SeekOrigin.Begin);
//Instantiate PdfFileMendor object and pass input and output PDF file streams to its constructor
PdfFileMend mendor = new PdfFileMend(inPdfStream, outputStream);
//Call AddImage method and pass image, page number and (X,Y) axis information.
//second parameter is page number which is 7 in this case
mendor.AddImage(inImgStream, 7, 140, 130, 320, 155);
//Close PdfFileMendor object
mendor.Close();
//Close output PDF file stream
outputStream.Close();
We'll look into replacing the text as well. However, for that matter, we'll require some time. Nevertheless, I hope this sample will work for you.
Regards,
We were also getting “SOLO Payment Options” text aprt from warning message. That is the reason for my confusion. Please post your thoughts
The image replace way might not work in the real time scenario. The reason is, the page number and the axis co-ordinates might change when the pdf is actually populated with the dynamic data.
And with regards to time, I have to respond to client on the feasibility today and I am really having hard time to compose mails to them.
I will try to buy time from them till monday I guess, and if everything goes well we shall send them the proposal for product license approval.
Hi,
First of all, as the 'SOLO Payment Options' is concerned', this is the first line on the page number 7 you're trying to extract text from. As, using PdfExtractor class can extract only one line of the original text in the page given, that's why this line is being extracted.
Secondly, as this workaround is not working for you, and the ReplaceText method is causing problems as well, I have forwarded a request to our development team. They'll be looking into the issue. You'll be updated regarding the results the earliest possible.
We're sorry for the inconvenience.
Regards,
Hi,
I just wanted to update you regarding this issue. I'm sorry to let you know that we can't provide this feature in short time, and we're unable to provide the ETA for this issue. I'm afraid, you'll have to tweak currently provided workaround to suit your needs if possible.
We're sorry for the inconvenience.
Regards,
Is it possible to find the x-y co-ordinates of the particular text at runtime.
The reason for this requirement is that if that is possible, then we will find the location and then pass the location dynamically for replacing with the image in the below method, instead of passing the hardcoded n statically calculated values.
mendor.AddImage(inImgStream, 7, 140, 130, 320, 155)
Hi,
I'm afraid, locating the coordinates of text are not possible at the moment. Also, we'll not be able to support this feature in short time.
We apologize for the inconvenience.
Regards,
Do you have any suggestions for any other product that fulfills our requirement, could be any other vendor…
Hi,
Sorry, I have no idea about any other product or vendor; probably, you'll have to search for that. Nevertheless, if you would like to know more about Aspose.Pdf.Kit features, I'll be more than happy to help you out.
Regards,