Barcode appears too small to see when used on PDF v1.5 file

I am using net2.0 Aspose.BarCode to add barcode to PDF file v.1.5 and PDF file v.1.4. The barcode appears fine on the PDF 1.4 but not on the PDF file 1.5 – it is too small to see. By the way I am using Aspose.BarCode v 5.4.0.0.

The code is below:

BarCodeBuilder builder = new BarCodeBuilder();

builder.SymbologyType = Symbology.Code39Standard;

builder.GraphicsUnit = GraphicsUnit.Millimeter;

builder.BarHeight = 8.0f;

builder.CodeTextFont = new System.Drawing.Font("Courier New", 12f);

<w:LatentStyles DefLockedState=“false” DefUnhideWhenUsed=“true”
DefSemiHidden=“true” DefQFormat=“false” DefPriority=“99”
LatentStyleCount=“267”>
<w:LsdException Locked=“false” Priority=“0” SemiHidden=“false”
UnhideWhenUsed=“false” QFormat=“true” Name=“Normal”/>
<w:LsdException Locked=“false” Priority=“9” SemiHidden=“false”
UnhideWhenUsed=“false” QFormat=“true” Name=“heading 1”/>
<w:LsdException Locked=“false” Priority=“9” QFormat=“true” Name=“heading 2”/>
<w:LsdException Locked=“false” Priority=“9” QFormat=“true” Name=“heading 3”/>
<w:LsdException Locked=“false” Priority=“9” QFormat=“true” Name=“heading 4”/>
<w:LsdException Locked=“false” Priority=“9” QFormat=“true” Name=“heading 5”/>
<w:LsdException Locked=“false” Priority=“9” QFormat=“true” Name=“heading 6”/>
<w:LsdException Locked=“false” Priority=“9” QFormat=“true” Name=“heading 7”/>
<w:LsdException Locked=“false” Priority=“9” QFormat=“true” Name=“heading 8”/>
<w:LsdException Locked=“false” Priority=“9” QFormat=“true” Name=“heading 9”/>
<w:LsdException Locked=“false” Priority=“39” Name=“toc 1”/>
<w:LsdException Locked=“false” Priority=“39” Name=“toc 2”/>
<w:LsdException Locked=“false” Priority=“39” Name=“toc 3”/>
<w:LsdException Locked=“false” Priority=“39” Name=“toc 4”/>
<w:LsdException Locked=“false” Priority=“39” Name=“toc 5”/>
<w:LsdException Locked=“false” Priority=“39” Name=“toc 6”/>
<w:LsdException Locked=“false” Priority=“39” Name=“toc 7”/>
<w:LsdException Locked=“false” Priority=“39” Name=“toc 8”/>
<w:LsdException Locked=“false” Priority=“39” Name=“toc 9”/>
<w:LsdException Locked=“false” Priority=“35” QFormat=“true” Name=“caption”/>
<w:LsdException Locked=“false” Priority=“10” SemiHidden=“false”
UnhideWhenUsed=“false” QFormat=“true” Name=“Title”/>
<w:LsdException Locked=“false” Priority=“1” Name=“Default Paragraph Font”/>
<w:LsdException Locked=“false” Priority=“11” SemiHidden=“false”
UnhideWhenUsed=“false” QFormat=“true” Name=“Subtitle”/>
<w:LsdException Locked=“false” Priority=“22” SemiHidden=“false”
UnhideWhenUsed=“false” QFormat=“true” Name=“Strong”/>
<w:LsdException Locked=“false” Priority=“20” SemiHidden=“false”
UnhideWhenUsed=“false” QFormat=“true” Name=“Emphasis”/>
<w:LsdException Locked=“false” Priority=“59” SemiHidden=“false”
UnhideWhenUsed=“false” Name=“Table Grid”/>
<w:LsdException Locked=“false” UnhideWhenUsed=“false” Name=“Placeholder Text”/>
<w:LsdException Locked=“false” Priority=“1” SemiHidden=“false”
UnhideWhenUsed=“false” QFormat=“true” Name=“No Spacing”/>
<w:LsdException Locked=“false” Priority=“60” SemiHidden=“false”
UnhideWhenUsed=“false” Name=“Light Shading”/>
<w:LsdException Locked=“false” Priority=“61” SemiHidden=“false”
UnhideWhenUsed=“false” Name=“Light List”/>
<w:LsdException Locked=“false” Priority=“62” SemiHidden=“false”
UnhideWhenUsed=“false” Name=“Light Grid”/>
<w:LsdException Locked=“false” Priority=“63” SemiHidden=“false”
UnhideWhenUsed=“false” Name=“Medium Shading 1”/>
<w:LsdException Locked=“false” Priority=“64” SemiHidden=“false”
UnhideWhenUsed=“false” Name=“Medium Shading 2”/>
<w:LsdException Locked=“false” Priority=“65” SemiHidden=“false”
UnhideWhenUsed=“false” Name=“Medium List 1”/>
<w:LsdException Locked=“false” Priority=“66” SemiHidden=“false”
UnhideWhenUsed=“false” Name=“Medium List 2”/>
<w:LsdException Locked=“false” Priority=“67” SemiHidden=“false”
UnhideWhenUsed=“false” Name=“Medium Grid 1”/>
<w:LsdException Locked=“false” Priority=“68” SemiHidden=“false”
UnhideWhenUsed=“false” Name=“Medium Grid 2”/>
<w:LsdException Locked=“false” Priority=“69” SemiHidden=“false”
UnhideWhenUsed=“false” Name=“Medium Grid 3”/>
<w:LsdException Locked=“false” Priority=“70” SemiHidden=“false”
UnhideWhenUsed=“false” Name=“Dark List”/>
<w:LsdException Locked=“false” Priority=“71” SemiHidden=“false”
UnhideWhenUsed=“false” Name=“Colorful Shading”/>
<w:LsdException Locked=“false” Priority=“72” SemiHidden=“false”
UnhideWhenUsed=“false” Name=“Colorful List”/>
<w:LsdException Locked=“false” Priority=“73” SemiHidden=“false”
UnhideWhenUsed=“false” Name=“Colorful Grid”/>
<w:LsdException Locked=“false” Priority=“60” SemiHidden=“false”
UnhideWhenUsed=“false” Name=“Light Shading Accent 1”/>
<w:LsdException Locked=“false” Priority=“61” SemiHidden=“false”
UnhideWhenUsed=“false” Name=“Light List Accent 1”/>
<w:LsdException Locked=“false” Priority=“62” SemiHidden=“false”
UnhideWhenUsed=“false” Name=“Light Grid Accent 1”/>
<w:LsdException Locked=“false” Priority=“63” SemiHidden=“false”
UnhideWhenUsed=“false” Name=“Medium Shading 1 Accent 1”/>
<w:LsdException Locked=“false” Priority=“64” SemiHidden=“false”
UnhideWhenUsed=“false” Name=“Medium Shading 2 Accent 1”/>
<w:LsdException Locked=“false” Priority=“65” SemiHidden=“false”
UnhideWhenUsed=“false” Name=“Medium List 1 Accent 1”/>
<w:LsdException Locked=“false” UnhideWhenUsed=“false” Name=“Revision”/>
<w:LsdException Locked=“false” Priority=“34” SemiHidden=“false”
UnhideWhenUsed=“false” QFormat=“true” Name=“List Paragraph”/>
<w:LsdException Locked=“false” Priority=“29” SemiHidden=“false”
UnhideWhenUsed=“false” QFormat=“true” Name=“Quote”/>
<w:LsdException Locked=“false” Priority=“30” SemiHidden=“false”
UnhideWhenUsed=“false” QFormat=“true” Name=“Intense Quote”/>
<w:LsdException Locked=“false” Priority=“66” SemiHidden=“false”
UnhideWhenUsed=“false” Name=“Medium List 2 Accent 1”/>
<w:LsdException Locked=“false” Priority=“67” SemiHidden=“false”
UnhideWhenUsed=“false” Name=“Medium Grid 1 Accent 1”/>
<w:LsdException Locked=“false” Priority=“68” SemiHidden=“false”
UnhideWhenUsed=“false” Name=“Medium Grid 2 Accent 1”/>
<w:LsdException Locked=“false” Priority=“69” SemiHidden=“false”
UnhideWhenUsed=“false” Name=“Medium Grid 3 Accent 1”/>
<w:LsdException Locked=“false” Priority=“70” SemiHidden=“false”
UnhideWhenUsed=“false” Name=“Dark List Accent 1”/>
<w:LsdException Locked=“false” Priority=“71” SemiHidden=“false”
UnhideWhenUsed=“false” Name=“Colorful Shading Accent 1”/>
<w:LsdException Locked=“false” Priority=“72” SemiHidden=“false”
UnhideWhenUsed=“false” Name=“Colorful List Accent 1”/>
<w:LsdException Locked=“false” Priority=“73” SemiHidden=“false”
UnhideWhenUsed=“false” Name=“Colorful Grid Accent 1”/>
<w:LsdException Locked=“false” Priority=“60” SemiHidden=“false”
UnhideWhenUsed=“false” Name=“Light Shading Accent 2”/>
<w:LsdException Locked=“false” Priority=“61” SemiHidden=“false”
UnhideWhenUsed=“false” Name=“Light List Accent 2”/>
<w:LsdException Locked=“false” Priority=“62” SemiHidden=“false”
UnhideWhenUsed=“false” Name=“Light Grid Accent 2”/>
<w:LsdException Locked=“false” Priority=“63” SemiHidden=“false”
UnhideWhenUsed=“false” Name=“Medium Shading 1 Accent 2”/>
<w:LsdException Locked=“false” Priority=“64” SemiHidden=“false”
UnhideWhenUsed=“false” Name=“Medium Shading 2 Accent 2”/>
<w:LsdException Locked=“false” Priority=“65” SemiHidden=“false”
UnhideWhenUsed=“false” Name=“Medium List 1 Accent 2”/>
<w:LsdException Locked=“false” Priority=“66” SemiHidden=“false”
UnhideWhenUsed=“false” Name=“Medium List 2 Accent 2”/>
<w:LsdException Locked=“false” Priority=“67” SemiHidden=“false”
UnhideWhenUsed=“false” Name=“Medium Grid 1 Accent 2”/>
<w:LsdException Locked=“false” Priority=“68” SemiHidden=“false”
UnhideWhenUsed=“false” Name=“Medium Grid 2 Accent 2”/>
<w:LsdException Locked=“false” Priority=“69” SemiHidden=“false”
UnhideWhenUsed=“false” Name=“Medium Grid 3 Accent 2”/>
<w:LsdException Locked=“false” Priority=“70” SemiHidden=“false”
UnhideWhenUsed=“false” Name=“Dark List Accent 2”/>
<w:LsdException Locked=“false” Priority=“71” SemiHidden=“false”
UnhideWhenUsed=“false” Name=“Colorful Shading Accent 2”/>
<w:LsdException Locked=“false” Priority=“72” SemiHidden=“false”
UnhideWhenUsed=“false” Name=“Colorful List Accent 2”/>
<w:LsdException Locked=“false” Priority=“73” SemiHidden=“false”
UnhideWhenUsed=“false” Name=“Colorful Grid Accent 2”/>
<w:LsdException Locked=“false” Priority=“60” SemiHidden=“false”
UnhideWhenUsed=“false” Name=“Light Shading Accent 3”/>
<w:LsdException Locked=“false” Priority=“61” SemiHidden=“false”
UnhideWhenUsed=“false” Name=“Light List Accent 3”/>
<w:LsdException Locked=“false” Priority=“62” SemiHidden=“false”
UnhideWhenUsed=“false” Name=“Light Grid Accent 3”/>
<w:LsdException Locked=“false” Priority=“63” SemiHidden=“false”
UnhideWhenUsed=“false” Name=“Medium Shading 1 Accent 3”/>
<w:LsdException Locked=“false” Priority=“64” SemiHidden=“false”
UnhideWhenUsed=“false” Name=“Medium Shading 2 Accent 3”/>
<w:LsdException Locked=“false” Priority=“65” SemiHidden=“false”
UnhideWhenUsed=“false” Name=“Medium List 1 Accent 3”/>
<w:LsdException Locked=“false” Priority=“66” SemiHidden=“false”
UnhideWhenUsed=“false” Name=“Medium List 2 Accent 3”/>
<w:LsdException Locked=“false” Priority=“67” SemiHidden=“false”
UnhideWhenUsed=“false” Name=“Medium Grid 1 Accent 3”/>
<w:LsdException Locked=“false” Priority=“68” SemiHidden=“false”
UnhideWhenUsed=“false” Name=“Medium Grid 2 Accent 3”/>
<w:LsdException Locked=“false” Priority=“69” SemiHidden=“false”
UnhideWhenUsed=“false” Name=“Medium Grid 3 Accent 3”/>
<w:LsdException Locked=“false” Priority=“70” SemiHidden=“false”
UnhideWhenUsed=“false” Name=“Dark List Accent 3”/>
<w:LsdException Locked=“false” Priority=“71” SemiHidden=“false”
UnhideWhenUsed=“false” Name=“Colorful Shading Accent 3”/>
<w:LsdException Locked=“false” Priority=“72” SemiHidden=“false”
UnhideWhenUsed=“false” Name=“Colorful List Accent 3”/>
<w:LsdException Locked=“false” Priority=“73” SemiHidden=“false”
UnhideWhenUsed=“false” Name=“Colorful Grid Accent 3”/>
<w:LsdException Locked=“false” Priority=“60” SemiHidden=“false”
UnhideWhenUsed=“false” Name=“Light Shading Accent 4”/>
<w:LsdException Locked=“false” Priority=“61” SemiHidden=“false”
UnhideWhenUsed=“false” Name=“Light List Accent 4”/>
<w:LsdException Locked=“false” Priority=“62” SemiHidden=“false”
UnhideWhenUsed=“false” Name=“Light Grid Accent 4”/>
<w:LsdException Locked=“false” Priority=“63” SemiHidden=“false”
UnhideWhenUsed=“false” Name=“Medium Shading 1 Accent 4”/>
<w:LsdException Locked=“false” Priority=“64” SemiHidden=“false”
UnhideWhenUsed=“false” Name=“Medium Shading 2 Accent 4”/>
<w:LsdException Locked=“false” Priority=“65” SemiHidden=“false”
UnhideWhenUsed=“false” Name=“Medium List 1 Accent 4”/>
<w:LsdException Locked=“false” Priority=“66” SemiHidden=“false”
UnhideWhenUsed=“false” Name=“Medium List 2 Accent 4”/>
<w:LsdException Locked=“false” Priority=“67” SemiHidden=“false”
UnhideWhenUsed=“false” Name=“Medium Grid 1 Accent 4”/>
<w:LsdException Locked=“false” Priority=“68” SemiHidden=“false”
UnhideWhenUsed=“false” Name=“Medium Grid 2 Accent 4”/>
<w:LsdException Locked=“false” Priority=“69” SemiHidden=“false”
UnhideWhenUsed=“false” Name=“Medium Grid 3 Accent 4”/>
<w:LsdException Locked=“false” Priority=“70” SemiHidden=“false”
UnhideWhenUsed=“false” Name=“Dark List Accent 4”/>
<w:LsdException Locked=“false” Priority=“71” SemiHidden=“false”
UnhideWhenUsed=“false” Name=“Colorful Shading Accent 4”/>
<w:LsdException Locked=“false” Priority=“72” SemiHidden=“false”
UnhideWhenUsed=“false” Name=“Colorful List Accent 4”/>
<w:LsdException Locked=“false” Priority=“73” SemiHidden=“false”
UnhideWhenUsed=“false” Name=“Colorful Grid Accent 4”/>
<w:LsdException Locked=“false” Priority=“60” SemiHidden=“false”
UnhideWhenUsed=“false” Name=“Light Shading Accent 5”/>
<w:LsdException Locked=“false” Priority=“61” SemiHidden=“false”
UnhideWhenUsed=“false” Name=“Light List Accent 5”/>
<w:LsdException Locked=“false” Priority=“62” SemiHidden=“false”
UnhideWhenUsed=“false” Name=“Light Grid Accent 5”/>
<w:LsdException Locked=“false” Priority=“63” SemiHidden=“false”
UnhideWhenUsed=“false” Name=“Medium Shading 1 Accent 5”/>
<w:LsdException Locked=“false” Priority=“64” SemiHidden=“false”
UnhideWhenUsed=“false” Name=“Medium Shading 2 Accent 5”/>
<w:LsdException Locked=“false” Priority=“65” SemiHidden=“false”
UnhideWhenUsed=“false” Name=“Medium List 1 Accent 5”/>
<w:LsdException Locked=“false” Priority=“66” SemiHidden=“false”
UnhideWhenUsed=“false” Name=“Medium List 2 Accent 5”/>
<w:LsdException Locked=“false” Priority=“67” SemiHidden=“false”
UnhideWhenUsed=“false” Name=“Medium Grid 1 Accent 5”/>
<w:LsdException Locked=“false” Priority=“68” SemiHidden=“false”
UnhideWhenUsed=“false” Name=“Medium Grid 2 Accent 5”/>
<w:LsdException Locked=“false” Priority=“69” SemiHidden=“false”
UnhideWhenUsed=“false” Name=“Medium Grid 3 Accent 5”/>
<w:LsdException Locked=“false” Priority=“70” SemiHidden=“false”
UnhideWhenUsed=“false” Name=“Dark List Accent 5”/>
<w:LsdException Locked=“false” Priority=“71” SemiHidden=“false”
UnhideWhenUsed=“false” Name=“Colorful Shading Accent 5”/>
<w:LsdException Locked=“false” Priority=“72” SemiHidden=“false”
UnhideWhenUsed=“false” Name=“Colorful List Accent 5”/>
<w:LsdException Locked=“false” Priority=“73” SemiHidden=“false”
UnhideWhenUsed=“false” Name=“Colorful Grid Accent 5”/>
<w:LsdException Locked=“false” Priority=“60” SemiHidden=“false”
UnhideWhenUsed=“false” Name=“Light Shading Accent 6”/>
<w:LsdException Locked=“false” Priority=“61” SemiHidden=“false”
UnhideWhenUsed=“false” Name=“Light List Accent 6”/>
<w:LsdException Locked=“false” Priority=“62” SemiHidden=“false”
UnhideWhenUsed=“false” Name=“Light Grid Accent 6”/>
<w:LsdException Locked=“false” Priority=“63” SemiHidden=“false”
UnhideWhenUsed=“false” Name=“Medium Shading 1 Accent 6”/>
<w:LsdException Locked=“false” Priority=“64” SemiHidden=“false”
UnhideWhenUsed=“false” Name=“Medium Shading 2 Accent 6”/>
<w:LsdException Locked=“false” Priority=“65” SemiHidden=“false”
UnhideWhenUsed=“false” Name=“Medium List 1 Accent 6”/>
<w:LsdException Locked=“false” Priority=“66” SemiHidden=“false”
UnhideWhenUsed=“false” Name=“Medium List 2 Accent 6”/>
<w:LsdException Locked=“false” Priority=“67” SemiHidden=“false”
UnhideWhenUsed=“false” Name=“Medium Grid 1 Accent 6”/>
<w:LsdException Locked=“false” Priority=“68” SemiHidden=“false”
UnhideWhenUsed=“false” Name=“Medium Grid 2 Accent 6”/>
<w:LsdException Locked=“false” Priority=“69” SemiHidden=“false”
UnhideWhenUsed=“false” Name=“Medium Grid 3 Accent 6”/>
<w:LsdException Locked=“false” Priority=“70” SemiHidden=“false”
UnhideWhenUsed=“false” Name=“Dark List Accent 6”/>
<w:LsdException Locked=“false” Priority=“71” SemiHidden=“false”
UnhideWhenUsed=“false” Name=“Colorful Shading Accent 6”/>
<w:LsdException Locked=“false” Priority=“72” SemiHidden=“false”
UnhideWhenUsed=“false” Name=“Colorful List Accent 6”/>
<w:LsdException Locked=“false” Priority=“73” SemiHidden=“false”
UnhideWhenUsed=“false” Name=“Colorful Grid Accent 6”/>
<w:LsdException Locked=“false” Priority=“19” SemiHidden=“false”
UnhideWhenUsed=“false” QFormat=“true” Name=“Subtle Emphasis”/>
<w:LsdException Locked=“false” Priority=“21” SemiHidden=“false”
UnhideWhenUsed=“false” QFormat=“true” Name=“Intense Emphasis”/>
<w:LsdException Locked=“false” Priority=“31” SemiHidden=“false”
UnhideWhenUsed=“false” QFormat=“true” Name=“Subtle Reference”/>
<w:LsdException Locked=“false” Priority=“32” SemiHidden=“false”
UnhideWhenUsed=“false” QFormat=“true” Name=“Intense Reference”/>
<w:LsdException Locked=“false” Priority=“33” SemiHidden=“false”
UnhideWhenUsed=“false” QFormat=“true” Name=“Book Title”/>
<w:LsdException Locked=“false” Priority=“37” Name=“Bibliography”/>
<w:LsdException Locked=“false” Priority=“39” QFormat=“true” Name=“TOC Heading”/>
</w:LatentStyles>
<![endif]–><!–[if gte mso 10]>

