Hi Team,
While Reading the barcode getting barcode height and width and measurement of height and width we are getting in pixels.
sample code :
public List extractbarcodes(string filepath = “”,string rootpath=“”)
{
var config = getConfig();
var WebFolderRootpath = config.GetSection(“ServiceSettings”).GetSection(“AsposeBarCodePath”).Value != “” ? config.GetSection(“ServiceSettings”).GetSection(“AsposeBarCodePath”).Value : null;
List<BarcodeProp> Listobjbarcodedata = new List<BarcodeProp>();
BarcodeProp objbarcodeprop = new BarcodeProp();
try
{
// Bind the pdf document
string webRootPath = rootpath;
// string WebFolderRootpath = Path.Combine(webRootPath + "\\bin\\Debug\\netcoreapp3.1\\Aspose.BarCode.lic");
WebFolderRootpath = Path.GetFullPath(WebFolderRootpath);
string dataDir = Path.GetFullPath(filepath);
Aspose.Pdf.License license = new Aspose.Pdf.License();
license.SetLicense("Aspose.Pdf.lic");
Aspose.BarCode.License barcodelic = new Aspose.BarCode.License();
barcodelic.SetLicense(WebFolderRootpath);
Aspose.Pdf.Facades.PdfConverter pdfConverter = new Aspose.Pdf.Facades.PdfConverter();
pdfConverter.BindPdf(dataDir);
// Set page range for image extraction
pdfConverter.StartPage = 1;
pdfConverter.EndPage = 1;
// Set rendering optimization for barcodes
pdfConverter.RenderingOptions.BarcodeOptimization = true;
pdfConverter.DoConvert();
// Save images to stream in a loop
while (pdfConverter.HasNextImage())
{
// Save image to stream
MemoryStream imageStream = new MemoryStream();
pdfConverter.GetNextImage(imageStream);
imageStream.Position = 0;
// Recognize the barcode from the image stream above
using (BarCodeReader reader = new BarCodeReader(imageStream, DecodeType.AllSupportedTypes))
{
var res = reader.ReadBarCodes();
if (reader.ReadBarCodes().Length > 0)
{
foreach (BarCodeResult result in res)
{
objbarcodeprop = new BarcodeProp();
objbarcodeprop.BarcodeType = Convert.ToString(result.CodeType);
objbarcodeprop.BarcodeValue = result.CodeText;
objbarcodeprop.BarcodeHeight = Convert.ToString(result.Region.Rectangle.Height);
objbarcodeprop.BarcodeWidth = Convert.ToString(result.Region.Rectangle.Width);
objbarcodeprop.Message = "true";
Listobjbarcodedata.Add(objbarcodeprop);
// Console.WriteLine("Codetext found: " + result.CodeType + ", Symbology: " + result.CodeText);
}
}
else {
objbarcodeprop.Message = "false";
Listobjbarcodedata.Add(objbarcodeprop);
}
}
}
string filepathdir = Path.GetDirectoryName(dataDir);
try
{
if (filepathdir.Length > 0)
{
Directory.Delete(filepathdir,true);
}
}
catch (Exception ex)
{
throw ex;
}
}
catch (Exception ex)
{
throw ex;
}
return Listobjbarcodedata;
}
Output :
image(1): getting barcode details like attached
image(1).jpg (43.7 KB)
image(2): after getting barcode height (pixel) we are converting height into points through online converter.
image(2).jpg (14.7 KB)
image(3): after getting barcode width(pixel) we are converting width into points through online converter.(measurements).
image(3).jpg (18.2 KB)
image(4): based on the scale measurement we are measuring height in points getting like attached image.
image(4).jpg (42.5 KB)
image(5): based on the scale measurement we are measuring width in points getting like attached image.
image(5).jpg (43.2 KB).
so how can i convert pdf coordinates to mouse coordinates.
Note: Already raised ticket in Aspose.Barcode forum please check the attached hyperlink.
[https://forum.aspose.com/t/okay-aspose-assistant-conversation-with-customer-on-monday-march-21st-2022-747-am/243637?u=deepthigutta]
Thanks.
@deepthiGutta
Would you please share a bit more details like why and how do you want to convert PDF units to mouse coordinates? Are you displaying PDFs in browser in any control? Do you want to draw something on PDF by selecting the area by mouse? Please share the requested information so that we may share our feedback accordingly.
Hi Team,
we are displaying PDF’s in browser by using PDF viewer.js . we want to draw rectangle annotation on Pdf by selecting barcode area by mouse.
Attached image for displaying Pdf in browser using viewer.js .
viewerjs.jpg (46.4 KB)
drawing rectangle annotation on pdf by selecting barcode Area. we are Reading barcode details using Aspose Barcode Reader and getting details are displaying on popup.
Rectangle On barcode area.jpg (52.8 KB)
Actually we are getting barcode height and width is in pixels but we want to height and width in mouse coordinates in points measurement.
Height of barcode in points.jpg (70.3 KB)
width of barcode in points.jpg (69.4 KB)
Thanks.
@deepthiGutta
Please note that PDF documents are resolution independent. They render on a screen in the same resolution in which current settings are applied. We are afraid that there is no such method in the API at the moment that can capture the mouse coordinates and convert them into respective position points inside PDF. Also, Aspose.PDF does not provide any viewer so this functionality was never investigated.
As a workaround, the images are generated from the PDF document and displayed in HTML Canvas but still the coordinates of images cannot be mapped over a PDF Page. For further investigation, we have logged an investigation ticket as PDFNET-51589 in our issue management system. We will look into details of this scenario and let you know as soon as the ticket is resolved. Please be patient and spare us some time.
We are sorry for the inconvenience.
Hi Team,
Any update regarding to this ticket.
@deepthiGutta
The ticket has recently been logged in our issue management system and it is pending for review. Please note that we will investigate and resolve the ticket on a first come first serve basis. We will inform you once we make some significant progress towards its resolution. Please be patient and spare us some time.
We are sorry for the inconvenience.
Hi Team,
Any update regarding to this ticket.
@deepthiGutta
We are afraid that the earlier logged ticket has not been yet resolved. We will let you know via this forum thread as soon as we have any updates in this regard. Please spare us some time.
We are sorry for the inconvenience.
Could you please update on this issue?
@deepthiGutta
We regret to inform you that the earlier logged ticket is not yet resolved. We will update you in this forum thread once we make some definite progress towards its resolution. Please be patient and spare us some time.
We are sorry for the inconvenience.
Could you please update on this issue?
@kirangali
We are afraid that the earlier logged ticket has not been yet resolved due to other pending issues in the queue. However, we will surely let you know once we have some significant updates about its resolution. Please spare us some time.
We are sorry for the inconvenience.
is there any update on the above issue.
if it is taking time how long it will take.
@kirangali
Regretfully, the ticket has not been yet resolved. Please note that the issues in free support model are resolved on first come first serve basis and resolution time of the issue depends upon the number of issues in the queue as well as the complexity of the issue. However, if you need to expedite the investigation process for this ticket, you can please check our paid support option where issues are resolved on an urgent basis. We will let you know further in case we have some updates.
We apologize for the inconvenience.
Could you please update on this issue?
@kirangalifreyr
We are afraid that no updates are available at the moment regarding ticket resolution. Nevertheless, we will be sharing news with you in this forum thread as soon as we have some in this regard.
We apologize for the inconvenience.
Hi Team,
Could you please update us on this issue as a high priority?
Thanks,
Kiran G
@kirangalifreyr
We are afraid that the ticket is not yet resolved due to other tasks and issues in the queue. Please note that it is a complex requirement and existing coordinating system in the API needs to be enhanced which is a core feature. Therefore, this functionality needs certain amount of time in order to get fully implemented. Your concerns are already recorded along with the ticket and we will surely inform you once we have some updates to share.
We apologize for your inconvenience.
Maximum how many days will take to resolve the complex issue, Please analyze and update the current status.
@kirangalifreyr
We are afraid that we are not in a position to share some reliable ETA as the issue was logged under free support model and it has less priority than paid support issues. Nevertheless, we have been investigating it parallel along with implementing the fixes for other previously logged tasks. We will update you via this forum thread once we have some shareworthy updates or news about ticket resolution. your patience and comprehension is greatly appreciated in this regard.
We are sorry for the inconvenience.