I want to implant by code
(c#), the “test” image (bytes) instead of the object in testPDF without using replace image
attached is a file and a image.testPDf.pdf (3.8 KB)
test.png (36.4 KB)
Can you please share an expected output PDF as well along with a little more details of your requirements so that we can better understand the scenario and address it accordingly.
I have code that merges a signature into a PDF file. I want to put an object in the PDF where it needs to be bounded and according to which the X and Y must be known. I saw that the LLX and LLY were inaccurate. Is there a calculation ?
Please share that code snippet with us. We will use it to generate your expected outcome and share the modified version with you.
Stream streamPdf = new MemoryStream(System.Convert.FromBase64String(base64Pdf));
var pdfDocument = new Document(streamPdf);
var sign = pdfDocument.Form.Fields.FirstOrDefault(_ => (_ as ButtonField) != null); – my object in pdf
if (sign != null && (sign.FullName == “Sig”)
px = (float)sign.GetRectangle(false).LLX;
py = (float)sign.GetRectangle(false).LLY; – doesn’t return the exact location
Please try to use the below code snippet in order to achieve your requirements:
Document doc = new Document(dataDir + "testPDf.pdf"); Field field1 = (Field)doc.Form["Image Field0"]; var fs = new FileStream(dataDir + "test.png", FileMode.Open); var rect1 = field1.GetRectangle(false); int llx = Convert.ToInt32(rect1.LLX); int lly = Convert.ToInt32(rect1.LLY); int urx = Convert.ToInt32(rect1.URX); int ury = Convert.ToInt32(rect1.URY); ImageStamp imageStamp1 = new ImageStamp(fs); imageStamp1.XIndent = llx; imageStamp1.YIndent = lly; imageStamp1.Height = ury - lly; imageStamp1.Width = urx - llx; doc.Flatten(); doc.Pages.AddStamp(imageStamp1); doc.Save(dataDir + "ImageAtformField.pdf");
ImageAtformField.pdf (155.1 KB)
in the same matter:
I save the pdf like this:
using(MemoryStream ms = new MemoryStream)
not like this: doc.Save(dataDir + “ImageAtformField.pdf”);
on iPhone - The field1 is not hidden - bad (bad)
on Android - The field1 is hidden - good
how can i hidden field or move as in the save code above.
Before saving the PDF, please try to flatten the form field using Field.Flatten() method. In case you still notice issue, please share generated file for reference. We will test the scenario in our environment and address it accordingly.
It doesn’t work and it looks like this: image0.png (818 Bytes)
We need sample source and generated output files for our reference so that we can continue to investigate this issue. Would you please provide them?