Firebird pdf blob save as pdf-file by PHP










0















I have a blob which we receive from a Firebird 3.0 database.



if($dbh = ibase_connect($db,$username,$password, 'UTF-8')){
echo "Connecton steht zur Firebird DB steht! <br>";
$sql = "SELECT MEMO FROM DMS where ID = '44'";
// Execute query
$rc = ibase_query($dbh, $sql);
// Get the result row by row as object
$data = ibase_fetch_object($rc);
$blob_data = ibase_blob_info($data->MEMO);
$blob_hndl = ibase_blob_open($data->MEMO);

$inhalt = ibase_blob_get($blob_hndl, $blob_data[0]);


With



ibase_blob_echo($data->MEMO)


there comes a lot of signs in browser, so the SQL query works. Now I'd like to write the content (its a PDF) in a pdf file on disk.



Every try didn't succeed:



file_put_contents('test.pdf', $inhalt);
file_put_contents('test.pdf', ibase_blob_echo($data->MEMO));


and much more.



When we try to open the PDF File with Acrobat Reader, there comes an error message: no PDF File / File-type is not supported



How can we fix this?










share|improve this question
























  • What is the datatype of the column? Given your problem description I suspect it is a blob sub_type text, not a blob sub_type binary, which means the file will be corrupted.

    – Mark Rotteveel
    Nov 14 '18 at 17:13











  • maybe you should check the file content beginning: en.wikipedia.org/wiki/List_of_file_signatures and there are programs for both UNIX and Windows which have their guessing databases. P.S. also do you close the BLOB handle?

    – Arioch 'The
    Nov 14 '18 at 17:19












  • People has to cut the prefix from the BLOB here: stackoverflow.com/questions/21608810 Dunno if that is applied here

    – Arioch 'The
    Nov 14 '18 at 17:26






  • 1





    Most probably the blog is big, split into many segments, and you only download first segment of the file, deleting all the rest. See the comments at php.net/manual/ru/function.ibase-blob-get.php

    – Arioch 'The
    Nov 14 '18 at 17:28











  • @Arioch'The IIRC that question was about an application specific storage format, and not a general problem.

    – Mark Rotteveel
    Nov 14 '18 at 18:12















0















I have a blob which we receive from a Firebird 3.0 database.



if($dbh = ibase_connect($db,$username,$password, 'UTF-8')){
echo "Connecton steht zur Firebird DB steht! <br>";
$sql = "SELECT MEMO FROM DMS where ID = '44'";
// Execute query
$rc = ibase_query($dbh, $sql);
// Get the result row by row as object
$data = ibase_fetch_object($rc);
$blob_data = ibase_blob_info($data->MEMO);
$blob_hndl = ibase_blob_open($data->MEMO);

$inhalt = ibase_blob_get($blob_hndl, $blob_data[0]);


With



ibase_blob_echo($data->MEMO)


there comes a lot of signs in browser, so the SQL query works. Now I'd like to write the content (its a PDF) in a pdf file on disk.



Every try didn't succeed:



file_put_contents('test.pdf', $inhalt);
file_put_contents('test.pdf', ibase_blob_echo($data->MEMO));


and much more.



When we try to open the PDF File with Acrobat Reader, there comes an error message: no PDF File / File-type is not supported



How can we fix this?










share|improve this question
























  • What is the datatype of the column? Given your problem description I suspect it is a blob sub_type text, not a blob sub_type binary, which means the file will be corrupted.

    – Mark Rotteveel
    Nov 14 '18 at 17:13











  • maybe you should check the file content beginning: en.wikipedia.org/wiki/List_of_file_signatures and there are programs for both UNIX and Windows which have their guessing databases. P.S. also do you close the BLOB handle?

    – Arioch 'The
    Nov 14 '18 at 17:19












  • People has to cut the prefix from the BLOB here: stackoverflow.com/questions/21608810 Dunno if that is applied here

    – Arioch 'The
    Nov 14 '18 at 17:26






  • 1





    Most probably the blog is big, split into many segments, and you only download first segment of the file, deleting all the rest. See the comments at php.net/manual/ru/function.ibase-blob-get.php

    – Arioch 'The
    Nov 14 '18 at 17:28











  • @Arioch'The IIRC that question was about an application specific storage format, and not a general problem.

    – Mark Rotteveel
    Nov 14 '18 at 18:12













0












0








0








I have a blob which we receive from a Firebird 3.0 database.



if($dbh = ibase_connect($db,$username,$password, 'UTF-8')){
echo "Connecton steht zur Firebird DB steht! <br>";
$sql = "SELECT MEMO FROM DMS where ID = '44'";
// Execute query
$rc = ibase_query($dbh, $sql);
// Get the result row by row as object
$data = ibase_fetch_object($rc);
$blob_data = ibase_blob_info($data->MEMO);
$blob_hndl = ibase_blob_open($data->MEMO);

$inhalt = ibase_blob_get($blob_hndl, $blob_data[0]);


With



ibase_blob_echo($data->MEMO)


there comes a lot of signs in browser, so the SQL query works. Now I'd like to write the content (its a PDF) in a pdf file on disk.



Every try didn't succeed:



file_put_contents('test.pdf', $inhalt);
file_put_contents('test.pdf', ibase_blob_echo($data->MEMO));


and much more.



When we try to open the PDF File with Acrobat Reader, there comes an error message: no PDF File / File-type is not supported



How can we fix this?










share|improve this question
















I have a blob which we receive from a Firebird 3.0 database.



if($dbh = ibase_connect($db,$username,$password, 'UTF-8')){
echo "Connecton steht zur Firebird DB steht! <br>";
$sql = "SELECT MEMO FROM DMS where ID = '44'";
// Execute query
$rc = ibase_query($dbh, $sql);
// Get the result row by row as object
$data = ibase_fetch_object($rc);
$blob_data = ibase_blob_info($data->MEMO);
$blob_hndl = ibase_blob_open($data->MEMO);

$inhalt = ibase_blob_get($blob_hndl, $blob_data[0]);


With



ibase_blob_echo($data->MEMO)


there comes a lot of signs in browser, so the SQL query works. Now I'd like to write the content (its a PDF) in a pdf file on disk.



Every try didn't succeed:



file_put_contents('test.pdf', $inhalt);
file_put_contents('test.pdf', ibase_blob_echo($data->MEMO));


and much more.



When we try to open the PDF File with Acrobat Reader, there comes an error message: no PDF File / File-type is not supported



How can we fix this?







php blob firebird






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Nov 14 '18 at 17:15









Mark Rotteveel

61.3k1478121




61.3k1478121










asked Nov 14 '18 at 16:31









Kap GalloKap Gallo

12




12












  • What is the datatype of the column? Given your problem description I suspect it is a blob sub_type text, not a blob sub_type binary, which means the file will be corrupted.

    – Mark Rotteveel
    Nov 14 '18 at 17:13











  • maybe you should check the file content beginning: en.wikipedia.org/wiki/List_of_file_signatures and there are programs for both UNIX and Windows which have their guessing databases. P.S. also do you close the BLOB handle?

    – Arioch 'The
    Nov 14 '18 at 17:19












  • People has to cut the prefix from the BLOB here: stackoverflow.com/questions/21608810 Dunno if that is applied here

    – Arioch 'The
    Nov 14 '18 at 17:26






  • 1





    Most probably the blog is big, split into many segments, and you only download first segment of the file, deleting all the rest. See the comments at php.net/manual/ru/function.ibase-blob-get.php

    – Arioch 'The
    Nov 14 '18 at 17:28











  • @Arioch'The IIRC that question was about an application specific storage format, and not a general problem.

    – Mark Rotteveel
    Nov 14 '18 at 18:12

















  • What is the datatype of the column? Given your problem description I suspect it is a blob sub_type text, not a blob sub_type binary, which means the file will be corrupted.

    – Mark Rotteveel
    Nov 14 '18 at 17:13











  • maybe you should check the file content beginning: en.wikipedia.org/wiki/List_of_file_signatures and there are programs for both UNIX and Windows which have their guessing databases. P.S. also do you close the BLOB handle?

    – Arioch 'The
    Nov 14 '18 at 17:19












  • People has to cut the prefix from the BLOB here: stackoverflow.com/questions/21608810 Dunno if that is applied here

    – Arioch 'The
    Nov 14 '18 at 17:26






  • 1





    Most probably the blog is big, split into many segments, and you only download first segment of the file, deleting all the rest. See the comments at php.net/manual/ru/function.ibase-blob-get.php

    – Arioch 'The
    Nov 14 '18 at 17:28











  • @Arioch'The IIRC that question was about an application specific storage format, and not a general problem.

    – Mark Rotteveel
    Nov 14 '18 at 18:12
















What is the datatype of the column? Given your problem description I suspect it is a blob sub_type text, not a blob sub_type binary, which means the file will be corrupted.

– Mark Rotteveel
Nov 14 '18 at 17:13





What is the datatype of the column? Given your problem description I suspect it is a blob sub_type text, not a blob sub_type binary, which means the file will be corrupted.

– Mark Rotteveel
Nov 14 '18 at 17:13













maybe you should check the file content beginning: en.wikipedia.org/wiki/List_of_file_signatures and there are programs for both UNIX and Windows which have their guessing databases. P.S. also do you close the BLOB handle?

– Arioch 'The
Nov 14 '18 at 17:19






maybe you should check the file content beginning: en.wikipedia.org/wiki/List_of_file_signatures and there are programs for both UNIX and Windows which have their guessing databases. P.S. also do you close the BLOB handle?

– Arioch 'The
Nov 14 '18 at 17:19














People has to cut the prefix from the BLOB here: stackoverflow.com/questions/21608810 Dunno if that is applied here

– Arioch 'The
Nov 14 '18 at 17:26





People has to cut the prefix from the BLOB here: stackoverflow.com/questions/21608810 Dunno if that is applied here

– Arioch 'The
Nov 14 '18 at 17:26




1




1





Most probably the blog is big, split into many segments, and you only download first segment of the file, deleting all the rest. See the comments at php.net/manual/ru/function.ibase-blob-get.php

– Arioch 'The
Nov 14 '18 at 17:28





Most probably the blog is big, split into many segments, and you only download first segment of the file, deleting all the rest. See the comments at php.net/manual/ru/function.ibase-blob-get.php

– Arioch 'The
Nov 14 '18 at 17:28













@Arioch'The IIRC that question was about an application specific storage format, and not a general problem.

– Mark Rotteveel
Nov 14 '18 at 18:12





@Arioch'The IIRC that question was about an application specific storage format, and not a general problem.

– Mark Rotteveel
Nov 14 '18 at 18:12












1 Answer
1






active

oldest

votes


















0














thank you for your answers ... We interpreted them in a way, that the code above is basicly correct. After a while, we found out, that the error apears because we changed the charset in the DB Connect to UTF8 for the varchar Fields. For the blob we connect now without Charset change and the readout work properly. Thank you again.



$dbh = ibase_connect($db,$username,$password)





share|improve this answer




















  • 1





    That would indicate your blobs are sub_type text, not sub_type binary; you would need to fix that, instead of using a separate connection (and associated overhead).

    – Mark Rotteveel
    Nov 15 '18 at 10:41












  • w.r.t. "code correct" I wonder what is your maximum BLOB size... Try putting some 100MB zip file into the blob and then read it out using that simplified code. Will it ever work? Also, you did not say if you close blob handle or not. The leakage of handles is a known case of Firebird performance steady degradation.

    – Arioch 'The
    Nov 19 '18 at 8:52










Your Answer






StackExchange.ifUsing("editor", function ()
StackExchange.using("externalEditor", function ()
StackExchange.using("snippets", function ()
StackExchange.snippets.init();
);
);
, "code-snippets");

StackExchange.ready(function()
var channelOptions =
tags: "".split(" "),
id: "1"
;
initTagRenderer("".split(" "), "".split(" "), channelOptions);

StackExchange.using("externalEditor", function()
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled)
StackExchange.using("snippets", function()
createEditor();
);

else
createEditor();

);

function createEditor()
StackExchange.prepareEditor(
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader:
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
,
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
);



);













draft saved

draft discarded


















StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53304792%2ffirebird-pdf-blob-save-as-pdf-file-by-php%23new-answer', 'question_page');

);

Post as a guest















Required, but never shown

























1 Answer
1






active

oldest

votes








1 Answer
1






active

oldest

votes









active

oldest

votes






active

oldest

votes









0














thank you for your answers ... We interpreted them in a way, that the code above is basicly correct. After a while, we found out, that the error apears because we changed the charset in the DB Connect to UTF8 for the varchar Fields. For the blob we connect now without Charset change and the readout work properly. Thank you again.



$dbh = ibase_connect($db,$username,$password)





share|improve this answer




















  • 1





    That would indicate your blobs are sub_type text, not sub_type binary; you would need to fix that, instead of using a separate connection (and associated overhead).

    – Mark Rotteveel
    Nov 15 '18 at 10:41












  • w.r.t. "code correct" I wonder what is your maximum BLOB size... Try putting some 100MB zip file into the blob and then read it out using that simplified code. Will it ever work? Also, you did not say if you close blob handle or not. The leakage of handles is a known case of Firebird performance steady degradation.

    – Arioch 'The
    Nov 19 '18 at 8:52















0














thank you for your answers ... We interpreted them in a way, that the code above is basicly correct. After a while, we found out, that the error apears because we changed the charset in the DB Connect to UTF8 for the varchar Fields. For the blob we connect now without Charset change and the readout work properly. Thank you again.



$dbh = ibase_connect($db,$username,$password)





share|improve this answer




















  • 1





    That would indicate your blobs are sub_type text, not sub_type binary; you would need to fix that, instead of using a separate connection (and associated overhead).

    – Mark Rotteveel
    Nov 15 '18 at 10:41












  • w.r.t. "code correct" I wonder what is your maximum BLOB size... Try putting some 100MB zip file into the blob and then read it out using that simplified code. Will it ever work? Also, you did not say if you close blob handle or not. The leakage of handles is a known case of Firebird performance steady degradation.

    – Arioch 'The
    Nov 19 '18 at 8:52













0












0








0







thank you for your answers ... We interpreted them in a way, that the code above is basicly correct. After a while, we found out, that the error apears because we changed the charset in the DB Connect to UTF8 for the varchar Fields. For the blob we connect now without Charset change and the readout work properly. Thank you again.



$dbh = ibase_connect($db,$username,$password)





share|improve this answer















thank you for your answers ... We interpreted them in a way, that the code above is basicly correct. After a while, we found out, that the error apears because we changed the charset in the DB Connect to UTF8 for the varchar Fields. For the blob we connect now without Charset change and the readout work properly. Thank you again.



$dbh = ibase_connect($db,$username,$password)






share|improve this answer














share|improve this answer



share|improve this answer








edited Nov 19 '18 at 15:50

























answered Nov 15 '18 at 10:28









Kap GalloKap Gallo

12




12







  • 1





    That would indicate your blobs are sub_type text, not sub_type binary; you would need to fix that, instead of using a separate connection (and associated overhead).

    – Mark Rotteveel
    Nov 15 '18 at 10:41












  • w.r.t. "code correct" I wonder what is your maximum BLOB size... Try putting some 100MB zip file into the blob and then read it out using that simplified code. Will it ever work? Also, you did not say if you close blob handle or not. The leakage of handles is a known case of Firebird performance steady degradation.

    – Arioch 'The
    Nov 19 '18 at 8:52












  • 1





    That would indicate your blobs are sub_type text, not sub_type binary; you would need to fix that, instead of using a separate connection (and associated overhead).

    – Mark Rotteveel
    Nov 15 '18 at 10:41












  • w.r.t. "code correct" I wonder what is your maximum BLOB size... Try putting some 100MB zip file into the blob and then read it out using that simplified code. Will it ever work? Also, you did not say if you close blob handle or not. The leakage of handles is a known case of Firebird performance steady degradation.

    – Arioch 'The
    Nov 19 '18 at 8:52







1




1





That would indicate your blobs are sub_type text, not sub_type binary; you would need to fix that, instead of using a separate connection (and associated overhead).

– Mark Rotteveel
Nov 15 '18 at 10:41






That would indicate your blobs are sub_type text, not sub_type binary; you would need to fix that, instead of using a separate connection (and associated overhead).

– Mark Rotteveel
Nov 15 '18 at 10:41














w.r.t. "code correct" I wonder what is your maximum BLOB size... Try putting some 100MB zip file into the blob and then read it out using that simplified code. Will it ever work? Also, you did not say if you close blob handle or not. The leakage of handles is a known case of Firebird performance steady degradation.

– Arioch 'The
Nov 19 '18 at 8:52





w.r.t. "code correct" I wonder what is your maximum BLOB size... Try putting some 100MB zip file into the blob and then read it out using that simplified code. Will it ever work? Also, you did not say if you close blob handle or not. The leakage of handles is a known case of Firebird performance steady degradation.

– Arioch 'The
Nov 19 '18 at 8:52



















draft saved

draft discarded
















































Thanks for contributing an answer to Stack Overflow!


  • Please be sure to answer the question. Provide details and share your research!

But avoid


  • Asking for help, clarification, or responding to other answers.

  • Making statements based on opinion; back them up with references or personal experience.

To learn more, see our tips on writing great answers.




draft saved


draft discarded














StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53304792%2ffirebird-pdf-blob-save-as-pdf-file-by-php%23new-answer', 'question_page');

);

Post as a guest















Required, but never shown





















































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown

































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown







這個網誌中的熱門文章

How to read a connectionString WITH PROVIDER in .NET Core?

In R, how to develop a multiplot heatmap.2 figure showing key labels successfully

Museum of Modern and Contemporary Art of Trento and Rovereto