none
Exporting pdf using itextsharp pdfcopy RRS feed

  • Question

  • I am using VS2019 and reading through a pdf report using pdfcopy to extract certain pages to export to a folder on sharepoint oinline using the savebinarydirect command. Since that command needs the memory stream I am trying to figure out how to do that. I am using the code below and it exports the file successfully but the pdf file is empty. I am assuming that is because the memory stream is empty but I am not sure how to get it populated.  

    Here is my code:

    Dim Mstream As New MemoryStream()
    doc = New iTextSharp.text.Document(reader_finsum.GetPageSizeWithRotation(1))
    pdfCpy = New iTextSharp.text.pdf.PdfCopy(doc, Mstream)
    doc.Open()
    page = pdfCpy.GetImportedPage(reader_finsum, counter)
    pdfCpy.AddPage(page)

    Dim creds As New SharePointOnlineCredentials(accountname, SecPass)
    Dim client As New ClientContext("https:" & ExportRptPath)
    client.Credentials = creds
    Microsoft.SharePoint.Client.File.SaveBinaryDirect(client, ExportRptPath, Mstream, True)
    doc.Close()

    Thursday, June 18, 2020 12:42 PM

All replies

  • Hi J-Bal,

    Thank you for posting here.

    In order to reproduce your problem, I need more information to make a test.

    Could you provide more related code about 'reader_finsum' ? It will help us to make a test.

    We are waiting for your update.

    Best Regards,

    Xingyu Zhao


    MSDN Community Support
    Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.

    Friday, June 19, 2020 9:52 AM
    Moderator