Announcement

Collapse
No announcement yet.

MergeDocument - possible to append PDF data using byte array instead of files?

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • MergeDocument - possible to append PDF data using byte array instead of files?

    I created a C# desktop application as a test, to see if I could append PDF information onto existing PDF files:

    MergeDocument mergeDocument = new MergeDocument();
    Page page = new Page(PageSize.Letter, PageOrientation.Portrait);

    page.Elements.Add(new Foxit.PDF.PageElements.Label("New TEST Cover Page", 0, 0, 512, 12));
    page.Elements.Add(new Foxit.PDF.PageElements.Label("2nd line", 0, 24, 512, 12));

    mergeDocument.Pages.Add(page);
    mergeDocument.Append(@"C:\sample.pdf");

    mergeDocument.Draw(@"C:\documents\outputResult.pdf ");

    This successfully appends data onto the beginning of a desktop PDF file. However, I am now required to duplicate this for a website.

    I am prevented from using the above code on the website - I receive an exception (due to potential security/access issues). What I would like to do instead is to use byte[] arrays, so the above would resemble something like:

    MergeDocument mergeDocument = new MergeDocument();
    Page page = new Page(PageSize.Letter, PageOrientation.Portrait);

    page.Elements.Add(new Foxit.PDF.PageElements.Label("New TEST Cover Page", 0, 0, 512, 12));
    page.Elements.Add(new Foxit.PDF.PageElements.Label("2nd line", 0, 24, 512, 12));

    mergeDocument.Pages.Add(page);
    mergeDocument.Append(byteArrayOfFileToBeAppended); //Bytte arrray of a file that already exists

    mergeDocument.Draw(byteArrayOfFileToBeOutput); //Result of combination, kept in byte array form

    The byteArrayOfFileToBeOutput represents the byte[] data for the file, and needs to be kept in this format until the site is able to create a file using the information.

    Thank you for your time. Please let me know if you require additional details.

    P.S. I understand Foxit's Generator SDK can output documents to a stream instead of a file; I'm following this hoping that we can stream or create an array for MergeDocument output.

  • #2
    I already answered this for Slipper2k. Any one else interested in the answer, please see the attached screen shots.
    You do not have permission to view this gallery.
    This gallery has 2 photos.

    Comment

    Working...
    X