Replace pre-existing Barcode image on PDF

Replace pre-existing Barcode image on PDF

Forum member · Mar 10, 2021
Hi, We have pdf templates which already have existing elements such as fields, barcodes, images etc. Ask is to dynamically add or replace content in the template. We are able to read fields and assign values to them by using (MergeDocument) mergeDoc.Form.Fields. However we can't read existing barcode and image elements (or we don't know how to). BarCodes and some Images are pre-printed on the template and we need to replace them dynamically. How can we do that?

Re: Replace pre-existing Barcode image on PDF

Support · Mar 12, 2021
Hello, You can get images from a PDF document. Please refer to the documentation on getting images here . DynamicPDF Core Suite for .NET product does not support replacing images and barcodes in a PDF but you can add new images and supported barcode to a PDF. Please refer to the documentation on Barcodes and Images . Thanks, ceTe Software Support Team

Re: Replace pre-existing Barcode image on PDF

Forum member · Mar 15, 2021
Hi Thanks for the reply. But the example given by you below does no compile in .net core. Is it really available? PdfDocument class does not have GetImages method. using System; using System.IO; using ceTe.DynamicPDF.Merger; Public Class Example { public static void GetImages(string inputPath, string outputPath) { // Create PDF document object PdfDocument pdfA = new PdfDocument(inputPath); // Call GetImages method from PDF document object to get the images from the document ImageInformation[] imageInfoList = pdf.GetImages(); for (int i = 0; i < imageInfoList.Length; i++) { ExtractedImageData extractedImageData = imageInfoList[i].GetImage(); byte[] data = null; string extension = ""; if (extractedImageData.ExtractedImageType == ExtractedImageType.Png) extension = ".png"; else extension = ".jpg"; data = extractedImageData.Data; File.WriteAllBytes(outputPath + i + extension, data); } } }

Re: Replace pre-existing Barcode image on PDF

Support · Mar 16, 2021
Hello, We tested this on our end in .NET Core application and able to extract images from an existing PDF. Please make sure to reference the latest product in your application and see if it resolves the issue. You can download latest product from NuGet (Package ID: ceTe.DynamicPDF.CoreSuite.NET) or from our website here . If you continue facing any issues, please send over the following information to [^a|mailto:support@dynamicpdf.com|opennewwindow|support@dynamicpdf.com^] so we can look into it further. 1. Code sample to recreate issue. 2. Full error message along with stack trace (if any). 3. Source/input PDF used to extract images. 4. Exact version and build number of the DynamicPDF DLL file used in your application. You can get this information by right clicking on the DynamicPDF DLL file>>Properties>>Details tab>>Product version. Thanks, ceTe Software Support Team