/* Style Definitions */ table.MsoNormalTable {mso-style-name:"Table Normal"; mso-tstyle-rowband-size:0; mso-tstyle-colband-size:0; mso-style-noshow:yes; mso-style-priority:99; mso-style-parent:""; mso-padding-alt:0in 5.4pt 0in 5.4pt; mso-para-margin-top:0in; mso-para-margin-right:0in; mso-para-margin-bottom:10.0pt; mso-para-margin-left:0in; line-height:115%; mso-pagination:widow-orphan; font-size:11.0pt; font-family:"Calibri","sans-serif"; mso-ascii-font-family:Calibri; mso-ascii-theme-font:minor-latin; mso-hansi-font-family:Calibri; mso-hansi-theme-font:minor-latin; mso-bidi-font-family:"Times New Roman"; mso-bidi-theme-font:minor-bidi;}

<![endif]–>

Hi Samson,


Thank you for contacting support. First off, please note that each new release contains many improvements, bug fixes and new features. So we always recommend our customers use the latest version of Aspose APIs. You can evaluate the latest version of Aspose.BarCode 6.0.0.

Please refer to the download page here:
http://www.aspose.com/community/files/51/.net-components/aspose.barcode-for-.net/default.aspx

Based on your query, you can control its size during the bar code generation process. Please visit the documented article here: Generate Barcode Using Custom Width Support

