Semi-blank PDF with v3.6.2.0 when Culture in fr-CA

Hi,

I’ve got a weird bug. PDF generated with Aspose.PDF v3.6.1.0 work without any problem. But, the same exact PDF generated with Aspose.PDF v3.6.2.0 does not work when generated with the UI culture “fr-CA”. The PDF is semi-blank and when “alt-tabbing” out and back to Acrobat Reader 8.1.2, parts of the PDF are disappeared. Doing it a few times leads to a totally blank PDF.

Using Acrobat 7, it give an error message like : "An unrecognized token ‘1.275595E+07’ was found."

BUT, when using the culture “en-US”, it works perfectly… the PDF should be exactly the same, not localization or anything is done.

Do you have any idea what is happening?

Thanks,

Dominic.

Hi,

Can you please provide us with the sour code that is used to generate the pdf along with any input files used and the ouput that you get, so that we can test it and more accurately determine the cause of the problem.

Thanks.

Hi, another bug related to culture:

Using the code below, the PDF is generated quickly (a few seconds) when the culture is set to en-US, but it loops forever when the culture is fr-CA. Eventually, after more than 1 minute, I kill the aspnet_wp.exe process to stop it from hogging all the processor…

With v3.6.1.0, it works in a second…

Culture is set like so:
string culture = “fr-CA”; // or en-US (from a cookie)
cultureInfo = new CultureInfo(culture);
System.Threading.Thread.CurrentThread.CurrentCulture = cultureInfo;
System.Threading.Thread.CurrentThread.CurrentUICulture = cultureInfo;

This is the same code as here :
Right-aligned tabstop with different TextInfo

Thanks,



Dominic.

