I`m using free version of Spire.PDF, so here is a 10 page license limit. I tried to create several files, to avoid limit, but I got a bug: my first file is normal, but second and all the others have some strange imposing of "artifacts" in the left column of PdfTextWidgets.
After that, I had downloaded a full trial version, but it`s behavior is the same! If I create 1 large file (~100 pages) there is no any bug? but if I create 10 files ~ 10 pages in each of them, I have the same bug? as in free version. So, what can I do to solve my problem?
Here is my code:
- Code: Select all
public static void CreatePages(string[] codes, PdfDocument doc)
{
var section = CreateSection(doc);
PdfNewPage page = section.Pages.Add();
var itemCount = 0;
float h = 0;
float w = 0;
var countH = 0;
var countW = 1;
var pageCount = 1;
var pdfCount = 1;
var isSaved = true;
try
{
foreach (var item in codes)
{
isSaved = false;
var code = item.Replace(",", "");
var shortcode = "";
shortcode = item.Remove(0, 36);
shortcode = shortcode.Remove(GparseSym);
CreateImage(code);
code = code.Replace("/", "");
code = code.Replace("?", "");
code = code.Replace(":", "");
DrawImageQR(page, code + "_QRcode.png", h + Glmargin, w + Gtmargin); //0
PdfTextWidget text = new PdfTextWidget
{
Font = new PdfFont(PdfFontFamily.Courier, 10, PdfFontStyle.Bold),
Text = shortcode
};
text.Draw(page, h + GtextH, w + GtextW); //h - text horizontal, w text vertical // 5 55
w += Gintercol;
countH++;
if (countH == Gh)
{
w = 0;
h = countW * Ginterrow;
countW++;
countH = 0;
}
if (countW == Gw)
{
countW = 1;
countH = 0;
w = 0;
h = 0;
if (pageCount < 10)
{
if (itemCount < codes.Length - 1)
{
page = section.Pages.Add();
pageCount++;
}
}
else
{
doc.SaveToFile("PDFS\\Barcode_" + pdfCount + ".pdf");
doc.Close();
pdfCount++;
countW = 0;
countH = 0;
w = 0;
h = 0;
pageCount = 1;
doc = new PdfDocument();
if (itemCount < codes.Length)
{
section = CreateSection(doc);
page = section.Pages.Add();
}
isSaved = true;
}
}
itemCount++;
Thread.Sleep(50);
}
if (!isSaved)
{
doc.SaveToFile("PDFS\\Barcode_" + pdfCount + ".pdf");
doc.Close();
}
}
catch (Exception ex)
{
Console.WriteLine("Exception: " + ex.Message);
}
}