TECHNOLOGIES
FORUMS
JOBS
BOOKS
EVENTS
INTERVIEWS
Live
MORE
LEARN
Training
CAREER
MEMBERS
VIDEOS
NEWS
BLOGS
Sign Up
Login
No unread comment.
View All Comments
No unread message.
View All Messages
No unread notification.
View All Notifications
Answers
Post
An Article
A Blog
A News
A Video
An EBook
An Interview Question
Ask Question
Forums
Monthly Leaders
Forum guidelines
jhanani ravishankar
NA
52
1.8k
QRCode Decode from PDF using Thoughtworks QRCode
Jan 5 2021 8:45 AM
Using Thoughtworks and spirepdf trying to decode QR code
Check the code below
private
static
void
GetImages(
string
sourcePdf,
string
outputPath)
{
PdfDocument doc =
new
PdfDocument();
doc.LoadFromFile(sourcePdf);
outputPath = System.IO.Path.Combine(outputPath, String.Format(@
"{0}.jpg"
, 0));
for
(
int
i = 0; i < doc.Pages.Count; i++)
{
string
QRCodeString =
""
;
PdfPageBase page = doc.Pages[i];
System.IO.Stream[] images = page.ExtractImages();
foreach
(System.IO.Stream image
in
images)
{
QRCodeString = GetQRCodeString(Bitmap.FromStream(image), outputPath);
if
(QRCodeString ==
""
)
{
continue
;
//QRCodeString == "Not supported in Spire.Barcode Evaluation version. " ||
}
else
{
QRCodeDecoder decoder =
new
QRCodeDecoder();
String decodedString = decoder.decode(
new
QRCodeBitmapImage(
new
System.Drawing.Bitmap(image)), System.Text.Encoding.UTF8);
Console.WriteLine(decodedString);
}
}
Console.WriteLine(QRCodeString);
}
}
private
static
string
GetQRCodeString(System.Drawing.Image img,
string
outPutPath)
{
img.Save(outPutPath, System.Drawing.Imaging.ImageFormat.Jpeg);
string
scaningResult = Spire.Barcode.BarcodeScanner.ScanOne(outPutPath);
System.IO.File.Delete(outPutPath);
return
scaningResult;
}
It is working for those pdf having Bar code at the top right corner. And showing for other positions
Error: ThoughtWorks.QRCode.ExceptionHandler.DecodingFailedException: 'Give up decoding'
Please help
Reply
Answers (
1
)
Walmart specify Item Type condition when listing a item
Select data from changed entity