Secondly, please try it with the latest version of Aspose.BarCode 6.0.0 and in case it does not help then please share complete source code along with sample PDF files. It’ll help us to be more specific.

The code and two pdf samples are provided. The barcode shows up fine on one but it show up as too small and inverted on the other. Same code, different results.

The version of the PDF file does not seem to matter. Both of them are vesion 1.5

Thanks for your help

Hi Samson,


Thank you for sharing source code and problematic PDFs. We can notice the said problems by using your sample project. Furthermore, we tested against the latest builds of Aspose.BarCode 6.0.0 and Aspose.Pdf 9.0.0. Now it is not inserting bar code in the AposeBarcodeTest_works.pdf file. It looks an issue with Aspose.Pdf API. I’m moving your request in Aspose.Total forum. My colleagues from Aspose.Pdf component team will answer you shortly. We apologize for your inconvenience.

Hi Samson,


Thanks for contacting support.

I have tested again tested the scenarios using Aspose.Pdf for .NET 9.0.0 and as per our observations, the BarCode image is not appearing in resultant file when using AposeBarcodeTest_works.pdf as input document. However when using AsposeBarcodeTest_doesnotwork.pdf file, the BarCode image is appearing inverted and small. For the sake of correction, I have separately logged these problems in our issue tracking system.

  • PDFNEWNET-36594 BarCode image is not being added to PDF file
  • PDFNEWNET-36595 Inverted small BarCode image on PDF file

