Spire.PDF is a professional PDF library applied to creating, writing, editing, handling and reading PDF files without any external dependencies. Get free and professional technical support for Spire.PDF for .NET, Java, Android, C++, Python.

Fri Feb 16, 2018 10:30 pm

Hi,

We are using Spire.pdf for pdf creation from existing pdf. We are using below code for generating a PDF. But after creating new document we are getting a pdf with blank pages without any data.

public byte[] CreatePDFFromPageNoWithBookmarks(Stream sourceStream, List<KeyValuePair<int, string>> PageNos)
{
byte[] finalDoc = null;
sourceStream.Seek(0, SeekOrigin.Begin);
using (System.IO.MemoryStream PDFDocument = new System.IO.MemoryStream())
{
if (PageNos != null && PageNos.Count > 0)
{
Spire.Pdf.PdfDocument sourcePdf = new Spire.Pdf.PdfDocument(sourceStream);
Spire.Pdf.PdfDocument newDoc = new Spire.Pdf.PdfDocument();
int NewDocPageindex = 0;
foreach (KeyValuePair<int, string> item in PageNos)
{
PdfPageBase page = sourcePdf.Pages[Convert.ToInt16(item.Key) - 1];
SizeF size = page.Size;
Spire.Pdf.Graphics.PdfTemplate template = page.CreateTemplate();
PdfPageBase newPage = newDoc.Pages.Add(size, new PdfMargins(0));
PdfTextLayout loLayout = new PdfTextLayout();
loLayout.Layout = PdfLayoutType.OnePage;
page.CreateTemplate().Draw(newPage, new PointF(0, 0), loLayout);
if (!string.IsNullOrEmpty(item.Value))
{
Spire.Pdf.General.PdfDestination partBookmarkDest = new Spire.Pdf.General.PdfDestination(newPage, new PointF(0, NewDocPageindex));
Spire.Pdf.Bookmarks.PdfBookmark partBookmark = newDoc.Bookmarks.Add(item.Value);
partBookmark.Action = new Spire.Pdf.Actions.PdfGoToAction(partBookmarkDest);
}
NewDocPageindex++;
}
newDoc.SaveToStream(PDFDocument, Spire.Pdf.FileFormat.PDF);
}
finalDoc = PDFDocument.ToArray();
}
return finalDoc;
}


But if we use the below code then there is no issue and pdf is generating with data.

sourcePdf = new Spire.Pdf.PdfDocument(sourceStream);
newDoc = new Spire.Pdf.PdfDocument();
foreach (KeyValuePair<int, string> item in PageNos)
{
newDoc.InsertPage(sourcePdf, Convert.ToInt16(item.Key) - 1);

}

I have attached the sample return. Could you please help us to resolve this issue.

Thanks
Dinesh

dineshpk2010@gmail.com
 
Posts: 6
Joined: Thu Oct 06, 2016 7:00 am

Mon Feb 19, 2018 6:44 am

Dear Sajitha,

Thanks for your inquiry.
I have noticed your issue and logged it into our bug system. Sorry for the inconvenience caused. We will notify you when there is any update on it.

Sincerely,
Amy
E-iceblue support team
User avatar

amy.zhao
 
Posts: 2766
Joined: Wed Jun 27, 2012 8:50 am

Tue Feb 20, 2018 5:21 pm

Hi Amy,

Thanks for your response.
Can I get the update?

Thanks
Sajitha

dineshpk2010@gmail.com
 
Posts: 6
Joined: Thu Oct 06, 2016 7:00 am

Wed Feb 21, 2018 4:07 am

Hello Sajitha,

Sorry there is no update at present as we are having our days off for Chinese Spring Festival(2018/2/15-2018/2/21). Once we are back to office, we will let our dev team to fix your issue. We will keep you informed if there is any update.

Sincerely,
Amy
E-iceblue support team
User avatar

amy.zhao
 
Posts: 2766
Joined: Wed Jun 27, 2012 8:50 am

Mon Feb 26, 2018 1:32 pm

Hi Amy,

Awaiting response , Please let us know the update for the reported issue.

Thanks
Dinesh

dineshpk2010@gmail.com
 
Posts: 6
Joined: Thu Oct 06, 2016 7:00 am

Tue Feb 27, 2018 6:06 am

Hello,

Thanks for your inquiry.
We will update you as soon as we get a feedback from our dev team.

Sincerely,
Amy
E-iceblue support team
User avatar

amy.zhao
 
Posts: 2766
Joined: Wed Jun 27, 2012 8:50 am

Return to Spire.PDF