Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 706881
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 14, 20262026-05-14T04:12:55+00:00 2026-05-14T04:12:55+00:00

I am having a bit of a problem, I am trying to get a

  • 0

I am having a bit of a problem, I am trying to get a PDF as a resource in my application.
At this point I have a fillable PDF that I have been able to store as a file next to the binary, but now I am trying to embed the PDF as a resource in the binary.

byte[] buffer;
try
{
    s = typeof(BattleTracker).Assembly.GetManifestResourceStream("libReports.Resources.DAForm1594.pdf");
    buffer = new byte[s.Length];
    int read = 0;
    do
    {
        read = s.Read(buffer, read, 32768);

    } while (read > 0);                        
}
catch (Exception e)
{
    throw new Exception("Error: could not import report:", e);
}

// read existing PDF document
PdfReader r = new PdfReader(
    // optimize memory usage
    buffer, null
);

Every time I run the code I get an error saying “Rebuild trailer not found. Original Error: PDF startxref not found”.

When I was just opening the file via a path to the static file in my directory it worked fine. I have tried using different encodings UTF-8, UTF-32, UTF-7, ASCII, etc etc….
As a side note I had the same problem with getting a Powerpoint file as a resource, I was finally able to fix that problem by converting the Powerpoint to xml and using that.
I have considered doing the same for the PDF but I am referencing elements by field name which does not seem to work with XML PDFs.

Can anyone help me out with this?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-14T04:12:56+00:00Added an answer on May 14, 2026 at 4:12 am

    Change the code in your try block to this:

    using (s = typeof(BattleTracker).Assembly.GetManifestResourceStream
        ("libReports.Resources.DAForm1594.pdf"))
    {
        buffer = new byte[(int)s.Length]; 
        s.Read(buffer, 0, (int)s.Length);
    }
    

    I assume that you have the correct path to your resource, and that its Build Action property is set to Embedded Resource.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm having a bit of a problem trying to get touchesBegan to respond to
I am having a bit of a problem. I get a RAW char* buffer
I'm having a bit of a problem. I have a datatable in the parent
I'm having a bit of a problem here. We have 2 urls let me
I'm having an annoying problem trying to get an html page with a google
I am having a bit of a brain block with this problem and I
This is an odd problem, so I have to provide a bit of background.
I am having a problem trying to deserialise this XML: <?xml version=1.0 encoding=UTF-8?> <links>
I've been trying to fix a problem i've been having all afternoon and was
I'm writing my first bit of jQuery, and I'm having a problem with jQuery.get()

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.