private void GenereatePdfError2()
{
const float MM2PT = 2.8346456692913385826771653543307f;

Aspose.Pdf.Pdf pdfDocument = new Aspose.Pdf.Pdf();

Aspose.Pdf.Text pdfText;
Aspose.Pdf.Segment pdfSegment;
Aspose.Pdf.TextInfo pdfTextInfo;
Aspose.Pdf.Row pdfRow = null;
Aspose.Pdf.Cell pdfCell;
Aspose.Pdf.TabStop pdfTabStop;

pdfDocument.DestinationType = Aspose.Pdf.DestinationType.FitPage;
pdfDocument.PageSetup.PageHeight = Aspose.Pdf.PageSize.LetterHeight;
pdfDocument.PageSetup.PageWidth = Aspose.Pdf.PageSize.LetterWidth;

pdfDocument.PageSetup.Margin.Top = System.Convert.ToInt32(13 * MM2PT);
pdfDocument.PageSetup.Margin.Bottom = pdfDocument.PageSetup.Margin.Top;

pdfDocument.PageSetup.Margin.Left = System.Convert.ToInt32(4 * MM2PT);
pdfDocument.PageSetup.Margin.Right = pdfDocument.PageSetup.Margin.Left;

Aspose.Pdf.Section pdfSection;
pdfSection = pdfDocument.Sections.Add();

// Create labels table
Aspose.Pdf.Table pdfTable = new Aspose.Pdf.Table();
pdfSection.Paragraphs.Add(pdfTable);

pdfTable.Alignment = Aspose.Pdf.AlignmentType.Center;

pdfTable.IsFirstRowRepeated = false;
pdfTable.IsRowBroken = false;

float cellWidth = 66.7f * MM2PT;
float cellHeight = 25.4f * MM2PT;
float spacer = 4f * MM2PT;

StringBuilder build = new StringBuilder(cellWidth.ToString());
build.Append(" “);
build.Append(spacer.ToString());
build.Append(” “);
build.Append(cellWidth.ToString());
build.Append(” “);
build.Append(spacer.ToString());
build.Append(” “);
build.Append(cellWidth.ToString());
build.Append(” “);
build.Append(spacer.ToString());
build.Append(” ");
build.Append(cellWidth.ToString());

pdfTable.ColumnWidths = build.ToString();

pdfTable.DefaultCellPadding = new Aspose.Pdf.MarginInfo();
pdfTable.DefaultCellPadding.Top = System.Convert.ToInt32(2 * MM2PT);
pdfTable.DefaultCellPadding.Right = pdfTable.DefaultCellPadding.Top;
pdfTable.DefaultCellPadding.Left = pdfTable.DefaultCellPadding.Top;
pdfTable.DefaultCellPadding.Left = pdfTable.DefaultCellPadding.Top;

pdfTextInfo = new Aspose.Pdf.TextInfo();
pdfTextInfo.FontSize = 10;
pdfTextInfo.FontName = “Helvetica”;
pdfTable.DefaultCellTextInfo = pdfTextInfo;

const int NB_LABELS = 10;
int labelNo = 0;
for (int i=0; i<NB_LABELS; ++i) {
if (labelNo % 3 == 0) { // new row
pdfRow = pdfTable.Rows.Add();
pdfRow.DefaultCellTextInfo = pdfTable.DefaultCellTextInfo;
pdfRow.FixedRowHeight = cellHeight;
}
else {
pdfRow.Cells.Add(); // spacer
}

pdfCell = pdfRow.Cells.Add();
pdfCell.DefaultCellTextInfo = pdfRow.DefaultCellTextInfo;

pdfCell.Padding = new Aspose.Pdf.MarginInfo();
pdfCell.Padding.Top = 2 * MM2PT;
pdfCell.Padding.Bottom = 2 * MM2PT;
pdfCell.Padding.Right = 2 * MM2PT;
pdfCell.Padding.Left = 2 * MM2PT;

pdfTextInfo = pdfCell.DefaultCellTextInfo.Clone() as Aspose.Pdf.TextInfo;
pdfTextInfo.FontName = “Helvetica-Bold”;

pdfText = new Aspose.Pdf.Text();
pdfText.ID = i.ToString();

// left aligned text
pdfSegment = pdfText.Segments.Add();
pdfSegment.Content = "Left " + i;
pdfSegment.TextInfo = pdfTextInfo;

// right aligned text
pdfText.TabStops = new Aspose.Pdf.TabStops();
pdfTabStop = pdfText.TabStops.Add();
pdfTabStop.AlignmentType = Aspose.Pdf.TabAlignmentType.Right;
pdfTabStop.Position = cellWidth - pdfCell.Padding.Left - pdfCell.Padding.Right;

pdfTextInfo = pdfCell.DefaultCellTextInfo.Clone() as Aspose.Pdf.TextInfo;
pdfTextInfo.FontSize = 5 + i;
pdfTextInfo.FontName = “Courier”;

pdfSegment = pdfText.Segments.Add();
pdfSegment.Content = “\tRight” + i;
pdfSegment.TextInfo = pdfTextInfo;

pdfCell.Paragraphs.Add(pdfText);

++labelNo;
}

this.Page.Controls.Clear();
pdfDocument.Save(“pdftest.pdf”, Aspose.Pdf.SaveType.OpenInAcrobat, this.Response);
}

Hi,

I have tested your code and was able to reproduce the error. I have logged this as PDFNET-4505 in our issue tracking system. We will try our best to resolve this issue as soon as possible.

Thanks.

Do you think both problems in this thread are related? I’ll test as soon as you have the fix out.

As you can no doubt imagine, it’s quite urgent for me… :wink:

Hi,

First I have logged the Culture-Info problem, once we resolve that then we will move furthur, because blank pages problem might be arises due to same problem mentioned above. We will try our best to resolve it ASAP. We appreciate your patience.

Thanks.

For the ColumnWidths property, only neutral culture is supported. As a workaround, you can modify you code like the following:

System.Globalization.NumberFormatInfo formatInfo = new System.Globalization.CultureInfo( “en-US”, false ).NumberFormat;
build.Append(spacer.ToString(formatInfo));

Or set the culture of the thread to “en-US”. Sorry for the inconvenience.

That was it, really? An exception or error message would have been nice… Especially since it worked perfectly in v3.6.1.0…

I’ll use invariant culture instead of en-US though :
build.Append(spacer.ToString(System.Globalization.CultureInfo.InvariantCulture.NumberFormat));

But better yet, you should change pdfTable.ColumnWidths so it doesn’t use strings, but real numeric values…

Thanks for your help!

Dominic.

Dear Dominic,

You are right that we should throw some exception. We need more time to investigate this issue. We decided to support neutral culture number format only in 3.6.2 so it worked in 3.6.1. Maybe it is better to real numeric values but we also want to support flexible setting such as “30% 70%” or “2inch 30cm”.

In my own opinion, people will rarely use two different units in one table. So “2inch 30cm” is pretty unlikely. You could use two properties, one for the column widths numeric values, the other for the unit used.

But, then again, you could very well do something like this :

pdfTable.AddColumn(2, Aspose.Pdf.Units.Inch);

pdfTable.AddColumn(30, Aspose.Pdf.Units.Cm);

That would remove all culture-related issues…

Dominic.

Hi,

Thank you for the suggestion. We will keep that in mind.