<html>
  <head>
    <meta http-equiv="Content-Type" content="text/html;
      charset=windows-1252">
  </head>
  <body>
    <p>Thank you very much !<br>
    </p>
    <p>This is what I expected : I had not search enough to find 
      PDFDoc(BaseStream *strA...</p>
    <p>I start on that..<br>
    </p>
    <p><br>
    </p>
    <p><br>
    </p>
    <div class="moz-cite-prefix">On 7/18/21 3:44 AM, William Bader
      wrote:<br>
    </div>
    <blockquote type="cite"
cite="mid:PR3PR09MB54749829808813AF9992F6B6C4E09@PR3PR09MB5474.eurprd09.prod.outlook.com">
      <meta http-equiv="Content-Type" content="text/html;
        charset=windows-1252">
      <style type="text/css" style="display:none;">P {margin-top:0;margin-bottom:0;}</style>
      <div style="font-family: Calibri, Helvetica, sans-serif;
        font-size: 12pt; color: rgb(0, 0, 0);">
        utils/pdfunite.cc opens its input files with PDFDoc *doc = new
        PDFDoc(gfileName, NULL, NULL, NULL)</div>
      <div style="font-family: Calibri, Helvetica, sans-serif;
        font-size: 12pt; color: rgb(0, 0, 0);">
        poppler/PDFDoc.h also provides PDFDoc(BaseStream *strA,
        GooString *ownerPassword = NULL, GooString *userPassword = NULL,
        void *guiDataA = NULL)</div>
      <div style="font-family: Calibri, Helvetica, sans-serif;
        font-size: 12pt; color: rgb(0, 0, 0);">
        poppler/Stream.h provides MemStream(char *bufA, Goffset startA,
        Goffset lengthA, Object &&dictA) that you could probably
        use like MemStream *mStream = new MemStream(s->getCString(),
        0, s->getLength(), Object(objNull))</div>
      <div style="font-family: Calibri, Helvetica, sans-serif;
        font-size: 12pt; color: rgb(0, 0, 0);">
        So if you are lucky, you can make a MemStream for each in-memory
        PDF, then make a PDFDoc for each MemStream, and then
        cut-and-paste the code in pdfunite.cc that combines the PDFDoc
        objects.<br>
        Running "pdfunite <(cat a.pdf) <(cat b.pdf) ab.pdf" from
        bash fails with "Syntax Error: Document stream is empty" "Syntax
        Error: Could not merge damaged documents ('/dev/fd/63')", so
        PDFDoc might require input that is seekable, so if you are
        using std::istream, if the underlying data is from a
        stringstream, it might work, but if it is from an fstream, you
        might have to read it all into a buffer.</div>
      <div>
        <div style="font-family:Calibri,Helvetica,sans-serif;
          font-size:12pt; color:rgb(0,0,0)">
          William</div>
        <div style="font-family:Calibri,Helvetica,sans-serif;
          font-size:12pt; color:rgb(0,0,0)">
          <br>
        </div>
        <hr tabindex="-1" style="display:inline-block; width:98%">
        <div id="divRplyFwdMsg" dir="ltr"><font style="font-size:11pt"
            face="Calibri, sans-serif" color="#000000"><b>From:</b>
            poppler <a class="moz-txt-link-rfc2396E" href="mailto:poppler-bounces@lists.freedesktop.org"><poppler-bounces@lists.freedesktop.org></a> on
            behalf of Pierre Couderc <a class="moz-txt-link-rfc2396E" href="mailto:pierre@couderc.eu"><pierre@couderc.eu></a><br>
            <b>Sent:</b> Saturday, July 17, 2021 5:33 PM<br>
            <b>To:</b> <a class="moz-txt-link-abbreviated" href="mailto:poppler@lists.freedesktop.org">poppler@lists.freedesktop.org</a>
            <a class="moz-txt-link-rfc2396E" href="mailto:poppler@lists.freedesktop.org"><poppler@lists.freedesktop.org></a><br>
            <b>Subject:</b> Re: [poppler] How to "pdfunite" in
            memory...?</font>
          <div> </div>
        </div>
        <div class="BodyFragment"><font size="2"><span
              style="font-size:11pt">
              <div class="PlainText">On 7/17/21 8:43 PM, Oliver Sander
                wrote:<br>
                >> I do not understand well your question. But I
                know that a pdf <br>
                >> document contains pages.<br>
                >><br>
                >> I have pdf documents in memory (read from a
                database) and I need to <br>
                >> merge these documents in memory to write them
                back in a database...<br>
                ><br>
                > You need to give a few more details about what you
                mean by "I have pdf <br>
                > documents in memory".<br>
                > Does that mean that you simply copied the file
                content to some <br>
                > allocated memory?  Or have<br>
                > you opened these pdf files using poppler (using
                code like in <br>
                > poppler/qt5/demos)?<br>
                ><br>
                > You need to do the latter to solve your problem. 
                Open the files using <br>
                > poppler,<br>
                > and then copy code that unites them from
                pdfunite.cc (licences <br>
                > permitting).<br>
                ><br>
                > Best,<br>
                > Oliver<br>
                ><br>
                Sorry to not be clear : I upload pdf documents (with a
                c++ cppcms <br>
                server), I get them in some std::istream, I need to
                manipulate pages of <br>
                these documents, create new  documents from these pages,
                store these <br>
                documents in bytea postgresql db, extract text from
                them, retrieve them <br>
                when a user ask to download them...<br>
                <br>
                poppler can make the job, but I do not need and I would
                like to avoid to <br>
                use files to do all that...<br>
                <br>
                So my question : what is the best strategy ?<br>
                <br>
                I have no license problem, all is open source.<br>
                <br>
                Thank you<br>
                <br>
                PX.<br>
                <br>
                <br>
                _______________________________________________<br>
                poppler mailing list<br>
                <a class="moz-txt-link-abbreviated" href="mailto:poppler@lists.freedesktop.org">poppler@lists.freedesktop.org</a><br>
                <a
                  href="https://lists.freedesktop.org/mailman/listinfo/poppler"
                  moz-do-not-send="true">https://lists.freedesktop.org/mailman/listinfo/poppler</a><br>
              </div>
            </span></font></div>
      </div>
    </blockquote>
  </body>
</html>