You are viewing limited content. For full access, please sign in.

Question

Question

will be be able to add a signature to a PDF from the FORM within the LF workflow. [https://answers.laserfiche.com/questions/66791/Workflow--Copy-Signature-into-PDF]

asked on September 9, 2015

Am relatively new to laserfiche and i would like to know whether we will be able to add a signature to a PDF from Laserfiche FORM within the Laserfiche workflow?

we are able to do what is mentioned in the link below 

https://answers.laserfiche.com/questions/66791/Workflow--Copy-Signature-into-PDF

we are able to add new form fields and store the image as two part text in Laserfiche forms and retrieve it from workflow to embed it into the pdf.

we then use itextsharp to add the image (from the laserfiche formfields) into  the PDF in repository. we are able achieve this only by exporting the document out of laserfiche repository (using documentExporter), add the image and import  (using Document Importer) the updated document back to LF repository.

when we try to do it in memory (using a memory stream) it just do not work, we can determine why? 

Please provide your useful insights.

0 0

Replies

replied on September 10, 2015 Show version history

It seems that your first approach to modifying a PDF in repository is correct. It involves a document export, loading into iTextSharp, saving the modified PDF from iTextSharp into a new file or stream, and finally re-import the new PDF into the repository.

Memory streams contain a copy of data that only exists in memory. If the memory stream is modified, the new data would only exist in memory; it will not be automatically transferred to any other place, unless someone calls a function to do it. The Document Importer is exactly the function one should use to bring the data from a memory stream into the repository.

(If I did not correctly understand your usage of memory stream, please post the relevant part of your source code to help illustrate how the memory stream is used.)

0 0
replied on September 10, 2015

using(MemoryStream signature = new MemoryStream(imageBytes, 0, imageBytes.Length))
                        {
                            //using (FileStream OutputPDFFile = new FileStream(outputFile, FileMode.OpenOrCreate, FileAccess.ReadWrite, FileShare.ReadWrite))
                            using (MemoryStream OutputPDFFile = new MemoryStream())
                            {
                                int NewDocID = 0;
                                using(PdfStamper stamper = new PdfStamper(new PdfReader(laserFileCopy), OutputPDFFile))
                                {
                                    iTextSharp.text.Image img = iTextSharp.text.Image.GetInstance(signature);
                                    img.ScaleAbsolute(100, 50);

                                    img.SetAbsolutePosition(20, 20);
                                    stamper.GetOverContent(1).AddImage(img);

                                    NewDocID = Document.Create(<fullpath>, "DEFAULT", EntryNameOption.AutoRename, RASession);
                                }

                                Laserfiche.DocumentServices.DocumentImporter DI = new Laserfiche.DocumentServices.DocumentImporter();

                                using(DI.Document = Document.GetDocumentInfo(NewDocID, this. RASession))
                                {
                                    DI.ImportEdoc(@"application\pdf", OutpuPDFFile);
                                    DI.Document.Save();
                                }
                            }
                        }

0 0
You are not allowed to follow up in this post.

Sign in to reply to this post.