We will further look into the details of these problems and will keep you updated on the status of correction. Please be
patient and spare us little time. We are sorry for this inconvenience.

Hi,<?xml:namespace prefix = o ns = "urn:schemas-microsoft-com:office:office" />

It has been three weeks since we reported this bug and we would like to find out if there is a chance of having a bug fix for it any time soon.

The pdf that we sent was created with layers. It appears that the barcode functionality is unable to calculate the size correctly and thus miscalculates the size and the location of the bar code required. Because the layered pdf is actually a valid pdf, no error is generated. We have tried merging the layered file with a non-layered pdf file but both parts retain their original formatting in the merged file with the layered one having the miscalculated bar code and the non-layered one having a normal bar code.

Unfortunately, the delay in finding a workable solution is affecting our implementation of a planned release of an application which is a heavy user of bar coding. We will have to consider using different software if the delay is going to be longer than we can accommodate.

Thanks

Samson

Hi Samson,


Thanks for your patience.

We have further investigated the issue PDFNEWNET-36594 and we are unable to reproduce the problem with latest release of Aspose.Pdf for .NET 9.1.0. Please try using the following code snippet to generate the correct output. For your reference, I have also attached the resultant PDF generated over my end.

[C#]

private void Test()
{
// AsposeBarcodeTest_doesnotwork.pdf does not work - the barcode shows up as very small. also inverted.
const string inputfile = @“C:\pdftest\AposeBarcodeTest_works.pdf”;
const string outputfile = @“C:\pdftestAsposeBarcodeTest_BarcodeNotAppearing.pdf”;
// AposeBarcodeTest_works.pdf does not work - the barcode shows up good.
const int pageNumber = 1;
/* coordinates for bottom middle and bottom right*/
// bottom right
const float lowerLeftX = 410;
const float lowerLeftY = 0;
const float upperRightX = 590;
const float upperRightY = 30;
const bool isPercentage = false; // if it sets to true the calculation of coordinates is incorrect
var fileBytes = ReadFile(inputfile);
var mStream = new MemoryStream(fileBytes);
var fileInfo = new PdfFileInfo(mStream);
var pixelWidth = fileInfo.GetPageWidth(pageNumber);
var pixelHeight = fileInfo.GetPageHeight(pageNumber);

var lowerLx = lowerLeftX;
var lowerLy = lowerLeftY;
var upperRx = upperRightX;
var upperRy = upperRightY;

if(isPercentage)
{
// calculated coordinates are out of the page, please check the initial values of lowerLeftX, lowerLeftY, upperRightX, upperRightY
lowerLx = (int)Math.Round(pixelWidth * (lowerLeftX / 100.0));
lowerLy = (int)Math.Round(pixelHeight * (lowerLeftY / 100.0));
upperRx = (int)Math.Round(pixelWidth * (upperRightX / 100.0));
upperRy = (int)Math.Round(pixelHeight * (upperRightY / 100.0));
}

var builder = new BarCodeBuilder
{
CodeText = “code text”,
SymbologyType = Symbology.Code39Standard,
BackColor = Color.Transparent,
GraphicsUnit = GraphicsUnit.Millimeter,
BarHeight = 8.0f,
CodeTextFont = new Font(“Courier New”, 12f)
};
var barcodeImage = new MemoryStream();
builder.BarCodeImage.Save(barcodeImage, System.Drawing.Imaging.ImageFormat.Png);
var outFileStream = AddBarCode(mStream, barcodeImage, fileInfo.NumberOfPages, lowerLx, lowerLy, upperRx, upperRy);
WriteFile(outputfile, outFileStream.ToArray());
}

private static MemoryStream AddBarCode(Stream inputStream, Stream barcodeImage, int numberOfPages,float lowerLx, float lowerLy, float upperRx, float upperRy)
{
Aspose.Pdf.License license = new Aspose.Pdf.License();
// Change the path to yout license
license.SetLicense(@“C:\Softwares\Aspose\License\Aspose.Total for .NET_10_Jan_2015\Aspose.Total.lic”);
var outFileStream = new MemoryStream();
using (var fileMend = new PdfFileMend(inputStream, outFileStream))
{
inputStream.Seek(0, SeekOrigin.Begin);
for (var i = 1; i <= numberOfPages; i++)
{
fileMend.AddImage(barcodeImage, i, lowerLx, lowerLy, upperRx, upperRy);
}
}
outFileStream.Seek(0, SeekOrigin.Begin);
return outFileStream;
}

private static void WriteFile(string path, byte[] fileBytes)
{
using (var fs = File.Open(path, FileMode.OpenOrCreate, FileAccess.ReadWrite))
{
fs.Write(fileBytes, 0, fileBytes.Length);
}
}

private static byte[] ReadFile(string path)
{
byte[] fileBytes ;
using (var fs = File.Open(path,FileMode.Open,FileAccess.Read))
{
fileBytes = new byte[fs.Length];
fs.Read(fileBytes, 0, fileBytes.Length);
}
return fileBytes;
}

Hi Samson,


Now concerning to PDFNEWNET-36595, the development
team has been busy resolving other priority issues and I am afraid the above
stated problem is not yet resolved. Furthermore, as we recently have been able to notice this problem and until or unless we have investigated and have figured out the actual
reasons of this problem, we might not be able to share any timelines by which
this problem will be resolved.

Please be patient and spare us little time. Your patience and
comprehension is greatly appreciated in this regard.

Hi,

The pdf file (AsposeBarcodeTest_doesnotwork.pdf)we provided you previously contains layers and that seems to be the cause for Aspose’s failure to add barcode. The reason why we think this so is when we re-saved the said file by using a pdf utility such as Cute PDF Writer or PDFill PDF & Image Writer and then run it through Aspose we were able to add barcode successfully. <?xml:namespace prefix = o ns = "urn:schemas-microsoft-com:office:office" />

The work around for this problem could be that we flatten the layers and then add the barcode to the flattened pdf. Now, after going through the forum in you site, I found a blog stating that Aspose does not allow flattening the layers. This was on 08-19-210. Does this statement still hold true or have you found way of flattening the layers. We think this might be a workaround for our problem.

Thanks

Samson

Hi Samson,


Thanks for your inquiry. I am afraid currently Aspose.Pdf for .NET does not support to flatten a layered object. We will keep you updated about the issue resolution, PDFNEWNET-36595 logged against PDF file (AsposeBarcodeTest_doesnotwork.pdf).

Thanks for your patience and cooperation.

Best Regards,


The issues you have found earlier (filed as PDFNEWNET-36594) have been fixed in Aspose.Pdf for .NET 9.2.0.

The blog post for this release is created over this link


This message was posted using Notification2Forum from Downloads module by Aspose Notifier.